Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 Assignment3.zip (e.g., EricWillsAssignment3.zip), and upload the zip file to Canvas (see Assignments section for submission link)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

Identify three ways to manage an intergenerational workforce.

Answered: 1 week ago

Question

Prepare a Porters Five Forces analysis.

Answered: 1 week ago

Question

Analyze the impact of mergers and acquisitions on employees.

Answered: 1 week ago