double __kernel_cos(double x) {
  double a1, a2, a3, a4;
  a1 = 0.5000000;
  a2 = 0.0833333;
  a3 = 0.0333333;
  a4 = 0.0178571;
  return (1 -
          a1 * x * x * (1 - a2 * x * x * (1 - a3 * x * x * (1 - a4 * x * x))));
}


x86 assembly (clang, -O0):
<__kernel_cos>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xf0f(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xefa(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee5(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  -0x8(%rbp),%xmm2
mulsd  -0x8(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
mulsd  -0x8(%rbp),%xmm3
movsd  -0x8(%rbp),%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xe64(%rip),%xmm4
addsd  %xmm4,%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xe3d(%rip),%xmm3
addsd  %xmm3,%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe16(%rip),%xmm2
addsd  %xmm2,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdef(%rip),%xmm1
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<__kernel_cos>:
movsd  0xef8(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xef0(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xeec(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  0xedc(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xecc(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @__kernel_cos(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
store double 5.000000e-01, double* %3
store double 8.333330e-02, double* %4
store double 3.333330e-02, double* %5
store double 1.785710e-02, double* %6
%7 = load double, double* %3
%8 = load double, double* %2
%9 = fmul double %7, %8
%10 = load double, double* %2
%11 = fmul double %9, %10
%12 = load double, double* %4
%13 = load double, double* %2
%14 = fmul double %12, %13
%15 = load double, double* %2
%16 = fmul double %14, %15
%17 = load double, double* %5
%18 = load double, double* %2
%19 = fmul double %17, %18
%20 = load double, double* %2
%21 = fmul double %19, %20
%22 = load double, double* %6
%23 = load double, double* %2
%24 = fmul double %22, %23
%25 = load double, double* %2
%26 = fneg double %24
%27 = call double @llvm.fmuladd.f64(double %26, double %25, double 1.000000e+00)
%28 = fneg double %21
%29 = call double @llvm.fmuladd.f64(double %28, double %27, double 1.000000e+00)
%30 = fneg double %16
%31 = call double @llvm.fmuladd.f64(double %30, double %29, double 1.000000e+00)
%32 = fneg double %11
%33 = call double @llvm.fmuladd.f64(double %32, double %31, double 1.000000e+00)
ret double %33
}

LLVM IR (-O2):
define double @__kernel_cos(double %0) {
%2 = fmul double %0, -1.785710e-02
%3 = tail call double @llvm.fmuladd.f64(double %2, double %0, double 1.000000e+00)
%4 = fmul double %0, -3.333330e-02
%5 = fmul double %4, %0
%6 = tail call double @llvm.fmuladd.f64(double %5, double %3, double 1.000000e+00)
%7 = fmul double %0, -8.333330e-02
%8 = fmul double %7, %0
%9 = tail call double @llvm.fmuladd.f64(double %8, double %6, double 1.000000e+00)
%10 = fmul double %0, -5.000000e-01
%11 = fmul double %10, %0
%12 = tail call double @llvm.fmuladd.f64(double %11, double %9, double 1.000000e+00)
ret double %12
}