Question: User Assembly code: # void switcher ( long a , long b , long c , long * dest ) # a in % rsi,

User
Assembly code:
# void switcher(long a, long b, long c, long *dest)
# a in %rsi, b in %rdi, c in %rdx, d in %rcx
switcher:
cmpq $8,%rdi
ja .L2
jmp *.L4(,%rdi,8)
.L7:
divq %rdi, %rsi
movq %rsi, %rdx
.L3:
leaq 10(,%rdx,2),%rdx
jmp .L6
.L5:
leaq (%rdx,%rsi),%rdx
salq $4,%rdx
jmp .L6
.L2:
movq %rsi, %rdx
.L6:
movq %rdx,(%rcx)
ret
Jump table:
.L4:
.quad .L3
.quad .L2
.quad .L5
.quad .L2
.quad .L7
.quad .L6
.quad .L2
.quad .L5
.quad .L6
Please complete the following C code based on the above assembly code.
void switcher(long a, long b, long c, long *dest){
switch ( Blank 1 Question 14){
case Blank 2 Question 14 :
c = a;
*dest = Blank 3 Question 14 ;
break;
case 1:
case 3:
case Blank 4 Question 14 :
Blank 5 Question 14 ;
break;
case 2: // Jumps to .L5
case Blank 6 Question 14 :
*dest = Blank 7 Question 14 ;
break;
case 4:
c = Blank 8 Question 14 ;
// Fall through
case 5:
case Blank 9 Question 14 :
*dest = Blank 10 Question 14 ; // movq %rdx,(%rcx)
break;
default:
*dest = Blank 11 Question 14 ;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!