Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you write the corresponding C code for this function. it can go in the function below Here are some input and outputs they are

image text in transcribed

image text in transcribed

Can you write the corresponding C code for this function. it can go in the function below Here are some input and outputs they are from 1-30 inclusive

Input 1

Output 4

-----------

Input 5

Output 7

-----------

Input 10

Output 30

-----------

Input 23

Output 69

-----------

Input 30

Output 90

the function has to be derived from the assebly as long as the C code output matches the outputs as shown it will do

unsigned int f5(unsigned int x) { }

00000000004007e4 :

4007e4: 48 83 ec 28 sub $0x28,%rsp

4007e8: 89 7c 24 0c mov %edi,0xc(%rsp)

4007ec: 83 7c 24 0c 05 cmpl $0x5,0xc(%rsp)

4007f1: 77 6f ja 400862

4007f3: 8b 44 24 0c mov 0xc(%rsp),%eax

4007f7: 48 8b 04 c5 30 0a 40 mov 0x400a30(,%rax,8),%rax

4007fe: 00

4007ff: ff e0 jmpq *%rax

400801: 8b 44 24 0c mov 0xc(%rsp),%eax

400805: c1 e8 02 shr $0x2,%eax

400808: 89 44 24 1c mov %eax,0x1c(%rsp)

40080c: eb 63 jmp 400871

40080e: 8b 44 24 0c mov 0xc(%rsp),%eax

400812: c1 e0 02 shl $0x2,%eax

400815: 89 44 24 1c mov %eax,0x1c(%rsp)

400819: eb 56 jmp 400871

40081b: 8b 44 24 0c mov 0xc(%rsp),%eax

40081f: 8d 50 01 lea 0x1(%rax),%edx

400822: 89 54 24 0c mov %edx,0xc(%rsp)

400826: 89 44 24 1c mov %eax,0x1c(%rsp)

40082a: eb 45 jmp 400871

40082c: 8b 44 24 0c mov 0xc(%rsp),%eax

400830: 89 c7 mov %eax,%edi

400832: b8 00 00 00 00 mov $0x0,%eax

400837: e8 3e 00 00 00 callq 40087a

40083c: 89 44 24 1c mov %eax,0x1c(%rsp)

400840: eb 2f jmp 400871

400842: 8b 44 24 0c mov 0xc(%rsp),%eax

400846: 89 c7 mov %eax,%edi

400848: b8 00 00 00 00 mov $0x0,%eax

40084d: e8 55 00 00 00 callq 4008a7

400852: 89 44 24 1c mov %eax,0x1c(%rsp)

400856: eb 19 jmp 400871

400858: c7 44 24 1c 07 00 00 movl $0x7,0x1c(%rsp)

40085f: 00

400860: eb 0f jmp 400871

400862: 8b 54 24 0c mov 0xc(%rsp),%edx

400866: 89 d0 mov %edx,%eax

400868: 01 c0 add %eax,%eax

40086a: 01 d0 add %edx,%eax

40086c: 89 44 24 1c mov %eax,0x1c(%rsp)

400870: 90 nop

400871: 8b 44 24 1c mov 0x1c(%rsp),%eax

400875: 48 83 c4 28 add $0x28,%rsp

400879: c3 retq

000000000040087a :

40087a: 89 7c 24 ec mov %edi,-0x14(%rsp)

40087e: c7 44 24 fc 01 00 00 movl $0x1,-0x4(%rsp)

400885: 00

400886: eb 13 jmp 40089b

400888: 8b 54 24 fc mov -0x4(%rsp),%edx

40088c: 8b 44 24 ec mov -0x14(%rsp),%eax

400890: 01 d0 add %edx,%eax

400892: 89 44 24 fc mov %eax,-0x4(%rsp)

400896: 83 6c 24 ec 01 subl $0x1,-0x14(%rsp)

40089b: 83 7c 24 ec 00 cmpl $0x0,-0x14(%rsp)

4008a0: 75 e6 jne 400888

4008a2: 8b 44 24 fc mov -0x4(%rsp),%eax

4008a6: c3 retq

00000000004008a7 :

4008a7: 89 7c 24 ec mov %edi,-0x14(%rsp)

4008ab: c7 44 24 fc 00 00 00 movl $0x0,-0x4(%rsp)

4008b2: 00

4008b3: eb 11 jmp 4008c6

4008b5: 8b 44 24 ec mov -0x14(%rsp),%eax

4008b9: 83 e0 01 and $0x1,%eax

4008bc: 89 c1 mov %eax,%ecx

4008be: d3 64 24 fc shll %cl,-0x4(%rsp)

4008c2: d1 6c 24 ec shrl -0x14(%rsp)

4008c6: 83 7c 24 ec 00 cmpl $0x0,-0x14(%rsp)

4008cb: 75 e8 jne 4008b5

4008cd: 8b 44 24 fc mov -0x4(%rsp),%eax

4008d1: c3 retq

4008d2: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)

4008d9: 00 00 00

4008dc: 0f 1f 40 00 nopl 0x0(%rax)

00000000004007e4 : 48 83 ec 28 83 7c 24 0c 05 8b 44 24 0c 0x28,%rs %edi,0xc (%rsp) $0x5, 0xc (%rsp) 4007e4: 4007e8: 4007ec: 4007f1: 4007f3: 4007f7: 4007fe: 4007ff: 400801: 400805: 400808: 40080c 40080e 400812: 400815: 400819: 40081b: 40081f 400822: 400826 40082a: 40082C 400830 400832: 400837: 40083C: 400840: 400842: 400846: 400848: 40084d 400852: 400856: 400858: 40085f: mov cmpl ja mov mov 400862 0xc (%rsp),%eax Ox400a30(.%rax, 8), %rax 48 8b 04 c5 30 0a 40 e mpg mov shr mov jmp mov shl mov jmp 400871 *%rax Oxo(%rsp ) ,%eax $0x2,%eax %eax,0x1c (%rsp ) 400871 0xc (%rsp),%eax $0x2,%eax %eax,0x1c(%rsp) 89 44 24 1c 8b 44 24 0c cl e0 02 89 44 24 1c 564 0C (%rsp), %eax 0x1 (%rax ) ,%edx %edx,0xc (%rsp ) %eax,0x1c (%rsp) lea mov mov jmp 400871 mov mov mov callg mov 8d 50 01 89 54 24 0c A5 24 0C (%rsp), %eax %eax,%edi $0x0,%eax b8 00 00 00 00 e8 3e 00 00 00 89 44 24 lc eb 247 40087a movl 400871 (%rsp), %eax %eax,%edi $0x0,%eax 4008a7 %eax,0x1c (%rsp) b8 00 00 00 00 e8 55 00 00 00 c7 44 24 1c 07 00 00 $0x7, 0x1c(%rsp ) 400860: 400862: 400866: 400868: jmp nov mov add add mov 400871 0xc (%rsp ) ,%edx %edx,%eax %eax,%eax %edx,%eax %eax,0x1c (%rsp) 8b 54 24 0c 40086a: 40086C 400870: 400871: 400875: 400879: g04 2A 0x1c(%rsp ) ,%eax mov add x28, srsp 48 83 c4 28

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago