Question: Reading x86 Assembly Code in C (it says python in the picture below, but it should be C) Related code: https://pastebin.com/CZ1dqBMW Also here: //mystery.s .file

Reading x86 Assembly Code in C (it says python in the picture below, but it should be C)

Reading x86 Assembly Code in C (it says python in the picture

Related code:

https://pastebin.com/CZ1dqBMW

Also here:

//mystery.s

 .file "mystery.c" .comm num,1600,32 .text .globl add .type add, @function add: .LFB2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movq %rdi, -8(%rbp) movq %rsi, -16(%rbp) movq -16(%rbp), %rax movq -8(%rbp), %rdx addq %rdx, %rax popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE2: .size add, .-add .globl dothething .type dothething, @function dothething: .LFB3: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 pushq %rbx subq $40, %rsp .cfi_offset 3, -24 movq %rdi, -40(%rbp) movq -40(%rbp), %rax movq num(,%rax,8), %rax cmpq $-1, %rax je .L4 movq -40(%rbp), %rax movq num(,%rax,8), %rax jmp .L5 .L4: movq $-1, -24(%rbp) cmpq $0, -40(%rbp) jne .L6 movq $0, -24(%rbp) jmp .L7 .L6: cmpq $1, -40(%rbp) jne .L8 movq $1, -24(%rbp) jmp .L7 .L8: movq -40(%rbp), %rax subq $2, %rax movq %rax, %rdi call dothething movq %rax, %rbx movq -40(%rbp), %rax subq $1, %rax movq %rax, %rdi call dothething movq %rbx, %rsi movq %rax, %rdi call add movq %rax, -24(%rbp) .L7: movq -40(%rbp), %rax movq num(,%rax,8), %rax cmpq $-1, %rax jne .L9 movq -40(%rbp), %rax movq -24(%rbp), %rdx movq %rdx, num(,%rax,8) .L9: movq -40(%rbp), %rax movq num(,%rax,8), %rax .L5: addq $40, %rsp popq %rbx popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE3: .size dothething, .-dothething .section .rodata .LC0: .string "Value: %d " .text .globl main .type main, @function main: .LFB4: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movl %edi, -20(%rbp) movq %rsi, -32(%rbp) movq -32(%rbp), %rax addq $8, %rax movq (%rax), %rax movq %rax, %rdi call atoi movl %eax, -8(%rbp) movl $0, -4(%rbp) jmp .L11 .L12: movl -4(%rbp), %eax cltq movq $-1, num(,%rax,8) addl $1, -4(%rbp) .L11: cmpl $199, -4(%rbp) jle .L12 movl -8(%rbp), %eax cltq movq %rax, %rdi call dothething movq %rax, %rsi movl $.LC0, %edi movl $0, %eax call printf movl $0, %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE4: .size main, .-main .ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-4)" .section .note.GNU-stack,"",@progbits

In this part, you are asked to decipher the Assembly Language program in the attached mystery.s file. Specifically, you need to provide a concise description of what the program does and how it does it. You should also implement a Python program mystery that performs the same task in the same manner that the code in the attached file mystery.s does. The provided program takes a single integer as input. $ gcc -m32 -o mystery mystery.s $ /mystery 41 Value: 165580141 Hint: This program performs a wel known and easily recognizable computation. However, it includes an optimization to speedup the computation. You need to figure out both the basic functionality as well as the optimization, describe them, and replicate them in your Python code. In this part, you are asked to decipher the Assembly Language program in the attached mystery.s file. Specifically, you need to provide a concise description of what the program does and how it does it. You should also implement a Python program mystery that performs the same task in the same manner that the code in the attached file mystery.s does. The provided program takes a single integer as input. $ gcc -m32 -o mystery mystery.s $ /mystery 41 Value: 165580141 Hint: This program performs a wel known and easily recognizable computation. However, it includes an optimization to speedup the computation. You need to figure out both the basic functionality as well as the optimization, describe them, and replicate them in your Python code

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!