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


x86 assembly (clang, -O0):
<ft_sin>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeef(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1133 <ft_sin+0x33>
movsd  0xeec(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1165 <ft_sin+0x65>
movsd  -0x8(%rbp),%xmm0
movsd  0xec8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1160 <ft_sin+0x60>
movsd  -0x8(%rbp),%xmm0
movsd  0xeb9(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1165 <ft_sin+0x65>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    125e <ft_sin+0x15e>
movsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xe86(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1211 <ft_sin+0x111>
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  0xe29(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1259 <ft_sin+0x159>
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  0xddc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1360 <ft_sin+0x260>
movsd  -0x8(%rbp),%xmm0
movsd  0xdb5(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd84(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1313 <ft_sin+0x213>
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  0xd27(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    135b <ft_sin+0x25b>
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  0xcda(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1360 <ft_sin+0x260>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_sin>:
movsd  0xef8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1118 <ft_sin+0x18>
addsd  0xf02(%rip),%xmm0
jmp    112a <ft_sin+0x2a>
ucomisd 0xee8(%rip),%xmm0
jbe    112a <ft_sin+0x2a>
addsd  0xee6(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    113e <ft_sin+0x3e>
movsd  0xefc(%rip),%xmm2
jmp    1146 <ft_sin+0x46>
movsd  0xeda(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  0xed2(%rip),%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
movapd 0xeda(%rip),%xmm2
xorpd  %xmm0,%xmm2
movapd %xmm0,%xmm1
jbe    1176 <ft_sin+0x76>
mulsd  %xmm2,%xmm1
jmp    117a <ft_sin+0x7a>
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xeaa(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

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

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