Question

Assembly Analysis: Please write pseudocode/c code/python code or just describe what is this recursive function doing....

Assembly Analysis:

Please write pseudocode/c code/python code or just describe what is this recursive function doing.

Thank you!

 
 

Dump of assembler code for function func4:

   0x0000000000401015 <+0>: push %r12

   0x0000000000401017 <+2>: push %rbp

   0x0000000000401018 <+3>: push %rbx

   0x0000000000401019 <+4>: mov %edi,%ebx

   0x000000000040101b <+6>: test %edi,%edi

   0x000000000040101d <+8>: jle 0x401041 <func4+44>

   0x000000000040101f <+10>: mov %esi,%ebp

   0x0000000000401021 <+12>: cmp $0x1,%edi

   0x0000000000401024 <+15>: je 0x401048 <func4+51>

   0x0000000000401026 <+17>: lea -0x1(%rdi),%edi

   0x0000000000401029 <+20>: callq 0x401015 <func4>

   0x000000000040102e <+25>: lea (%rax,%rbp,1),%r12d

   0x0000000000401032 <+29>: lea -0x2(%rbx),%edi

   0x0000000000401035 <+32>: mov %ebp,%esi

   0x0000000000401037 <+34>: callq 0x401015 <func4>

   0x000000000040103c <+39>: add %r12d,%eax

   0x000000000040103f <+42>: jmp 0x40104a <func4+53>

   0x0000000000401041 <+44>: mov $0x0,%eax

   0x0000000000401046 <+49>: jmp 0x40104a <func4+53>

   0x0000000000401048 <+51>: mov %esi,%eax

   0x000000000040104a <+53>: pop %rbx

   0x000000000040104b <+54>: pop %rbp

   0x000000000040104c <+55>: pop %r12

   0x000000000040104e <+57>: retq

 
0 0
Add a comment Improve this question Transcribed image text
Answer #1
put the stack
ebi = edx
if edi is not zero
    if edi is one: then eax=ebp.
                   rearrange the stack
                   return.
    else: edi = -0x1(rbx)
          func4
          r12d = eax
          edi = -0x2(rbx)
          esi = ebp
          func4
          eax = rax+r12+ebp
          rearrange the stack and return.
else
    ebp=0
    eax=ebp
    return
Add a comment
Know the answer?
Add Answer to:
Assembly Analysis: Please write pseudocode/c code/python code or just describe what is this recursive function doing....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT