Question: Hi I need to convert the following into C code. The following is the gdb output for ex4: 0x4007c2 push %rbp 0x4007c3 push %rbx 0x4007c4

Hi I need to convert the following into C code. The following is the gdb output for ex4:

0x4007c2 Hi I need to convert the following into C code. The following push %rbp

0x4007c3 is the gdb output for ex4: 0x4007c2 push %rbp 0x4007c3 push %rbx push %rbx

0x4007c4 0x4007c4 sub $0x8, %rsp 0x4007c8 mov %rdi, %rbx 0x4007cb mov %rdi, %rax sub $0x8, %rsp

0x4007c8 0x4007ce cmp $0x1, %rdi 0x4007d2 jle 0x4007ec 0x4007d4 lea -0x1(%rdi), %rdi 0x4007d8 mov %rdi, %rbx

0x4007cb callq 0x4007c2 0x4007dd mov %rax, %rbp 0x4007e0 lea -0x2(%rbx), %rdi 0x4007e4 callq mov %rdi, %rax

0x4007ce 0x4007c2 0x4007e9 add %rbp, %rax 0x4007ec add $0x8, %rsp 0x4007f0 pop %rbx cmp $0x1, %rdi

0x4007d2 0x4007f1 pop %rbp 0x4007f2 retq The code should be converted into the jle 0x4007ec function void ex4 () {} where void should be replaced by int

0x4007d4 or other comparable data type and parameters should be inferred from the lea -0x1(%rdi), %rdi

0x4007d8 assembly en4 > callq 0x4007c2 image text in transcribed

0x4007dd image text in transcribed mov %rax, %rbp

0x4007e0 image text in transcribed lea -0x2(%rbx), %rdi

0x4007e4 image text in transcribed callq 0x4007c2 image text in transcribed

0x4007e9 image text in transcribed add %rbp, %rax

0x4007ec image text in transcribed add $0x8, %rsp

0x4007f0 image text in transcribed pop %rbx

0x4007f1image text in transcribed pop %rbp

0x4007f2image text in transcribed retq

The code should be converted into the function

void ex4 () {}

where void should be replaced by int or other comparable data type and parameters should be inferred from the assembly

en4 >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!