double __kernel_cos(double x, double y) {
  double a, hz, z, r, qx;
  int ix;
  ix = *(1 + (int *)&x) & 0x7fffffff;
  if (ix < 0x3e400000) {
    if (((int)x) == 0) {
      return 1.00000000000000000000e+00;
    }
  }
  z = x * x;
  r = z * (4.16666666666666019037e-02 +
           z * (-1.38888888888741095749e-03 +
                z * (2.48015872894767294178e-05 +
                     z * (-2.75573143513906633035e-07 +
                          z * (2.08757232129817482790e-09 +
                               z * -1.13596475577881948265e-11)))));
  if (ix < 0x3FD33333) {
    return 1.00000000000000000000e+00 - (0.5 * z - (z * r - x * y));
  } else {
    if (ix > 0x3fe90000) {
      qx = 0.28125;
    } else {
      *(1 + (int *)&qx) = ix - 0x00200000;
      *(int *)&qx = 0;
    }
    hz = 0.5 * z - qx;
    a = 1.00000000000000000000e+00 - qx;
    return a - (hz - (z * r - x * y));
  }
}


x86 assembly (clang, -O0):
<__kernel_cos>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7fffffff,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x3e400000,-0x44(%rbp)
jge    114b <__kernel_cos+0x4b>
cvttsd2si -0x10(%rbp),%eax
cmp    $0x0,%eax
jne    1146 <__kernel_cos+0x46>
movsd  0xefc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    131e <__kernel_cos+0x21e>
jmp    114b <__kernel_cos+0x4b>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x30(%rbp),%xmm5
movsd  0xea0(%rip),%xmm6
mulsd  %xmm6,%xmm5
movsd  0xe9c(%rip),%xmm6
addsd  %xmm6,%xmm5
mulsd  %xmm5,%xmm4
movsd  0xe7c(%rip),%xmm5
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe64(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe4c(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe34(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x3fd33333,-0x44(%rbp)
jge    125b <__kernel_cos+0x15b>
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe03(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdeb(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    131e <__kernel_cos+0x21e>
cmpl   $0x3fe90000,-0x44(%rbp)
jle    127a <__kernel_cos+0x17a>
movsd  0xdc0(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    128c <__kernel_cos+0x18c>
mov    -0x44(%rbp),%eax
sub    $0x200000,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd8b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xd6e(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm4
movsd  -0x10(%rbp),%xmm3
mulsd  -0x18(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<__kernel_cos>:
movq   %xmm0,%rax
shr    $0x20,%rax
and    $0x7fffffff,%eax
cmp    $0x3e3fffff,%eax
ja     1126 <__kernel_cos+0x26>
cvttsd2si %xmm0,%ecx
test   %ecx,%ecx
jne    1126 <__kernel_cos+0x26>
movsd  0xedb(%rip),%xmm0
ret
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movsd  0xed2(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xece(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xeca(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xec6(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xec2(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xebe(%rip),%xmm4
mulsd  %xmm3,%xmm4
cmp    $0x3fd33332,%eax
ja     11a6 <__kernel_cos+0xa6>
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm4
mulsd  0xeb3(%rip),%xmm3
subsd  %xmm0,%xmm4
subsd  %xmm4,%xmm3
movsd  0xe63(%rip),%xmm2
subsd  %xmm3,%xmm2
movapd %xmm2,%xmm0
ret
cmp    $0x3fe90001,%eax
jae    11bd <__kernel_cos+0xbd>
add    $0xffe00000,%eax
shl    $0x20,%rax
movq   %rax,%xmm5
jmp    11c5 <__kernel_cos+0xc5>
movq   0xe73(%rip),%xmm5
movsd  0xe73(%rip),%xmm6
mulsd  %xmm3,%xmm6
subsd  %xmm5,%xmm6
movsd  0xe23(%rip),%xmm2
subsd  %xmm5,%xmm2
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm4
subsd  %xmm0,%xmm4
subsd  %xmm4,%xmm6
subsd  %xmm6,%xmm2
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @__kernel_cos(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
store double %0, double* %4
store double %1, double* %5
%12 = bitcast double* %4 to i32*
%13 = getelementptr inbounds i32, i32* %12, i64 1
%14 = load i32, i32* %13
%15 = and i32 %14, 2147483647
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = icmp slt i32 %16, 1044381696
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load double, double* %4
%20 = fptosi double %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store double 1.000000e+00, double* %3
br label %82
23: ; preds = %18
br label %24
24: ; preds = %23, %2
%25 = load double, double* %4
%26 = load double, double* %4
%27 = fmul double %25, %26
store double %27, double* %8
%28 = load double, double* %8
%29 = load double, double* %8
%30 = load double, double* %8
%31 = load double, double* %8
%32 = load double, double* %8
%33 = load double, double* %8
%34 = call double @llvm.fmuladd.f64(double %33, double 0xBDA8FAE9BE8838D4, double 0x3E21EE9EBDB4B1C4)
%35 = call double @llvm.fmuladd.f64(double %32, double %34, double 0xBE927E4F809C52AD)
%36 = call double @llvm.fmuladd.f64(double %31, double %35, double 0x3EFA01A019CB1590)
%37 = call double @llvm.fmuladd.f64(double %30, double %36, double 0xBF56C16C16C15177)
%38 = call double @llvm.fmuladd.f64(double %29, double %37, double 0x3FA555555555554C)
%39 = fmul double %28, %38
store double %39, double* %9
%40 = load i32, i32* %11
%41 = icmp slt i32 %40, 1070805811
br i1 %41, label %42, label %54
42: ; preds = %24
%43 = load double, double* %8
%44 = load double, double* %8
%45 = load double, double* %9
%46 = load double, double* %4
%47 = load double, double* %5
%48 = fmul double %46, %47
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double %44, double %45, double %49)
%51 = fneg double %50
%52 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %43, double %51)
%53 = fsub double 1.000000e+00, %52
store double %53, double* %3
br label %82
54: ; preds = %24
%55 = load i32, i32* %11
%56 = icmp sgt i32 %55, 1072234496
br i1 %56, label %57, label %58
57: ; preds = %54
store double 2.812500e-01, double* %10
br label %64
58: ; preds = %54
%59 = load i32, i32* %11
%60 = sub nsw i32 %59, 2097152
%61 = bitcast double* %10 to i32*
%62 = getelementptr inbounds i32, i32* %61, i64 1
store i32 %60, i32* %62
%63 = bitcast double* %10 to i32*
store i32 0, i32* %63
br label %64
64: ; preds = %58, %57
%65 = load double, double* %8
%66 = load double, double* %10
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %65, double %67)
store double %68, double* %7
%69 = load double, double* %10
%70 = fsub double 1.000000e+00, %69
store double %70, double* %6
%71 = load double, double* %6
%72 = load double, double* %7
%73 = load double, double* %8
%74 = load double, double* %9
%75 = load double, double* %4
%76 = load double, double* %5
%77 = fmul double %75, %76
%78 = fneg double %77
%79 = call double @llvm.fmuladd.f64(double %73, double %74, double %78)
%80 = fsub double %72, %79
%81 = fsub double %71, %80
store double %81, double* %3
br label %82
82: ; preds = %64, %42, %22
%83 = load double, double* %3
ret double %83
}

LLVM IR (-O2):
define double @__kernel_cos(double %0, double %1) {
%3 = bitcast double %0 to i64
%4 = lshr i64 %3, 32
%5 = trunc i64 %4 to i32
%6 = and i32 %5, 2147483647
%7 = icmp ult i32 %6, 1044381696
%8 = fptosi double %0 to i32
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %42, label %11
11: ; preds = %2
%12 = fmul double %0, %0
%13 = tail call double @llvm.fmuladd.f64(double %12, double 0xBDA8FAE9BE8838D4, double 0x3E21EE9EBDB4B1C4)
%14 = tail call double @llvm.fmuladd.f64(double %12, double %13, double 0xBE927E4F809C52AD)
%15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double 0x3EFA01A019CB1590)
%16 = tail call double @llvm.fmuladd.f64(double %12, double %15, double 0xBF56C16C16C15177)
%17 = tail call double @llvm.fmuladd.f64(double %12, double %16, double 0x3FA555555555554C)
%18 = fmul double %12, %17
%19 = icmp ult i32 %6, 1070805811
br i1 %19, label %20, label %27
20: ; preds = %11
%21 = fneg double %0
%22 = fmul double %21, %1
%23 = tail call double @llvm.fmuladd.f64(double %12, double %18, double %22)
%24 = fneg double %23
%25 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %24)
%26 = fsub double 1.000000e+00, %25
br label %42
27: ; preds = %11
%28 = icmp ugt i32 %6, 1072234496
%29 = add nsw i32 %6, -2097152
%30 = zext i32 %29 to i64
%31 = shl nuw nsw i64 %30, 32
%32 = bitcast i64 %31 to double
%33 = select i1 %28, double 2.812500e-01, double %32
%34 = fneg double %33
%35 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %34)
%36 = fsub double 1.000000e+00, %33
%37 = fneg double %0
%38 = fmul double %37, %1
%39 = tail call double @llvm.fmuladd.f64(double %12, double %18, double %38)
%40 = fsub double %35, %39
%41 = fsub double %36, %40
br label %42
42: ; preds = %2, %27, %20
%43 = phi double [ %26, %20 ], [ %41, %27 ], [ 1.000000e+00, %2 ]
ret double %43
}