#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fac(int);
double pow(double, int);
double sin(double x) {
  double y = 0;
  x *= 3.14159265358979323846 / 180;
  for (unsigned int i = 0; i != 8; i++)
    y += pow(-1.0, i) / fac(2 * i + 1) * pow(x, 2 * i + 1);
  return y;
}


x86 assembly (clang, -O0):
<sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
je     11c7 <sin+0xa7>
mov    -0x14(%rbp),%edi
movsd  0xea5(%rip),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1030 <fac@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <sin+0x2e>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin>:
sub    $0x18,%rsp
mulsd  0xed4(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xece(%rip),%xmm0
xor    %edi,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x1,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe7f(%rip),%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x3,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe2f(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x5,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x5,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xddf(%rip),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x7,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x7,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xd8f(%rip),%xmm0
mov    $0x4,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x9,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x9,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xd3f(%rip),%xmm0
mov    $0x5,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0xb,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xb,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xcef(%rip),%xmm0
mov    $0x6,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0xd,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xd,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xc9f(%rip),%xmm0
mov    $0x7,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0xf,%edi
call   1030 <fac@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0xf,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
%5 = load double, double* %2
%6 = fmul double %5, 0x3F91DF46A2529D39
store double %6, double* %2
store i32 0, i32* %4
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 8
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %4
%12 = call double @pow(double -1.000000e+00, i32 %11)
%13 = load i32, i32* %4
%14 = mul i32 2, %13
%15 = add i32 %14, 1
%16 = call double @fac(i32 %15)
%17 = fdiv double %12, %16
%18 = load double, double* %2
%19 = load i32, i32* %4
%20 = mul i32 2, %19
%21 = add i32 %20, 1
%22 = call double @pow(double %18, i32 %21)
%23 = load double, double* %3
%24 = call double @llvm.fmuladd.f64(double %17, double %22, double %23)
store double %24, double* %3
br label %25
25: ; preds = %10
%26 = load i32, i32* %4
%27 = add i32 %26, 1
store i32 %27, i32* %4
br label %7
28: ; preds = %7
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
define double @sin(double %0) {
%2 = fmul double %0, 0x3F91DF46A2529D39
%3 = tail call double @pow(double -1.000000e+00, i32 0)
%4 = tail call double @fac(i32 1)
%5 = fdiv double %3, %4
%6 = tail call double @pow(double %2, i32 1)
%7 = tail call double @llvm.fmuladd.f64(double %5, double %6, double 0.000000e+00)
%8 = tail call double @pow(double -1.000000e+00, i32 1)
%9 = tail call double @fac(i32 3)
%10 = fdiv double %8, %9
%11 = tail call double @pow(double %2, i32 3)
%12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %7)
%13 = tail call double @pow(double -1.000000e+00, i32 2)
%14 = tail call double @fac(i32 5)
%15 = fdiv double %13, %14
%16 = tail call double @pow(double %2, i32 5)
%17 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %12)
%18 = tail call double @pow(double -1.000000e+00, i32 3)
%19 = tail call double @fac(i32 7)
%20 = fdiv double %18, %19
%21 = tail call double @pow(double %2, i32 7)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %17)
%23 = tail call double @pow(double -1.000000e+00, i32 4)
%24 = tail call double @fac(i32 9)
%25 = fdiv double %23, %24
%26 = tail call double @pow(double %2, i32 9)
%27 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %22)
%28 = tail call double @pow(double -1.000000e+00, i32 5)
%29 = tail call double @fac(i32 11)
%30 = fdiv double %28, %29
%31 = tail call double @pow(double %2, i32 11)
%32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %27)
%33 = tail call double @pow(double -1.000000e+00, i32 6)
%34 = tail call double @fac(i32 13)
%35 = fdiv double %33, %34
%36 = tail call double @pow(double %2, i32 13)
%37 = tail call double @llvm.fmuladd.f64(double %35, double %36, double %32)
%38 = tail call double @pow(double -1.000000e+00, i32 7)
%39 = tail call double @fac(i32 15)
%40 = fdiv double %38, %39
%41 = tail call double @pow(double %2, i32 15)
%42 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %37)
ret double %42
}