Created
January 16, 2015 04:03
-
-
Save angch/c225008c04706528be80 to your computer and use it in GitHub Desktop.
noloop.c tail recursion elimination (see line 79)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.section __TEXT,__text,regular,pure_instructions | |
.globl _doScore | |
.align 4, 0x90 | |
_doScore: ## @doScore | |
.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 %r13 | |
pushq %r12 | |
pushq %rbx | |
pushq %rax | |
Ltmp6: | |
.cfi_offset %rbx, -56 | |
Ltmp7: | |
.cfi_offset %r12, -48 | |
Ltmp8: | |
.cfi_offset %r13, -40 | |
Ltmp9: | |
.cfi_offset %r14, -32 | |
Ltmp10: | |
.cfi_offset %r15, -24 | |
movq %rdx, %r14 | |
movl %esi, %ebx | |
movq %rdi, %r15 | |
leaq L_.str(%rip), %rdi | |
xorl %eax, %eax | |
callq _printf | |
movq ___stdinp@GOTPCREL(%rip), %r12 | |
movq (%r12), %rdx | |
movl $50, %esi | |
movq %r14, %rdi | |
callq _fgets | |
testq %rax, %rax | |
je LBB0_6 | |
## BB#1: | |
leaq L_.str2(%rip), %r13 | |
.align 4, 0x90 | |
LBB0_3: ## %.lr.ph | |
## =>This Inner Loop Header: Depth=1 | |
movl 52(%r14), %r8d | |
xorl %eax, %eax | |
movq %r15, %rdi | |
leaq L_.str1(%rip), %rsi | |
movl %ebx, %edx | |
movq %r14, %rcx | |
callq _fprintf | |
testl %eax, %eax | |
je LBB0_6 | |
## BB#4: ## in Loop: Header=BB0_3 Depth=1 | |
xorl %eax, %eax | |
movq %r15, %rdi | |
movq %r13, %rsi | |
callq _fprintf | |
testl %eax, %eax | |
je LBB0_6 | |
## BB#5: ## in Loop: Header=BB0_3 Depth=1 | |
cmpl $2147483647, %ebx ## imm = 0x7FFFFFFF | |
je LBB0_6 | |
## BB#2: ## %tailrecurse | |
## in Loop: Header=BB0_3 Depth=1 | |
incl %ebx | |
xorl %eax, %eax | |
leaq L_.str(%rip), %rdi | |
callq _printf | |
movq (%r12), %rdx | |
movl $50, %esi | |
movq %r14, %rdi | |
callq _fgets | |
testq %rax, %rax | |
jne LBB0_3 | |
LBB0_6: ## %split | |
addq $8, %rsp | |
popq %rbx | |
popq %r12 | |
popq %r13 | |
popq %r14 | |
popq %r15 | |
popq %rbp | |
retq | |
.cfi_endproc | |
.globl _main | |
.align 4, 0x90 | |
_main: ## @main | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp14: | |
.cfi_def_cfa_offset 16 | |
Ltmp15: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp16: | |
.cfi_def_cfa_register %rbp | |
pushq %r14 | |
pushq %rbx | |
subq $64, %rsp | |
Ltmp17: | |
.cfi_offset %rbx, -32 | |
Ltmp18: | |
.cfi_offset %r14, -24 | |
movq ___stack_chk_guard@GOTPCREL(%rip), %r14 | |
movq (%r14), %rax | |
movq %rax, -24(%rbp) | |
movl $20, -28(%rbp) | |
leaq L_.str3(%rip), %rdi | |
leaq L_.str4(%rip), %rsi | |
callq _fopen | |
movq %rax, %rbx | |
testq %rbx, %rbx | |
je LBB1_1 | |
## BB#2: | |
leaq -80(%rbp), %rdx | |
movl $1, %esi | |
movq %rbx, %rdi | |
callq _doScore | |
movq %rbx, %rdi | |
callq _fclose | |
xorl %eax, %eax | |
jmp LBB1_3 | |
LBB1_1: | |
movq ___stderrp@GOTPCREL(%rip), %rax | |
movq (%rax), %rcx | |
leaq L_.str5(%rip), %rdi | |
movl $60, %esi | |
movl $1, %edx | |
callq _fwrite | |
movl $-1, %eax | |
LBB1_3: | |
movq (%r14), %rcx | |
cmpq -24(%rbp), %rcx | |
jne LBB1_5 | |
## BB#4: | |
addq $64, %rsp | |
popq %rbx | |
popq %r14 | |
popq %rbp | |
retq | |
LBB1_5: | |
callq ___stack_chk_fail | |
.cfi_endproc | |
.section __TEXT,__cstring,cstring_literals | |
L_.str: ## @.str | |
.asciz "Enter you[sic] name: " | |
L_.str1: ## @.str1 | |
.asciz "%d) Name:%s Score:%d\n" | |
L_.str2: ## @.str2 | |
.asciz "_________________\n\n" | |
L_.str3: ## @.str3 | |
.asciz "result.txt" | |
L_.str4: ## @.str4 | |
.asciz "a+" | |
L_.str5: ## @.str5 | |
.asciz "Don't lar try to write to stuff you have no permission for.\n" | |
.subsections_via_symbols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment