Skip to content

Instantly share code, notes, and snippets.

@chibiegg
Created December 11, 2014 17:28
Show Gist options
  • Save chibiegg/7c787646c0deb5ae4b29 to your computer and use it in GitHub Desktop.
Save chibiegg/7c787646c0deb5ae4b29 to your computer and use it in GitHub Desktop.
最適化3
int main(){
int i = 0;
int n = rand();
while(i++<n){
printf("%d",i);
}
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp3:
.cfi_def_cfa_offset 16
Ltmp4:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp5:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
Ltmp6:
.cfi_offset %rbx, -40
Ltmp7:
.cfi_offset %r14, -32
Ltmp8:
.cfi_offset %r15, -24
xorl %ebx, %ebx
xorl %eax, %eax
callq _rand
movl %eax, %r14d
testl %r14d, %r14d
jle LBB0_3
## BB#1:
leaq L_.str(%rip), %r15
.align 4, 0x90
LBB0_2: ## %.lr.ph
## =>This Inner Loop Header: Depth=1
incl %ebx
xorl %eax, %eax
movq %r15, %rdi
movl %ebx, %esi
callq _printf
cmpl %ebx, %r14d
jne LBB0_2
LBB0_3: ## %._crit_edge
xorl %eax, %eax
addq $8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "%d"
.subsections_via_symbols
int main(){
int i;
int n = rand();
for(i=0;i<n;i++){
printf("%d",i);
}
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp3:
.cfi_def_cfa_offset 16
Ltmp4:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp5:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
Ltmp6:
.cfi_offset %rbx, -40
Ltmp7:
.cfi_offset %r14, -32
Ltmp8:
.cfi_offset %r15, -24
xorl %ebx, %ebx
xorl %eax, %eax
callq _rand
movl %eax, %r14d
testl %r14d, %r14d
jle LBB0_3
## BB#1:
leaq L_.str(%rip), %r15
.align 4, 0x90
LBB0_2: ## %.lr.ph
## =>This Inner Loop Header: Depth=1
xorl %eax, %eax
movq %r15, %rdi
movl %ebx, %esi
callq _printf
incl %ebx
cmpl %ebx, %r14d
jne LBB0_2
LBB0_3: ## %._crit_edge
xorl %eax, %eax
addq $8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "%d"
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment