double getSplineCoeff(double a, double b, double c, double d, double dist) {
  if (dist <= 1.0)
    return ((d * dist + c) * dist + b) * dist + a;
  else
    return getSplineCoeff(0.0, b + 2.0 * c + 3.0 * d, c + 3.0 * d,
                          -b - 3.0 * c - 6.0 * d, dist - 1.0);
}


x86 assembly (clang, -O0):
<getSplineCoeff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  0xec7(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1189 <getSplineCoeff+0x79>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122e <getSplineCoeff+0x11e>
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe70(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xe56(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  -0x20(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm4
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  -0x28(%rbp),%xmm3
movsd  0xe00(%rip),%xmm4
mulsd  %xmm4,%xmm3
addsd  %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  0xde3(%rip),%xmm0
subsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
call   1030 <getSplineCoeff@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSplineCoeff>:
movsd  0xef7(%rip),%xmm10
ucomisd %xmm4,%xmm10
jae    1185 <getSplineCoeff+0x85>
movsd  0xeef(%rip),%xmm8
movsd  0xeee(%rip),%xmm9
movsd  0xeee(%rip),%xmm7
movsd  0xeee(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm1,%xmm6
movapd %xmm2,%xmm5
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm6,%xmm1
movapd %xmm3,%xmm2
mulsd  %xmm8,%xmm2
addsd  %xmm2,%xmm1
addsd  %xmm5,%xmm2
mulsd  %xmm9,%xmm5
subsd  %xmm6,%xmm5
mulsd  %xmm7,%xmm3
addsd  %xmm5,%xmm3
addsd  %xmm0,%xmm4
ucomisd %xmm4,%xmm10
jb     1140 <getSplineCoeff+0x40>
xorpd  %xmm0,%xmm0
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @getSplineCoeff(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%12 = load double, double* %11
%13 = fcmp ole double %12, 1.000000e+00
br i1 %13, label %14, label %25
14: ; preds = %5
%15 = load double, double* %10
%16 = load double, double* %11
%17 = load double, double* %9
%18 = call double @llvm.fmuladd.f64(double %15, double %16, double %17)
%19 = load double, double* %11
%20 = load double, double* %8
%21 = call double @llvm.fmuladd.f64(double %18, double %19, double %20)
%22 = load double, double* %11
%23 = load double, double* %7
%24 = call double @llvm.fmuladd.f64(double %21, double %22, double %23)
store double %24, double* %6
br label %43
25: ; preds = %5
%26 = load double, double* %8
%27 = load double, double* %9
%28 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %27, double %26)
%29 = load double, double* %10
%30 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %29, double %28)
%31 = load double, double* %9
%32 = load double, double* %10
%33 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %32, double %31)
%34 = load double, double* %8
%35 = fneg double %34
%36 = load double, double* %9
%37 = call double @llvm.fmuladd.f64(double -3.000000e+00, double %36, double %35)
%38 = load double, double* %10
%39 = call double @llvm.fmuladd.f64(double -6.000000e+00, double %38, double %37)
%40 = load double, double* %11
%41 = fsub double %40, 1.000000e+00
%42 = call double @getSplineCoeff(double 0.000000e+00, double %30, double %33, double %39, double %41)
store double %42, double* %6
br label %43
43: ; preds = %25, %14
%44 = load double, double* %6
ret double %44
}

LLVM IR (-O2):
define double @getSplineCoeff(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp ugt double %4, 1.000000e+00
br i1 %6, label %16, label %7
7: ; preds = %16, %5
%8 = phi double [ %0, %5 ], [ 0.000000e+00, %16 ]
%9 = phi double [ %1, %5 ], [ %22, %16 ]
%10 = phi double [ %2, %5 ], [ %23, %16 ]
%11 = phi double [ %3, %5 ], [ %26, %16 ]
%12 = phi double [ %4, %5 ], [ %27, %16 ]
%13 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %10)
%14 = tail call double @llvm.fmuladd.f64(double %13, double %12, double %9)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %12, double %8)
ret double %15
16: ; preds = %5, %16
%17 = phi double [ %27, %16 ], [ %4, %5 ]
%18 = phi double [ %26, %16 ], [ %3, %5 ]
%19 = phi double [ %23, %16 ], [ %2, %5 ]
%20 = phi double [ %22, %16 ], [ %1, %5 ]
%21 = tail call double @llvm.fmuladd.f64(double %19, double 2.000000e+00, double %20)
%22 = tail call double @llvm.fmuladd.f64(double %18, double 3.000000e+00, double %21)
%23 = tail call double @llvm.fmuladd.f64(double %18, double 3.000000e+00, double %19)
%24 = fneg double %20
%25 = tail call double @llvm.fmuladd.f64(double %19, double -3.000000e+00, double %24)
%26 = tail call double @llvm.fmuladd.f64(double %18, double -6.000000e+00, double %25)
%27 = fadd double %17, -1.000000e+00
%28 = fcmp ugt double %27, 1.000000e+00
br i1 %28, label %16, label %7
}