Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. [20] Consider the following C function long f(long a, long b, long c) When compiled (with Arch gcc), the resulting x86-64 code for the
2. [20] Consider the following C function long f(long a, long b, long c) When compiled (with Arch gcc), the resulting x86-64 code for the function body is addq %rsi, %rdx imu1q% rdx, %rdi salq $63, %rdx sarq $63, %rdx movq %rdi, %rax xorq %rax, %rax Assume that o is in %rdi, b is in %rsi, c is in %rdx, and that %rax is used to hold the return value. Your task is to reverse engineer the C code; specifically, to write a C implementation for the decode function that is functionally equivalent to the compiled x86-64 code above Here are some test runs: f (1, 2, 4) 6 f (3, 5, 7): 36 f (10, 20, 30): 500 Also write a main() function to test your function. Hint: try compiling your C code to x86-64 on Arch using gcc -0g -S3-2.c as you work. Note that the output assembly does not need to match the x86-64 code above exactly -it just needs to be functionally equivalent. Name your source file 3-2.c Zip the source files and solution document (if applicable), name the zip file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started