double drag_cd_g2(double mach) {
  if (mach > 2.5)
    return 0.4465610 + mach * (-0.0958548 + mach * 0.00799645);
  else if (mach > 1.2)
    return 0.7016110 + mach * (-0.3075100 + mach * 0.05192560);
  else if (mach > 1.0)
    return -1.105010 + mach * (2.77195000 - mach * 1.26667000);
  else if (mach > 0.9)
    return -2.240370 + mach * 2.63867000;
  else if (mach >= 0.7)
    return 0.9099690 + mach * (-1.9017100 + mach * 1.21524000);
  else
    return 0.2302760 + mach * (0.000210564 - mach * 0.1275050);
}


x86 assembly (clang, -O0):
<drag_cd_g2>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeea(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115c <drag_cd_g2+0x5c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xf6e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xf6a(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xf4a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <drag_cd_g2+0x1f8>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11af <drag_cd_g2+0xaf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xf03(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xeff(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xedf(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <drag_cd_g2+0x1f8>
movsd  -0x10(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1219 <drag_cd_g2+0x119>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe81(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe7d(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <drag_cd_g2+0x1f8>
movsd  -0x10(%rbp),%xmm0
movsd  0xdf2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1257 <drag_cd_g2+0x157>
movsd  -0x10(%rbp),%xmm0
movsd  0xe1b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe17(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <drag_cd_g2+0x1f8>
movsd  -0x10(%rbp),%xmm0
movsd  0xdbc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12aa <drag_cd_g2+0x1aa>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdc8(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdc4(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <drag_cd_g2+0x1f8>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd5d(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd59(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd39(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<drag_cd_g2>:
ucomisd 0xef8(%rip),%xmm0
jbe    112f <drag_cd_g2+0x2f>
movsd  0xf86(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf82(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf7e(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xed1(%rip),%xmm0
jbe    115e <drag_cd_g2+0x5e>
movsd  0xf3f(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf3b(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf37(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xeaa(%rip),%xmm0
jbe    118d <drag_cd_g2+0x8d>
movsd  0xef8(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xef4(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xef0(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xe83(%rip),%xmm0
jbe    11a8 <drag_cd_g2+0xa8>
mulsd  0xeb9(%rip),%xmm0
addsd  0xeb9(%rip),%xmm0
ret
ucomisd 0xe70(%rip),%xmm0
jae    11d7 <drag_cd_g2+0xd7>
movsd  0xe86(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe82(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe7e(%rip),%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xe49(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe45(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe41(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @drag_cd_g2(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ogt double %4, 2.500000e+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 7.996450e-03, double -9.585480e-02)
%10 = call double @llvm.fmuladd.f64(double %7, double %9, double 4.465610e-01)
store double %10, double* %2
br label %48
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp ogt double %12, 1.200000e+00
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load double, double* %3
%16 = load double, double* %3
%17 = call double @llvm.fmuladd.f64(double %16, double 5.192560e-02, double -3.075100e-01)
%18 = call double @llvm.fmuladd.f64(double %15, double %17, double 0x3FE67398E9707182)
store double %18, double* %2
br label %48
19: ; preds = %11
%20 = load double, double* %3
%21 = fcmp ogt double %20, 1.000000e+00
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load double, double* %3
%24 = load double, double* %3
%25 = fneg double %24
%26 = call double @llvm.fmuladd.f64(double %25, double 1.266670e+00, double 2.771950e+00)
%27 = call double @llvm.fmuladd.f64(double %23, double %26, double -1.105010e+00)
store double %27, double* %2
br label %48
28: ; preds = %19
%29 = load double, double* %3
%30 = fcmp ogt double %29, 9.000000e-01
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load double, double* %3
%33 = call double @llvm.fmuladd.f64(double %32, double 2.638670e+00, double -2.240370e+00)
store double %33, double* %2
br label %48
34: ; preds = %28
%35 = load double, double* %3
%36 = fcmp oge double %35, 0x3FE6666666666666
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load double, double* %3
%39 = load double, double* %3
%40 = call double @llvm.fmuladd.f64(double %39, double 1.215240e+00, double -1.901710e+00)
%41 = call double @llvm.fmuladd.f64(double %38, double %40, double 9.099690e-01)
store double %41, double* %2
br label %48
42: ; preds = %34
%43 = load double, double* %3
%44 = load double, double* %3
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %45, double 1.275050e-01, double 2.105640e-04)
%47 = call double @llvm.fmuladd.f64(double %43, double %46, double 2.302760e-01)
store double %47, double* %2
br label %48
48: ; preds = %42, %37, %31, %22, %14, %6
%49 = load double, double* %2
ret double %49
}

LLVM IR (-O2):
define double @drag_cd_g2(double %0) {
%2 = fcmp ogt double %0, 2.500000e+00
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call double @llvm.fmuladd.f64(double %0, double 7.996450e-03, double -9.585480e-02)
%5 = tail call double @llvm.fmuladd.f64(double %0, double %4, double 4.465610e-01)
br label %30
6: ; preds = %1
%7 = fcmp ogt double %0, 1.200000e+00
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call double @llvm.fmuladd.f64(double %0, double 5.192560e-02, double -3.075100e-01)
%10 = tail call double @llvm.fmuladd.f64(double %0, double %9, double 0x3FE67398E9707182)
br label %30
11: ; preds = %6
%12 = fcmp ogt double %0, 1.000000e+00
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = fneg double %0
%15 = tail call double @llvm.fmuladd.f64(double %14, double 1.266670e+00, double 2.771950e+00)
%16 = tail call double @llvm.fmuladd.f64(double %0, double %15, double -1.105010e+00)
br label %30
17: ; preds = %11
%18 = fcmp ogt double %0, 9.000000e-01
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call double @llvm.fmuladd.f64(double %0, double 2.638670e+00, double -2.240370e+00)
br label %30
21: ; preds = %17
%22 = fcmp ult double %0, 0x3FE6666666666666
br i1 %22, label %26, label %23
23: ; preds = %21
%24 = tail call double @llvm.fmuladd.f64(double %0, double 1.215240e+00, double -1.901710e+00)
%25 = tail call double @llvm.fmuladd.f64(double %0, double %24, double 9.099690e-01)
br label %30
26: ; preds = %21
%27 = fneg double %0
%28 = tail call double @llvm.fmuladd.f64(double %27, double 1.275050e-01, double 2.105640e-04)
%29 = tail call double @llvm.fmuladd.f64(double %0, double %28, double 2.302760e-01)
br label %30
30: ; preds = %26, %23, %19, %13, %8, %3
%31 = phi double [ %5, %3 ], [ %10, %8 ], [ %16, %13 ], [ %20, %19 ], [ %25, %23 ], [ %29, %26 ]
ret double %31
}