double drag_cd_gi(double mach) {
  if (mach > 1.65)
    return 0.845362 + mach * (-0.143989 + mach * 0.0113272);
  else if (mach > 1.2)
    return 0.630556 + mach * 0.00701308;
  else if (mach >= 0.7)
    return 0.531976 + mach * (-1.28079 + mach * 1.17628);
  else
    return 0.2282;
}


x86 assembly (clang, -O0):
<drag_cd_gi>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeea(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115c <drag_cd_gi+0x5c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xf1e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xf1a(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xefa(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fa <drag_cd_gi+0xfa>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119a <drag_cd_gi+0x9a>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fa <drag_cd_gi+0xfa>
movsd  -0x10(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ed <drag_cd_gi+0xed>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe65(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe61(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fa <drag_cd_gi+0xfa>
movsd  0xe23(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<drag_cd_gi>:
ucomisd 0xef8(%rip),%xmm0
jbe    112f <drag_cd_gi+0x2f>
movsd  0xf36(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf32(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf2e(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xed1(%rip),%xmm0
jbe    114a <drag_cd_gi+0x4a>
mulsd  0xef7(%rip),%xmm0
addsd  0xef7(%rip),%xmm0
ret
ucomisd 0xebe(%rip),%xmm0
jae    115d <drag_cd_gi+0x5d>
movsd  0xed4(%rip),%xmm0
ret
movsd  0xeb3(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeaf(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeab(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @drag_cd_gi(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ogt double %4, 1.650000e+00
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load double, double* %3
%8 = load double, double* %3
%9 = call double @llvm.fmuladd.f64(double %8, double 1.132720e-02, double -1.439890e-01)
%10 = call double @llvm.fmuladd.f64(double %7, double %9, double 0x3FEB0D349BE8FF32)
store double %10, double* %2
br label %26
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp ogt double %12, 1.200000e+00
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load double, double* %3
%16 = call double @llvm.fmuladd.f64(double %15, double 7.013080e-03, double 6.305560e-01)
store double %16, double* %2
br label %26
17: ; preds = %11
%18 = load double, double* %3
%19 = fcmp oge double %18, 0x3FE6666666666666
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load double, double* %3
%22 = load double, double* %3
%23 = call double @llvm.fmuladd.f64(double %22, double 1.176280e+00, double -1.280790e+00)
%24 = call double @llvm.fmuladd.f64(double %21, double %23, double 5.319760e-01)
store double %24, double* %2
br label %26
25: ; preds = %17
store double 2.282000e-01, double* %2
br label %26
26: ; preds = %25, %20, %14, %6
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @drag_cd_gi(double %0) {
%2 = fcmp ogt double %0, 1.650000e+00
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call double @llvm.fmuladd.f64(double %0, double 1.132720e-02, double -1.439890e-01)
%5 = tail call double @llvm.fmuladd.f64(double %0, double %4, double 0x3FEB0D349BE8FF32)
br label %15
6: ; preds = %1
%7 = fcmp ogt double %0, 1.200000e+00
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call double @llvm.fmuladd.f64(double %0, double 7.013080e-03, double 6.305560e-01)
br label %15
10: ; preds = %6
%11 = fcmp ult double %0, 0x3FE6666666666666
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call double @llvm.fmuladd.f64(double %0, double 1.176280e+00, double -1.280790e+00)
%14 = tail call double @llvm.fmuladd.f64(double %0, double %13, double 5.319760e-01)
br label %15
15: ; preds = %10, %12, %8, %3
%16 = phi double [ %5, %3 ], [ %9, %8 ], [ %14, %12 ], [ 2.282000e-01, %10 ]
ret double %16
}