Question: #include #include / * compute x * y with addition * / uint 6 4 _ t recmul ( uint 6 4 _ t a
#include
#include
compute xy with addition
uintt recmuluintt auintt b
if a b
return ;
else if a
return b;
else
return b recmulab;
compute x to the yth power using only addition
uintt recexpuintt xuintt y
if y
return ;
else if y
return x;
else
return recmulxrecexpxy;
int main
printfrecexp returned lu
recexp;
return ;
Using the disassemble command under gdb examine the first five instructions of
recmul ignoring the endbr instruction
a Compare these instructions to the first five instructions of recexp. What do you notice?
b What are these instructions doing? Hint: recall that the parameters to each function are
passed in registers rdi and rsi.
c Why does the compiler generate this code? Hint: look at the instructions before the recursive
call in each function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
