//Project2.s MysteryFunction1:     movl    $1, %eax //     jmp    .L2 .L3:     imulq    %rdi, %rax     movl    %edx, %esi .L2:     leal    -1(%rsi), %edx     testl    %esi, %esi     jg    .L3     ret   MysteryFunction2:     movl    $0, %edx     movl    $0, %ecx     jmp    .L5 .L6:     addl    $1, %ecx .L5:     cmpl    $31, %ecx     ja    .L8     movl    $1, %eax     sall    %cl, %eax     testl    %edi, %eax     je    .L6     movl    $-2147483648, %eax     shrl    %cl, %eax     orl    %eax, %edx     jmp    .L6 .L8:     movl    %edx, %eax     ret MysteryFunction3:     movq    (%rdi), %rcx     movl    $1, %eax     jmp    .L10 .L11:     addl    $1, %eax .L10:     cmpl    %esi, %eax     jge    .L14     movslq    %eax, %rdx     movq    (%rdi,%rdx,8), %rdx     cmpq    %rcx, %rdx     jle    .L11     movq    %rdx, %rcx     jmp    .L11 .L14:     movq    %rcx, %rax     ret MysteryFunction4:     movl    $0, %eax     jmp    .L16 .L17:     movl    %edi, %edx     andl    $1, %edx     addl    %edx, %eax     shrq    %rdi .L16:     testq    %rdi, %rdi     jne    .L17     ret MysteryFunction5:     xorl    %esi, %edi     movl    $0, %eax     jmp    .L19 .L20:     movl    %edi, %edx     andl    $1, %edx     addl    %edx, %eax     sarl    %edi .L19:     testl    %edi, %edi     jne    .L20     ret   //Project2.c /*   * CSCI3240: Project 2  *   *  *   * Project2.c - Source file with your solutions to the Lab.  *          This is the file you will submit in the D2L -> Project2 dropbox.  *  *   Make sure you have insightful comments in your code.   *   */ long MysteryFunction1(long a, int b){    //TODO    //check assembly code for MysteryFunction1 in project3.s } unsigned int MysteryFunction2(unsigned int num) {      //TODO    //check assembly code for MysteryFunction2 in project3.s   } long MysteryFunction3(long *a, int n){    //TODO    //check assembly code for MysteryFunction3 in project3.s } int MysteryFunction4(unsigned long n) {       //TODO    //check assembly code for MysteryFunction4 in project3.s }   unsigned int MysteryFunction5(unsigned int A, unsigned int B) {   //TODO    //check assembly code for MysteryFunction5 in project3.s }   Please help me read these mystery functions to c code.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

//Project2.s
MysteryFunction1:
    movl    $1, %eax //
    jmp    .L2
.L3:
    imulq    %rdi, %rax
    movl    %edx, %esi
.L2:
    leal    -1(%rsi), %edx
    testl    %esi, %esi
    jg    .L3
    ret

 


MysteryFunction2:
    movl    $0, %edx
    movl    $0, %ecx
    jmp    .L5
.L6:
    addl    $1, %ecx
.L5:
    cmpl    $31, %ecx
    ja    .L8
    movl    $1, %eax
    sall    %cl, %eax
    testl    %edi, %eax
    je    .L6
    movl    $-2147483648, %eax
    shrl    %cl, %eax
    orl    %eax, %edx
    jmp    .L6
.L8:
    movl    %edx, %eax
    ret

MysteryFunction3:
    movq    (%rdi), %rcx
    movl    $1, %eax
    jmp    .L10
.L11:
    addl    $1, %eax
.L10:
    cmpl    %esi, %eax
    jge    .L14
    movslq    %eax, %rdx
    movq    (%rdi,%rdx,8), %rdx
    cmpq    %rcx, %rdx
    jle    .L11
    movq    %rdx, %rcx
    jmp    .L11
.L14:
    movq    %rcx, %rax
    ret

MysteryFunction4:
    movl    $0, %eax
    jmp    .L16
.L17:
    movl    %edi, %edx
    andl    $1, %edx
    addl    %edx, %eax
    shrq    %rdi
.L16:
    testq    %rdi, %rdi
    jne    .L17
    ret

MysteryFunction5:
    xorl    %esi, %edi
    movl    $0, %eax
    jmp    .L19
.L20:
    movl    %edi, %edx
    andl    $1, %edx
    addl    %edx, %eax
    sarl    %edi
.L19:
    testl    %edi, %edi
    jne    .L20
    ret

 

//Project2.c
/* 
 * CSCI3240: Project 2
 * 
 * <Please put your name and userid here>
 * 
 * Project2.c - Source file with your solutions to the Lab.
 *          This is the file you will submit in the D2L -> Project2 dropbox.
 *
 *   Make sure you have insightful comments in your code. 
 * 
 */


long MysteryFunction1(long a, int b){

   //TODO
   //check assembly code for MysteryFunction1 in project3.s
}


unsigned int MysteryFunction2(unsigned int num)
{
     //TODO
   //check assembly code for MysteryFunction2 in project3.s
 
}


long MysteryFunction3(long *a, int n){
   //TODO
   //check assembly code for MysteryFunction3 in project3.s
}

int MysteryFunction4(unsigned long n)
{
      //TODO
   //check assembly code for MysteryFunction4 in project3.s

}

 

unsigned int MysteryFunction5(unsigned int A, unsigned int B)
{
  //TODO
   //check assembly code for MysteryFunction5 in project3.s

}

 


Please help me read these mystery functions to c code.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Properties of CSS
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education