double bSplineFilter(double t) {
  double tt;
  if (t < 0.0)
    t = -t;
  if (t < 1.0) {
    tt = t * t;
    return ((0.5 * tt * t) - tt + (2.0 / 3.0));
  } else if (t < 2.0) {
    t = 2.0 - t;
    return ((1.0 / 6.0) * (t * t * t));
  }
  return 0.0;
}


x86 assembly (clang, -O0):
<bSplineFilter>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1138 <bSplineFilter+0x38>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec0(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a6 <bSplineFilter+0xa6>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebe(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe80(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fd <bSplineFilter+0xfd>
movsd  0xe5a(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f0 <bSplineFilter+0xf0>
movsd  0xe47(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe2e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fd <bSplineFilter+0xfd>
jmp    11f5 <bSplineFilter+0xf5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<bSplineFilter>:
movapd %xmm0,%xmm1
movapd 0xef4(%rip),%xmm3
xorpd  %xmm0,%xmm3
xorpd  %xmm0,%xmm0
movapd %xmm1,%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm3
andnpd %xmm1,%xmm2
orpd   %xmm3,%xmm2
movsd  0xedf(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    115c <bSplineFilter+0x5c>
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xee1(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
addsd  0xed5(%rip),%xmm0
ret
movsd  0xeb4(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1182 <bSplineFilter+0x82>
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe9e(%rip),%xmm0
ret

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

LLVM IR (-O2):
define double @bSplineFilter(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp olt double %4, 1.000000e+00
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = fmul double %4, %4
%8 = fmul double %7, 5.000000e-01
%9 = fneg double %7
%10 = tail call double @llvm.fmuladd.f64(double %8, double %4, double %9)
%11 = fadd double %10, 0x3FE5555555555555
br label %19
12: ; preds = %1
%13 = fcmp olt double %4, 2.000000e+00
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = fsub double 2.000000e+00, %4
%16 = fmul double %15, %15
%17 = fmul double %15, %16
%18 = fmul double %17, 0x3FC5555555555555
br label %19
19: ; preds = %12, %14, %6
%20 = phi double [ %11, %6 ], [ %18, %14 ], [ 0.000000e+00, %12 ]
ret double %20
}