So I was doing the following problem, making the assembly code to C(still kind of new to assembly code) Suppose you know that when a function with prototype long decode4(long x, long y, long z) is compiled into assembly code, the body of the code is as follows
addq %rsi, %rdi
imulq %rdx, %rdi
movq %rdi, %rax
sarq $15, %rax
salq $31, %rax
andq %rdi, %rax
ret
Parameters x, y, and z are passed in registers %rdi, %rsi, and %rdx. The code stores the return value in register %rax.
How I interpreted the code was with the following:
long w =(x+y)*z;
w=(w>>15);
w=(<<31);
return x&w;
please review my code, and please be nice!
