#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 */
int floor(double);
double sin(double x) {
  double sign;
  double x2, x3, x5, x7, x9, x11, x13;
  sign = 1.0;
  x = x - floor(x / (2 * 3.1415926535897932384626433832795)) * 2 *
              3.1415926535897932384626433832795;
  if (x > 3.1415926535897932384626433832795) {
    x = x - 3.1415926535897932384626433832795;
    sign = -1;
  }
  if (x > 1.5707963267948966192313216916398) {
    x = 3.1415926535897932384626433832795 - x;
  }
  x2 = x * x;
  x3 = x * x2;
  x5 = x3 * x2;
  x7 = x5 * x2;
  x9 = x7 * x2;
  x11 = x9 * x2;
  x13 = x11 * x2;
  return sign * (x - x3 / 6 + x5 / 120 - x7 / 5040 + x9 / 362880 -
                 x11 / 39916800 + x13 / 6227020800);
}


x86 assembly (clang, -O0):
<sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  -0x50(%rbp),%xmm1
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe8b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11bc <sin+0xac>
movsd  -0x8(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e5 <sin+0xd5>
movsd  0xe25(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xdeb(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xdce(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  0xdb1(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  0xd94(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  0xd77(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  0xd5a(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin>:
push   %rax
movsd  %xmm0,(%rsp)
divsd  0xee2(%rip),%xmm0
call   1030 <floor@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xed4(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
movsd  0xecb(%rip),%xmm2
ucomisd %xmm2,%xmm0
addsd  %xmm0,%xmm1
movapd %xmm2,%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
subsd  %xmm3,%xmm2
movsd  0xeaa(%rip),%xmm4
cmpltsd %xmm3,%xmm4
andpd  %xmm4,%xmm2
andnpd %xmm3,%xmm4
orpd   %xmm2,%xmm4
movapd %xmm4,%xmm3
mulsd  %xmm4,%xmm3
movapd %xmm4,%xmm2
mulsd  %xmm3,%xmm2
movapd %xmm3,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm3,%xmm1
mulsd  %xmm5,%xmm1
movapd %xmm3,%xmm6
mulsd  %xmm1,%xmm6
movapd %xmm3,%xmm0
mulsd  %xmm6,%xmm0
unpcklpd %xmm5,%xmm2
divpd  0xe65(%rip),%xmm2
mulsd  %xmm0,%xmm3
subsd  %xmm2,%xmm4
unpckhpd %xmm2,%xmm2
addsd  %xmm4,%xmm2
unpcklpd %xmm6,%xmm1
divpd  0xe59(%rip),%xmm1
subsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
unpcklpd %xmm3,%xmm0
divpd  0xe55(%rip),%xmm0
addsd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
jbe    1205 <sin+0xf5>
xorpd  0xe4b(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %2
store double 1.000000e+00, double* %3
%11 = load double, double* %2
%12 = load double, double* %2
%13 = fdiv double %12, 0x401921FB54442D18
%14 = call i32 @floor(double %13)
%15 = mul nsw i32 %14, 2
%16 = sitofp i32 %15 to double
%17 = fneg double %16
%18 = call double @llvm.fmuladd.f64(double %17, double 0x400921FB54442D18, double %11)
store double %18, double* %2
%19 = load double, double* %2
%20 = fcmp ogt double %19, 0x400921FB54442D18
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load double, double* %2
%23 = fsub double %22, 0x400921FB54442D18
store double %23, double* %2
store double -1.000000e+00, double* %3
br label %24
24: ; preds = %21, %1
%25 = load double, double* %2
%26 = fcmp ogt double %25, 0x3FF921FB54442D18
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load double, double* %2
%29 = fsub double 0x400921FB54442D18, %28
store double %29, double* %2
br label %30
30: ; preds = %27, %24
%31 = load double, double* %2
%32 = load double, double* %2
%33 = fmul double %31, %32
store double %33, double* %4
%34 = load double, double* %2
%35 = load double, double* %4
%36 = fmul double %34, %35
store double %36, double* %5
%37 = load double, double* %5
%38 = load double, double* %4
%39 = fmul double %37, %38
store double %39, double* %6
%40 = load double, double* %6
%41 = load double, double* %4
%42 = fmul double %40, %41
store double %42, double* %7
%43 = load double, double* %7
%44 = load double, double* %4
%45 = fmul double %43, %44
store double %45, double* %8
%46 = load double, double* %8
%47 = load double, double* %4
%48 = fmul double %46, %47
store double %48, double* %9
%49 = load double, double* %9
%50 = load double, double* %4
%51 = fmul double %49, %50
store double %51, double* %10
%52 = load double, double* %3
%53 = load double, double* %2
%54 = load double, double* %5
%55 = fdiv double %54, 6.000000e+00
%56 = fsub double %53, %55
%57 = load double, double* %6
%58 = fdiv double %57, 1.200000e+02
%59 = fadd double %56, %58
%60 = load double, double* %7
%61 = fdiv double %60, 5.040000e+03
%62 = fsub double %59, %61
%63 = load double, double* %8
%64 = fdiv double %63, 3.628800e+05
%65 = fadd double %62, %64
%66 = load double, double* %9
%67 = fdiv double %66, 3.991680e+07
%68 = fsub double %65, %67
%69 = load double, double* %10
%70 = fdiv double %69, 0x41F7328CC0000000
%71 = fadd double %68, %70
%72 = fmul double %52, %71
ret double %72
}

LLVM IR (-O2):
define double @sin(double %0) {
%2 = fdiv double %0, 0x401921FB54442D18
%3 = tail call i32 @floor(double %2)
%4 = shl nsw i32 %3, 1
%5 = sitofp i32 %4 to double
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x400921FB54442D18, double %0)
%8 = fcmp ogt double %7, 0x400921FB54442D18
%9 = fadd double %7, 0xC00921FB54442D18
%10 = select i1 %8, double %9, double %7
%11 = fcmp ogt double %10, 0x3FF921FB54442D18
%12 = fsub double 0x400921FB54442D18, %10
%13 = select i1 %11, double %12, double %10
%14 = fmul double %13, %13
%15 = fmul double %13, %14
%16 = fmul double %14, %15
%17 = fmul double %14, %16
%18 = fmul double %14, %17
%19 = fmul double %14, %18
%20 = fmul double %14, %19
%21 = insertelement <2 x double> poison, double %15, i64 0
%22 = insertelement <2 x double> %21, double %16, i64 1
%23 = fdiv <2 x double> %22, <double 6.000000e+00, double 1.200000e+02>
%24 = extractelement <2 x double> %23, i64 0
%25 = fsub double %13, %24
%26 = extractelement <2 x double> %23, i64 1
%27 = fadd double %25, %26
%28 = insertelement <2 x double> poison, double %17, i64 0
%29 = insertelement <2 x double> %28, double %18, i64 1
%30 = fdiv <2 x double> %29, <double 5.040000e+03, double 3.628800e+05>
%31 = extractelement <2 x double> %30, i64 0
%32 = fsub double %27, %31
%33 = extractelement <2 x double> %30, i64 1
%34 = fadd double %32, %33
%35 = insertelement <2 x double> poison, double %19, i64 0
%36 = insertelement <2 x double> %35, double %20, i64 1
%37 = fdiv <2 x double> %36, <double 3.991680e+07, double 0x41F7328CC0000000>
%38 = extractelement <2 x double> %37, i64 0
%39 = fsub double %34, %38
%40 = extractelement <2 x double> %37, i64 1
%41 = fadd double %39, %40
%42 = fneg double %41
%43 = select i1 %8, double %42, double %41
ret double %43
}