3.58
题目中的汇编代码为:
decode2:
// rdi<=>x rsi<=>y rdx<=>z
sub %rdx,%rsi # y-=z
imulq %rsi,%rdi # x*=y
movq %rsi,%rax # rax=y
salq $63,%rax # rax<<63
sarq $63,%rax # rax>>63
xorq %rdi,%rax # rax^=x
ret
转化为C代码为:
long decode2(long x,long y,long z)
{
y-=z;
x*=y;
return x^((y<<63)>>63);
}
3.60
汇编代码为:
// long loop (long x,int n)
// x<=>rdi , n<=>esi
loop:
movl %esi, %ecx # %ecx=n;
movl $1, %edx # %edx=1; [mask=1]
movl $0, %eax # %eax=0; [result=0