Arithmetic and Logic Operations

The following problem was taken from Computer Systems: A Programmer’s Perspective, Third Edition; Bryant, O’Hallaron.

Exercise

Consider the following assembly code for arith2().

arith2:
    orq     %rsi, %rdi
    sarq    $3, %rdi
    notq    %rdi
    movq    %rdx, %rax
    subq    %rdi, %rax
ret

Write the C code for arith2() that would produce the assembly code given above.

long arith2(long x, long y, long z) {
    long t1 =  _____________________________;
    long t2 =  _____________________________;
    long t3 =  _____________________________;
    long t4 =  _____________________________;
    return t4;
}