Created
December 4, 2010 17:00
-
-
Save pervognsen/728323 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
// chebyshev.cpp | |
#include <stdio.h> | |
#include <math.h> | |
static float chebyshev(int n, float x) | |
{ | |
float a = 1.0f, b = x; | |
x += x; | |
while (n--) { | |
float t = b; | |
b = x * b - a; | |
a = t; | |
} | |
return a; | |
} | |
int main() | |
{ | |
char line[80]; | |
gets(line); | |
float x = float(atof(line)); | |
float r = chebyshev(10, x); | |
printf("%f\n", r); | |
return 0; | |
} | |
// chebyshev.s (generated by clang++ chebyshev.cpp -O3 -march=native -S) | |
.def _main; | |
.scl 2; | |
.type 32; | |
.endef | |
.section .rdata,"r" | |
.align 4 | |
LCPI0_0: # constant pool float | |
.long 3212836864 # float -1.000000e+000 | |
.text | |
.globl _main | |
.align 16, 0x90 | |
_main: # @main | |
# BB#0: | |
pushl %ebp | |
movl %esp, %ebp | |
pushl %esi | |
subl $100, %esp | |
leal -84(%ebp), %esi | |
movl %esi, (%esp) | |
calll _gets | |
movl %esi, (%esp) | |
calll _atof | |
fstps -88(%ebp) | |
movss -88(%ebp), %xmm0 | |
movaps %xmm0, %xmm1 | |
addss %xmm1, %xmm1 | |
movaps %xmm1, %xmm2 | |
mulss %xmm0, %xmm2 | |
addss LCPI0_0, %xmm2 | |
movaps %xmm1, %xmm3 | |
mulss %xmm2, %xmm3 | |
subss %xmm0, %xmm3 | |
movaps %xmm1, %xmm0 | |
mulss %xmm3, %xmm0 | |
subss %xmm2, %xmm0 | |
movaps %xmm1, %xmm2 | |
mulss %xmm0, %xmm2 | |
subss %xmm3, %xmm2 | |
movaps %xmm1, %xmm3 | |
mulss %xmm2, %xmm3 | |
subss %xmm0, %xmm3 | |
movaps %xmm1, %xmm0 | |
mulss %xmm3, %xmm0 | |
subss %xmm2, %xmm0 | |
movaps %xmm1, %xmm2 | |
mulss %xmm0, %xmm2 | |
subss %xmm3, %xmm2 | |
movaps %xmm1, %xmm3 | |
mulss %xmm2, %xmm3 | |
subss %xmm0, %xmm3 | |
mulss %xmm1, %xmm3 | |
subss %xmm2, %xmm3 | |
cvtss2sd %xmm3, %xmm0 | |
movsd %xmm0, 4(%esp) | |
movl $L_.str, (%esp) | |
calll _printf | |
xorl %eax, %eax | |
addl $100, %esp | |
popl %esi | |
popl %ebp | |
ret | |
.data | |
L_.str: # @.str | |
.asciz "%f\n" | |
.globl __fltused |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment