double sin(f)
double f;
{
  static double coeff_a[] = {0.1357884e8, -0.49429081e7, 0.440103053e6,
                             -0.138472724e5, 0.145968841e3};
  static double coeff_b[] = {0.864455865e7, 0.408179225e6, 0.946309610e4,
                             0.132653491e3, 1.0};
  double y, y_squared;
  int sect, e;
  extern double eval_poly();
  if (f < 0.0) {
    f = -f;
    sect = 2;
  } else
    sect = 0;
  f *= .63661977237;
  if (f > 4.0)
    f -= 4.0 * floor(f / 4.0);
  if (f > 2.0) {
    f -= 2.0;
    sect = 2 - sect;
  }
  y = f - (e = (int)f);
  sect = (e + sect) % 4;
  if (sect & 1)
    y = 1.0 - y;
  if (sect & 2)
    y = -y;
  y_squared = y * y;
  return y * eval_poly(y_squared, coeff_a, 4) /
         eval_poly(y_squared, coeff_b, 4);
}


x86 assembly (clang, -O0):
<sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1168 <sin+0x48>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x2,-0x1c(%rbp)
jmp    116f <sin+0x4f>
movl   $0x0,-0x1c(%rbp)
movsd  0xe91(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c8 <sin+0xa8>
movsd  -0x8(%rbp),%xmm0
movsd  0xe5b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  -0x8(%rbp),%xmm1
movsd  0xe55(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1200 <sin+0xe0>
movsd  -0x8(%rbp),%xmm0
movsd  0xe2c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x2,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     124c <sin+0x12c>
movsd  0xdde(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     127c <sin+0x15c>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0x2d9f(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0x2da6(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
ucomisd %xmm2,%xmm0
seta   %bl
jbe    1140 <sin+0x20>
xorpd  0xec0(%rip),%xmm2
mulsd  0xec8(%rip),%xmm2
add    %ebx,%ebx
ucomisd 0xec6(%rip),%xmm2
jbe    117d <sin+0x5d>
movsd  0xec4(%rip),%xmm0
mulsd  %xmm2,%xmm0
movapd %xmm2,0x10(%rsp)
call   1040 <floor@plt>
movapd 0x10(%rsp),%xmm2
mulsd  0xeaf(%rip),%xmm0
addsd  %xmm0,%xmm2
mov    $0x2,%eax
sub    %ebx,%eax
movsd  0xea4(%rip),%xmm1
ucomisd %xmm1,%xmm2
cmovbe %ebx,%eax
movsd  0xe9d(%rip),%xmm0
addsd  %xmm2,%xmm0
cmpltsd %xmm2,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
cvttsd2si %xmm1,%ecx
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
lea    (%rax,%rcx,1),%edx
add    $0x3,%edx
add    %ecx,%eax
cmovns %eax,%edx
subsd  %xmm0,%xmm1
and    $0xfffffffc,%edx
sub    %edx,%eax
test   $0x1,%al
je     11e4 <sin+0xc4>
movsd  0xe64(%rip),%xmm0
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
test   $0x2,%al
je     11f0 <sin+0xd0>
xorpd  0xe10(%rip),%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x2e36(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x2e49(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@sin.coeff_a = internal global [5 x double] [double 0x4169E64B00000000, double 0xC152DB0F06666666, double 0x411ADC9C3645A1CB, double 0xC0CB0BA2DE00D1B7, double 0x40623F00BED740C4]
@sin.coeff_b = internal global [5 x double] [double 0x41607CF9D4CCCCCD, double 0x4118E9CCE6666666, double 0x40C27B8C4D013A93, double 0x406094E965F5275F, double 1.000000e+00]
define double @sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store double %0, double* %2
%7 = load double, double* %2
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load double, double* %2
%11 = fneg double %10
store double %11, double* %2
store i32 2, i32* %5
br label %13
12: ; preds = %1
store i32 0, i32* %5
br label %13
13: ; preds = %12, %9
%14 = load double, double* %2
%15 = fmul double %14, 0x3FE45F306DCA1D9C
store double %15, double* %2
%16 = load double, double* %2
%17 = fcmp ogt double %16, 4.000000e+00
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load double, double* %2
%20 = fdiv double %19, 4.000000e+00
%21 = call double @llvm.floor.f64(double %20)
%22 = load double, double* %2
%23 = call double @llvm.fmuladd.f64(double -4.000000e+00, double %21, double %22)
store double %23, double* %2
br label %24
24: ; preds = %18, %13
%25 = load double, double* %2
%26 = fcmp ogt double %25, 2.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load double, double* %2
%29 = fsub double %28, 2.000000e+00
store double %29, double* %2
%30 = load i32, i32* %5
%31 = sub nsw i32 2, %30
store i32 %31, i32* %5
br label %32
32: ; preds = %27, %24
%33 = load double, double* %2
%34 = load double, double* %2
%35 = fptosi double %34 to i32
store i32 %35, i32* %6
%36 = sitofp i32 %35 to double
%37 = fsub double %33, %36
store double %37, double* %3
%38 = load i32, i32* %6
%39 = load i32, i32* %5
%40 = add nsw i32 %38, %39
%41 = srem i32 %40, 4
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = and i32 %42, 1
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %32
%46 = load double, double* %3
%47 = fsub double 1.000000e+00, %46
store double %47, double* %3
br label %48
48: ; preds = %45, %32
%49 = load i32, i32* %5
%50 = and i32 %49, 2
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load double, double* %3
%54 = fneg double %53
store double %54, double* %3
br label %55
55: ; preds = %52, %48
%56 = load double, double* %3
%57 = load double, double* %3
%58 = fmul double %56, %57
store double %58, double* %4
%59 = load double, double* %3
%60 = load double, double* %4
%61 = call double (double, double*, i32, ...) bitcast (double (...)* @eval_poly to double (double, double*, i32, ...)*)(double %60, double* getelementptr inbounds ([5 x double], [5 x double]* @sin.coeff_a, i64 0, i64 0), i32 4)
%62 = fmul double %59, %61
%63 = load double, double* %4
%64 = call double (double, double*, i32, ...) bitcast (double (...)* @eval_poly to double (double, double*, i32, ...)*)(double %63, double* getelementptr inbounds ([5 x double], [5 x double]* @sin.coeff_b, i64 0, i64 0), i32 4)
%65 = fdiv double %62, %64
ret double %65
}

LLVM IR (-O2):
@sin.coeff_a = internal global [5 x double] [double 0x4169E64B00000000, double 0xC152DB0F06666666, double 0x411ADC9C3645A1CB, double 0xC0CB0BA2DE00D1B7, double 0x40623F00BED740C4]
@sin.coeff_b = internal global [5 x double] [double 0x41607CF9D4CCCCCD, double 0x4118E9CCE6666666, double 0x40C27B8C4D013A93, double 0x406094E965F5275F, double 1.000000e+00]
define double @sin(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, i32 2, i32 0
%5 = select i1 %2, double %3, double %0
%6 = fmul double %5, 0x3FE45F306DCA1D9C
%7 = fcmp ogt double %6, 4.000000e+00
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = fmul double %6, 2.500000e-01
%10 = tail call double @llvm.floor.f64(double %9)
%11 = tail call double @llvm.fmuladd.f64(double %10, double -4.000000e+00, double %6)
br label %12
12: ; preds = %8, %1
%13 = phi double [ %11, %8 ], [ %6, %1 ]
%14 = fcmp ogt double %13, 2.000000e+00
%15 = fadd double %13, -2.000000e+00
%16 = sub nuw nsw i32 2, %4
%17 = select i1 %14, i32 %16, i32 %4
%18 = select i1 %14, double %15, double %13
%19 = fptosi double %18 to i32
%20 = sitofp i32 %19 to double
%21 = fsub double %18, %20
%22 = add nsw i32 %17, %19
%23 = srem i32 %22, 4
%24 = and i32 %23, 1
%25 = icmp eq i32 %24, 0
%26 = fsub double 1.000000e+00, %21
%27 = select i1 %25, double %21, double %26
%28 = and i32 %23, 2
%29 = icmp eq i32 %28, 0
%30 = fneg double %27
%31 = select i1 %29, double %27, double %30
%32 = fmul double %31, %31
%33 = tail call double (double, double*, i32, ...) bitcast (double (...)* @eval_poly to double (double, double*, i32, ...)*)(double %32, double* getelementptr inbounds ([5 x double], [5 x double]* @sin.coeff_a, i64 0, i64 0), i32 4)
%34 = fmul double %33, %31
%35 = tail call double (double, double*, i32, ...) bitcast (double (...)* @eval_poly to double (double, double*, i32, ...)*)(double %32, double* getelementptr inbounds ([5 x double], [5 x double]* @sin.coeff_b, i64 0, i64 0), i32 4)
%36 = fdiv double %34, %35
ret double %36
}