Skip to content

Instantly share code, notes, and snippets.

@chibiegg
Created December 11, 2014 17:23
Show Gist options
  • Save chibiegg/1a828c1bd07e3b39a994 to your computer and use it in GitHub Desktop.
Save chibiegg/1a828c1bd07e3b39a994 to your computer and use it in GitHub Desktop.
最適化0
int main(){
int i = 0;
while(i++<10){
}
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
movl $0, -4(%rbp)
movl $0, -8(%rbp)
LBB0_1: ## =>This Inner Loop Header: Depth=1
movl -8(%rbp), %eax
movl %eax, %ecx ## 今の値をeaxに取っておく
addl $1, %ecx
movl %ecx, -8(%rbp)
cmpl $10, %eax ## インクリメントする前の値で比較
jge LBB0_3
## BB#2: ## in Loop: Header=BB0_1 Depth=1
jmp LBB0_1
LBB0_3:
movl $0, %eax
popq %rbp
retq
.cfi_endproc
.subsections_via_symbols
int main(){
int i;
for(i=0;i<10;i++){
}
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
movl $0, -4(%rbp)
movl $0, -8(%rbp)
LBB0_1: ## =>This Inner Loop Header: Depth=1
cmpl $10, -8(%rbp) ## 先に比較する
jge LBB0_4
## BB#2: ## in Loop: Header=BB0_1 Depth=1
jmp LBB0_3
LBB0_3: ## in Loop: Header=BB0_1 Depth=1
movl -8(%rbp), %eax
addl $1, %eax ## あとでインクリメント
movl %eax, -8(%rbp)
jmp LBB0_1
LBB0_4:
movl $0, %eax
popq %rbp
retq
.cfi_endproc
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment