// Disassembly: conversion of binary executable to assembly (and machine code text)

int main(){
  int b=2, e=5, p=1;
  while(e>0){
    p=p*b;
    e=e-1;
    }
  return p;
  }


/*** assembly style ***/
// gcc 40_disassembly.c -S -masm=intel
/*
	.intel_syntax noprefix
	.globl	main
main:	push	rbp
	mov	rbp, rsp
	mov	DWORD PTR [rbp- 4], 2
	mov	DWORD PTR [rbp-12], 5
	mov	DWORD PTR [rbp- 8], 1
	jmp	.L2
.L3:	mov	eax, DWORD PTR [rbp-8]
	imul	eax, DWORD PTR [rbp-4]
	mov	DWORD PTR [rbp-8], eax
	sub	DWORD PTR [rbp-12], 1
.L2:	cmp	DWORD PTR [rbp-12], 0
	jg	.L3
	mov	eax, DWORD PTR [rbp-8]
	pop	rbp
	ret
*/

// gcc 40_disassembly.c -o execute
// objdump execute -d -M intel
/*
00000000000005fa <main>:
 5fa:	55                   	push   rbp
 5fb:	48 89 e5             	mov    rbp,rsp
 5fe:	c7 45 fc 02 00 00 00 	mov    DWORD PTR [rbp-0x4],0x2
 605:	c7 45 f4 05 00 00 00 	mov    DWORD PTR [rbp-0xc],0x5
 60c:	c7 45 f8 01 00 00 00 	mov    DWORD PTR [rbp-0x8],0x1
 613:	eb 0e                	jmp    623	#<rip+0x0e>
 615:	8b 45 f8             	mov    eax,DWORD PTR [rbp-0x8]
 618:	0f af 45 fc          	imul   eax,DWORD PTR [rbp-0x4]
 61c:	89 45 f8             	mov    DWORD PTR [rbp-0x8],eax
 61f:	83 6d f4 01          	sub    DWORD PTR [rbp-0xc],0x1
 623:	83 7d f4 00          	cmp    DWORD PTR [rbp-0xc],0x0
 627:	7f ec                	jg     615	#<rip+0xec>=<rip-0x14>
 629:	8b 45 f8             	mov    eax,DWORD PTR [rbp-0x8]
 62c:	5d                   	pop    rbp
 62d:	c3                   	ret
 62e:	66 90                	xchg   ax,ax	#nop
*/
