double _libtcas_filter_BSpline(double x) {
  if (x < -2)
    return 0;
  else if (x < -1)
    return (2 + x) * (2 + x) * (2 + x) / 6.0;
  else if (x < 0)
    return (4 + (-6 - 3 * x) * x * x) / 6.0;
  else if (x < 1)
    return (4 + (-6 + 3 * x) * x * x) / 6.0;
  else if (x < 2)
    return (2 - x) * (2 - x) * (2 - x) / 6.0;
  else
    return 0;
}


x86 assembly (clang, -O0):
<_libtcas_filter_BSpline>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xeef(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1129 <_libtcas_filter_BSpline+0x29>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129c <_libtcas_filter_BSpline+0x19c>
movsd  0xed7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1181 <_libtcas_filter_BSpline+0x81>
movsd  0xed4(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb6(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xead(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129c <_libtcas_filter_BSpline+0x19c>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11dc <_libtcas_filter_BSpline+0xdc>
movsd  -0x10(%rbp),%xmm0
movsd  0xea4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe90(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe66(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129c <_libtcas_filter_BSpline+0x19c>
movsd  0xe2c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    123c <_libtcas_filter_BSpline+0x13c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe30(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe06(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129c <_libtcas_filter_BSpline+0x19c>
movsd  0xdd4(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1294 <_libtcas_filter_BSpline+0x194>
movsd  0xdc1(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xdb4(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda3(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129c <_libtcas_filter_BSpline+0x19c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_libtcas_filter_BSpline>:
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  0xef0(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     1188 <_libtcas_filter_BSpline+0x88>
movsd  0xeea(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    113a <_libtcas_filter_BSpline+0x3a>
addsd  0xeec(%rip),%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
jmp    1180 <_libtcas_filter_BSpline+0x80>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    114e <_libtcas_filter_BSpline+0x4e>
movsd  0xef4(%rip),%xmm0
jmp    1164 <_libtcas_filter_BSpline+0x64>
movsd  0xeba(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1189 <_libtcas_filter_BSpline+0x89>
movsd  0xec4(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xec0(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xeb8(%rip),%xmm0
divsd  0xe98(%rip),%xmm0
ret
xorpd  %xmm0,%xmm0
movsd  0xe83(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1188 <_libtcas_filter_BSpline+0x88>
subsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
jmp    1180 <_libtcas_filter_BSpline+0x80>

LLVM IR (-O0):
define double @_libtcas_filter_BSpline(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp olt double %4, -2.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store double 0.000000e+00, double* %2
br label %56
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp olt double %8, -1.000000e+00
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load double, double* %3
%12 = fadd double 2.000000e+00, %11
%13 = load double, double* %3
%14 = fadd double 2.000000e+00, %13
%15 = fmul double %12, %14
%16 = load double, double* %3
%17 = fadd double 2.000000e+00, %16
%18 = fmul double %15, %17
%19 = fdiv double %18, 6.000000e+00
store double %19, double* %2
br label %56
20: ; preds = %7
%21 = load double, double* %3
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double -3.000000e+00, double %24, double -6.000000e+00)
%26 = load double, double* %3
%27 = fmul double %25, %26
%28 = load double, double* %3
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 4.000000e+00)
%30 = fdiv double %29, 6.000000e+00
store double %30, double* %2
br label %56
31: ; preds = %20
%32 = load double, double* %3
%33 = fcmp olt double %32, 1.000000e+00
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load double, double* %3
%36 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %35, double -6.000000e+00)
%37 = load double, double* %3
%38 = fmul double %36, %37
%39 = load double, double* %3
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double 4.000000e+00)
%41 = fdiv double %40, 6.000000e+00
store double %41, double* %2
br label %56
42: ; preds = %31
%43 = load double, double* %3
%44 = fcmp olt double %43, 2.000000e+00
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = load double, double* %3
%47 = fsub double 2.000000e+00, %46
%48 = load double, double* %3
%49 = fsub double 2.000000e+00, %48
%50 = fmul double %47, %49
%51 = load double, double* %3
%52 = fsub double 2.000000e+00, %51
%53 = fmul double %50, %52
%54 = fdiv double %53, 6.000000e+00
store double %54, double* %2
br label %56
55: ; preds = %42
store double 0.000000e+00, double* %2
br label %56
56: ; preds = %55, %45, %34, %23, %10, %6
%57 = load double, double* %2
ret double %57
}

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