Question: (50 points) Consider the following assembly code for long loop_for (long x, long n ) ;. The first argument x is in %rdi and second

(50 points) Consider the following assembly code for long loop_for (long x, long n ) ;. The first argument x is in \%rdi and second argument n is in \%rsi. The return value of loop_for is returned through \%rax. \( \begin{array}{cl}\text { loop_for: } & \\ \text { movq } & \% r \mathrm{rsi}, \% \mathrm{rcx} \\ \text { movq } & \$ 1, \% r d x \\ \text { movq } & \$ 0, \% \mathrm{rax} \\ \text { jmp } & . \text { L6 } \\ \text {.L5: } & \\ \text { movq } & \% r d i, \% r 8 \\ \text { andq } & \% r d x, \% r 8 \\ \text { orq } & \% r 8, \% r a x \\ \text { salq } & \% r c x, \% r d x \\ \text {.L6: } & \\ \text { testq } & \% r d x, \% r d x \\ \text { jne } & . \text { L5 } \\ \text { ret } & \end{array} \) Fill in the C code for loop_for that will have an effect equivalent to the assembly code shown
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
