Question: Convert these x86-64 assembly language functions into C Code. There are 5 total functions. Rather than writing assembly language programs, your task in this assignment

Convert these x86-64 assembly language functions into C Code. There are 5 total functions. Rather than writing assembly language programs, your task in this assignment is to reverse engineer x86-64 code into C. Specifically, you will find 5 functions which are provided below, and your job is to write 5 equivalent functions in C.

f1: subl $97, %edi xorl %eax, %eax cmpb $25, %dil setbe %al ret

f2: cmpl %edx, %edi sete %dl xorl %eax, %eax cmpl %esi, %edi sete %al andl %edx, %eax ret

f3: cmpl $1, %edi jle .L6 movl $2, %edx movl $1, %eax jmp .L5 .L8: movl %ecx, %edx .L5: imull %edx, %eax leal 1(%rdx), %ecx cmpl %eax, %edi jg .L8 .L4: cmpl %edi, %eax sete %al movzbl %al, %eax ret .L6: movl $1, %eax jmp .L4

f4: pushq %r12 movq %rdi, %r12 pushq %rbp movq %r12, %rbp pushq %rbx leaq 1(%r12), %rbx call puts movsbl (%r12), %edx testb %dl, %dl je .L15 .L17: xorl %eax, %eax movl $122, %ecx movl $97, %esi movl $.LC0, %edi call printf movzbl 0(%rbp), %edx leal -97(%rdx), %eax cmpb $25, %al ja .L11 subl $32, %edx movb %dl, 0(%rbp) .L11: movq %rbx, %rbp addq $1, %rbx movsbl -1(%rbx), %edx testb %dl, %dl jne .L17 .L15: popq %rbx popq %rbp movq %r12, %rax popq %r12 ret

f5: cmpb $0, (%rdi) movq %rdi, %rax movq %rdi, %rdx je .L32 .L22: addq $1, %rdx cmpb $0, (%rdx) jne .L22 movzbl (%rsi), %ecx testb %cl, %cl je .L33 .L24: movb %cl, (%rdx) addq $1, %rsi addq $1, %rdx .L32: movzbl (%rsi), %ecx testb %cl, %cl jne .L24 .L33: movb $0, (%rdx) ret

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!