double ft_cos(double ang) {
  double cosinus;
  ang += 1.57079632;
  if (ang > 3.14159265)
    ang -= 6.28318531;
  if (ang < 0) {
    cosinus = 1.27323954 * ang + 0.405284735 * ang * ang;
    if (cosinus < 0)
      cosinus = 0.225 * (cosinus * (-cosinus) - cosinus) + cosinus;
    else
      cosinus = 0.225 * (cosinus * cosinus - cosinus) + cosinus;
  } else {
    cosinus = 1.27323954 * ang - 0.405284735 * ang * ang;
    if (cosinus < 0)
      cosinus = 0.225 * (cosinus * (-cosinus) - cosinus) + cosinus;
    else
      cosinus = 0.225 * (cosinus * cosinus - cosinus) + cosinus;
  }
  return (cosinus);
}


x86 assembly (clang, -O0):
<ft_cos>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef7(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1148 <ft_cos+0x48>
movsd  -0x8(%rbp),%xmm0
movsd  0xed1(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1241 <ft_cos+0x141>
movsd  -0x8(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xea3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f4 <ft_cos+0xf4>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe46(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    123c <ft_cos+0x13c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdf9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1343 <ft_cos+0x243>
movsd  -0x8(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xda1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12f6 <ft_cos+0x1f6>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xd44(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    133e <ft_cos+0x23e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xcf7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1343 <ft_cos+0x243>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_cos>:
addsd  0xef8(%rip),%xmm0
movsd  0xef8(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0xef4(%rip),%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1141 <ft_cos+0x41>
movsd  0xef1(%rip),%xmm3
jmp    1149 <ft_cos+0x49>
movsd  0xecf(%rip),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movsd  0xec7(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
ucomisd %xmm2,%xmm0
movapd 0xed3(%rip),%xmm1
xorpd  %xmm2,%xmm1
movapd %xmm2,%xmm0
jbe    117d <ft_cos+0x7d>
mulsd  %xmm1,%xmm0
jmp    1181 <ft_cos+0x81>
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe9b(%rip),%xmm0
addsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @ft_cos(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fadd double %4, 0x3FF921FB52713C02
store double %5, double* %2
%6 = load double, double* %2
%7 = fcmp ogt double %6, 0x400921FB53C8D4F1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load double, double* %2
%10 = fsub double %9, 0x401921FB5474A168
store double %10, double* %2
br label %11
11: ; preds = %8, %1
%12 = load double, double* %2
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load double, double* %2
%16 = load double, double* %2
%17 = fmul double 0x3FD9F02F62992759, %16
%18 = load double, double* %2
%19 = fmul double %17, %18
%20 = call double @llvm.fmuladd.f64(double 0x3FF45F306C8462A6, double %15, double %19)
store double %20, double* %3
%21 = load double, double* %3
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %32
23: ; preds = %14
%24 = load double, double* %3
%25 = load double, double* %3
%26 = fneg double %25
%27 = load double, double* %3
%28 = fneg double %27
%29 = call double @llvm.fmuladd.f64(double %24, double %26, double %28)
%30 = load double, double* %3
%31 = call double @llvm.fmuladd.f64(double 2.250000e-01, double %29, double %30)
store double %31, double* %3
br label %40
32: ; preds = %14
%33 = load double, double* %3
%34 = load double, double* %3
%35 = load double, double* %3
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %33, double %34, double %36)
%38 = load double, double* %3
%39 = call double @llvm.fmuladd.f64(double 2.250000e-01, double %37, double %38)
store double %39, double* %3
br label %40
40: ; preds = %32, %23
br label %69
41: ; preds = %11
%42 = load double, double* %2
%43 = load double, double* %2
%44 = fmul double 0x3FD9F02F62992759, %43
%45 = load double, double* %2
%46 = fmul double %44, %45
%47 = fneg double %46
%48 = call double @llvm.fmuladd.f64(double 0x3FF45F306C8462A6, double %42, double %47)
store double %48, double* %3
%49 = load double, double* %3
%50 = fcmp olt double %49, 0.000000e+00
br i1 %50, label %51, label %60
51: ; preds = %41
%52 = load double, double* %3
%53 = load double, double* %3
%54 = fneg double %53
%55 = load double, double* %3
%56 = fneg double %55
%57 = call double @llvm.fmuladd.f64(double %52, double %54, double %56)
%58 = load double, double* %3
%59 = call double @llvm.fmuladd.f64(double 2.250000e-01, double %57, double %58)
store double %59, double* %3
br label %68
60: ; preds = %41
%61 = load double, double* %3
%62 = load double, double* %3
%63 = load double, double* %3
%64 = fneg double %63
%65 = call double @llvm.fmuladd.f64(double %61, double %62, double %64)
%66 = load double, double* %3
%67 = call double @llvm.fmuladd.f64(double 2.250000e-01, double %65, double %66)
store double %67, double* %3
br label %68
68: ; preds = %60, %51
br label %69
69: ; preds = %68, %40
%70 = load double, double* %3
ret double %70
}

LLVM IR (-O2):
define double @ft_cos(double %0) {
%2 = fadd double %0, 0x3FF921FB52713C02
%3 = fcmp ogt double %2, 0x400921FB53C8D4F1
%4 = fadd double %2, 0xC01921FB5474A168
%5 = select i1 %3, double %4, double %2
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = fmul double %5, 0x3FD9F02F62992759
%9 = fmul double %5, %8
%10 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FF45F306C8462A6, double %9)
%11 = fcmp olt double %10, 0.000000e+00
%12 = fneg double %10
br i1 %11, label %13, label %16
13: ; preds = %7
%14 = tail call double @llvm.fmuladd.f64(double %10, double %12, double %12)
%15 = tail call double @llvm.fmuladd.f64(double %14, double 2.250000e-01, double %10)
br label %31
16: ; preds = %7
%17 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %12)
%18 = tail call double @llvm.fmuladd.f64(double %17, double 2.250000e-01, double %10)
br label %31
19: ; preds = %1
%20 = fmul double %5, 0xBFD9F02F62992759
%21 = fmul double %5, %20
%22 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FF45F306C8462A6, double %21)
%23 = fcmp olt double %22, 0.000000e+00
%24 = fneg double %22
br i1 %23, label %25, label %28
25: ; preds = %19
%26 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %24)
%27 = tail call double @llvm.fmuladd.f64(double %26, double 2.250000e-01, double %22)
br label %31
28: ; preds = %19
%29 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %24)
%30 = tail call double @llvm.fmuladd.f64(double %29, double 2.250000e-01, double %22)
br label %31
31: ; preds = %25, %28, %13, %16
%32 = phi double [ %15, %13 ], [ %18, %16 ], [ %27, %25 ], [ %30, %28 ]
ret double %32
}