'salq and sarq in x86-64 Assembly Language

I am learning x86-64 assembly language with a textbook, and I am having difficulty understanding what specific lines of the code do.

the function in C that have the prototype

long doSth(long x, long y, long z):

and GCC generates the following assembly code;

#x->%rdi, y->%rsi, z->%rdx.

doSth:
subq    %rdx, %rsi
imulq   %rsi, %rdi
movq    %rsi, %rax
salq    $63, %rax
sarq    $63, %rax
xorq    %rdi, %rax
ret

I want to figire out how I would write C code that have an equivalent effect to the assembly code.

what I dont understand is that salq and sarq lines.

salq left shifts %rax by 63, but then in the next line sarq right shifts %rax by 63 back again.

So what is this doing in here? is it basically same as nothing happended?

How can I interpret these line so that I can write C code for these lines?

Thank you !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source