Last active
December 26, 2015 11:39
-
-
Save DanGe42/7144994 to your computer and use it in GitHub Desktop.
This file contains 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 | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI0_0: | |
.quad -4609434218613702656 ## double -3 | |
LCPI0_1: | |
.quad 4616189618054758400 ## double 4 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _poly1a | |
.align 4, 0x90 | |
_poly1a: ## @poly1a | |
.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 | |
movsd LCPI0_0(%rip), %xmm1 | |
mulsd %xmm0, %xmm1 | |
mulsd %xmm0, %xmm0 | |
addsd %xmm1, %xmm0 | |
addsd LCPI0_1(%rip), %xmm0 | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI1_0: | |
.quad -4609434218613702656 ## double -3 | |
LCPI1_1: | |
.quad 4616189618054758400 ## double 4 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _poly1b | |
.align 4, 0x90 | |
_poly1b: ## @poly1b | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp7: | |
.cfi_def_cfa_offset 16 | |
Ltmp8: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp9: | |
.cfi_def_cfa_register %rbp | |
movsd LCPI1_0(%rip), %xmm1 | |
mulsd %xmm0, %xmm1 | |
mulsd %xmm0, %xmm0 | |
addsd %xmm1, %xmm0 | |
addsd LCPI1_1(%rip), %xmm0 | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI2_0: | |
.quad -4609434218613702656 ## double -3 | |
LCPI2_1: | |
.quad 4616189618054758400 ## double 4 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _poly2 | |
.align 4, 0x90 | |
_poly2: ## @poly2 | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp12: | |
.cfi_def_cfa_offset 16 | |
Ltmp13: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp14: | |
.cfi_def_cfa_register %rbp | |
movaps %xmm0, %xmm1 | |
movsd LCPI2_0(%rip), %xmm0 | |
addsd %xmm1, %xmm0 | |
mulsd %xmm1, %xmm0 | |
addsd LCPI2_1(%rip), %xmm0 | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI3_0: | |
.quad 4613937818241073152 ## double 3 | |
LCPI3_1: | |
.quad 4616189618054758400 ## double 4 | |
LCPI3_2: | |
.quad -4609434218613702656 ## double -3 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _main | |
.align 4, 0x90 | |
_main: ## @main | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp18: | |
.cfi_def_cfa_offset 16 | |
Ltmp19: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp20: | |
.cfi_def_cfa_register %rbp | |
pushq %rbx | |
pushq %rax | |
Ltmp21: | |
.cfi_offset %rbx, -24 | |
movq 8(%rsi), %rdi | |
leaq L_.str(%rip), %rsi | |
leaq -16(%rbp), %rdx | |
xorb %al, %al | |
callq _sscanf | |
movsd -16(%rbp), %xmm0 | |
movaps %xmm0, %xmm1 | |
mulsd LCPI3_0(%rip), %xmm1 | |
mulsd %xmm0, %xmm0 | |
subsd %xmm1, %xmm0 | |
addsd LCPI3_1(%rip), %xmm0 | |
leaq L_.str1(%rip), %rbx | |
movq %rbx, %rdi | |
movb $1, %al | |
callq _printf | |
movsd -16(%rbp), %xmm0 | |
movsd LCPI3_0(%rip), %xmm1 | |
mulsd %xmm0, %xmm1 | |
mulsd %xmm0, %xmm0 | |
subsd %xmm1, %xmm0 | |
addsd LCPI3_1(%rip), %xmm0 | |
movq %rbx, %rdi | |
movb $1, %al | |
callq _printf | |
movsd -16(%rbp), %xmm1 | |
movsd LCPI3_2(%rip), %xmm0 | |
addsd %xmm1, %xmm0 | |
mulsd %xmm1, %xmm0 | |
addsd LCPI3_1(%rip), %xmm0 | |
movq %rbx, %rdi | |
movb $1, %al | |
callq _printf | |
xorl %eax, %eax | |
addq $8, %rsp | |
popq %rbx | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__cstring,cstring_literals | |
L_.str: ## @.str | |
.asciz "%lf" | |
L_.str1: ## @.str1 | |
.asciz "%lf\n" | |
.subsections_via_symbols |
This file contains 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
#include <stdio.h> | |
#include <math.h> | |
double poly1a(double x) { | |
return x*x - 3*x + 4; | |
} | |
double poly1b(double x) { | |
return pow(x, 2.0) - 3*x + 4; | |
} | |
double poly2(double x) { | |
return x*(x - 3) + 4; | |
} | |
int main(int argc, char** argv) { | |
double d; | |
sscanf(argv[1], "%lf", &d); | |
printf("%lf\n", poly1a(d)); | |
printf("%lf\n", poly1b(d)); | |
printf("%lf\n", poly2(d)); | |
return 0; | |
} |
This file contains 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 _poly1a | |
.align 4, 0x90 | |
_poly1a: ## @poly1a | |
.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 | |
movabsq $4, %rax | |
cvtsi2sdq %rax, %xmm1 | |
movabsq $3, %rax | |
cvtsi2sdq %rax, %xmm2 | |
movsd %xmm0, -8(%rbp) | |
movsd -8(%rbp), %xmm0 | |
mulsd -8(%rbp), %xmm0 | |
mulsd -8(%rbp), %xmm2 | |
subsd %xmm2, %xmm0 | |
addsd %xmm1, %xmm0 | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI1_0: | |
.quad 4611686018427387904 ## double 2 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _poly1b | |
.align 4, 0x90 | |
_poly1b: ## @poly1b | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp7: | |
.cfi_def_cfa_offset 16 | |
Ltmp8: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp9: | |
.cfi_def_cfa_register %rbp | |
subq $16, %rsp | |
movsd %xmm0, -8(%rbp) | |
movsd -8(%rbp), %xmm0 | |
movsd LCPI1_0(%rip), %xmm1 | |
callq _pow | |
movabsq $4, %rax | |
cvtsi2sdq %rax, %xmm1 | |
movabsq $3, %rax | |
cvtsi2sdq %rax, %xmm2 | |
mulsd -8(%rbp), %xmm2 | |
subsd %xmm2, %xmm0 | |
addsd %xmm1, %xmm0 | |
addq $16, %rsp | |
popq %rbp | |
ret | |
.cfi_endproc | |
.globl _poly2 | |
.align 4, 0x90 | |
_poly2: ## @poly2 | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp12: | |
.cfi_def_cfa_offset 16 | |
Ltmp13: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp14: | |
.cfi_def_cfa_register %rbp | |
movabsq $4, %rax | |
cvtsi2sdq %rax, %xmm1 | |
movabsq $3, %rax | |
cvtsi2sdq %rax, %xmm2 | |
movsd %xmm0, -8(%rbp) | |
movsd -8(%rbp), %xmm0 | |
movsd -8(%rbp), %xmm3 | |
subsd %xmm2, %xmm3 | |
mulsd %xmm3, %xmm0 | |
addsd %xmm1, %xmm0 | |
popq %rbp | |
ret | |
.cfi_endproc | |
.globl _main | |
.align 4, 0x90 | |
_main: ## @main | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp17: | |
.cfi_def_cfa_offset 16 | |
Ltmp18: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp19: | |
.cfi_def_cfa_register %rbp | |
subq $48, %rsp | |
leaq L_.str(%rip), %rax | |
leaq -24(%rbp), %rdx | |
movl $0, -4(%rbp) | |
movl %edi, -8(%rbp) | |
movq %rsi, -16(%rbp) | |
movq -16(%rbp), %rsi | |
movq 8(%rsi), %rdi | |
movq %rax, %rsi | |
movb $0, %al | |
callq _sscanf | |
movsd -24(%rbp), %xmm0 | |
movl %eax, -28(%rbp) ## 4-byte Spill | |
callq _poly1a | |
leaq L_.str1(%rip), %rdi | |
movb $1, %al | |
callq _printf | |
movsd -24(%rbp), %xmm0 | |
movl %eax, -32(%rbp) ## 4-byte Spill | |
callq _poly1b | |
leaq L_.str1(%rip), %rdi | |
movb $1, %al | |
callq _printf | |
movsd -24(%rbp), %xmm0 | |
movl %eax, -36(%rbp) ## 4-byte Spill | |
callq _poly2 | |
leaq L_.str1(%rip), %rdi | |
movb $1, %al | |
callq _printf | |
movl $0, %ecx | |
movl %eax, -40(%rbp) ## 4-byte Spill | |
movl %ecx, %eax | |
addq $48, %rsp | |
popq %rbp | |
ret | |
.cfi_endproc | |
.section __TEXT,__cstring,cstring_literals | |
L_.str: ## @.str | |
.asciz "%lf" | |
L_.str1: ## @.str1 | |
.asciz "%lf\n" | |
.subsections_via_symbols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment