// Conversion of C code to assembly by gcc

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


/*** assembly styles ***/
// gcc 39_gnu_assembly.c -S -masm=intel
/*
	.file	"gcc_assembly.c"
	.intel_syntax noprefix
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	mov	DWORD PTR -4[rbp], 2
	mov	DWORD PTR -12[rbp], 5
	mov	DWORD PTR -8[rbp], 1
	jmp	.L2
.L3:
	mov	eax, DWORD PTR -8[rbp]
	imul	eax, DWORD PTR -4[rbp]
	mov	DWORD PTR -8[rbp], eax
	sub	DWORD PTR -12[rbp], 1
.L2:
	cmp	DWORD PTR -12[rbp], 0
	jg	.L3
	mov	eax, DWORD PTR -8[rbp]
	pop	rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0"
	.section	.note.GNU-stack,"",@progbits
*/

// a short, definitely necessary version
/*
	.intel_syntax noprefix
	.globl	main
main:	push	rbp
	mov	rbp, rsp
	mov	DWORD PTR -4[rbp], 2
	mov	DWORD PTR -12[rbp], 5
	mov	DWORD PTR -8[rbp], 1
	jmp	.L2
.L3:	mov	eax, DWORD PTR -8[rbp]
	imul	eax, DWORD PTR -4[rbp]
	mov	DWORD PTR -8[rbp], eax
	sub	DWORD PTR -12[rbp], 1
.L2:	cmp	DWORD PTR -12[rbp], 0
	jg	.L3
	mov	eax, DWORD PTR -8[rbp]
	pop	rbp
	ret
*/
