float spl(float x) {
  return x <= 0   ? 0.0
         : x <= 1 ? x * x * x / 6
         : x <= 2 ? (x * ((12 - 3 * x) * x - 12) + 4) / 6
         : x <= 3 ? (x * (x * (3 * x - 24) + 60) - 44) / 6
         : x <= 4 ? (x * ((12 - x) * x - 48) + 64) / 6
                  : 0.0;
}


x86 assembly (clang, -O0):
<spl>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1123 <spl+0x23>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12dc <spl+0x1dc>
movss  0xed5(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     115e <spl+0x5e>
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  0xec4(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12d2 <spl+0x1d2>
movss  0xe9e(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     11d1 <spl+0xd1>
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movss  0xeae(%rip),%xmm2
mulss  %xmm2,%xmm1
movss  0xe8e(%rip),%xmm2
addss  %xmm2,%xmm1
movss  -0x4(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe89(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe59(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe51(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12c8 <spl+0x1c8>
movss  0xe2f(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1244 <spl+0x144>
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
movss  0xe0e(%rip),%xmm3
mulss  %xmm3,%xmm2
movss  0xe22(%rip),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm1
movss  0xe0e(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xdfa(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xdde(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12be <spl+0x1be>
movss  0xdc0(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     12a7 <spl+0x1a7>
movss  -0x4(%rbp),%xmm0
movss  0xdb9(%rip),%xmm1
subss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xd9f(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xd8b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xd7b(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12b4 <spl+0x1b4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12b4 <spl+0x1b4>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<spl>:
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jae    11e0 <spl+0xe0>
movss  0xee9(%rip),%xmm2
ucomiss %xmm0,%xmm2
jae    116d <spl+0x6d>
movss  0xee4(%rip),%xmm2
ucomiss %xmm0,%xmm2
jae    117a <spl+0x7a>
movss  0xeeb(%rip),%xmm2
ucomiss %xmm0,%xmm2
jae    11a8 <spl+0xa8>
movss  0xeda(%rip),%xmm2
ucomiss %xmm0,%xmm2
jb     11e0 <spl+0xe0>
movss  0xec1(%rip),%xmm1
subss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  0xecd(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xec5(%rip),%xmm1
jmp    11d4 <spl+0xd4>
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
jmp    11d4 <spl+0xd4>
movss  0xe8a(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe82(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe7a(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe72(%rip),%xmm1
jmp    11d4 <spl+0xd4>
movss  0xe6c(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe64(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe5c(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe54(%rip),%xmm1
divss  0xe28(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @spl(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fcmp ole float %3, 0.000000e+00
br i1 %4, label %5, label %6
5: ; preds = %1
br label %62
6: ; preds = %1
%7 = load float, float* %2
%8 = fcmp ole float %7, 1.000000e+00
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load float, float* %2
%11 = load float, float* %2
%12 = fmul float %10, %11
%13 = load float, float* %2
%14 = fmul float %12, %13
%15 = fdiv float %14, 6.000000e+00
%16 = fpext float %15 to double
br label %60
17: ; preds = %6
%18 = load float, float* %2
%19 = fcmp ole float %18, 2.000000e+00
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load float, float* %2
%22 = load float, float* %2
%23 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %22, float 1.200000e+01)
%24 = load float, float* %2
%25 = call float @llvm.fmuladd.f32(float %23, float %24, float -1.200000e+01)
%26 = call float @llvm.fmuladd.f32(float %21, float %25, float 4.000000e+00)
%27 = fdiv float %26, 6.000000e+00
%28 = fpext float %27 to double
br label %58
29: ; preds = %17
%30 = load float, float* %2
%31 = fcmp ole float %30, 3.000000e+00
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load float, float* %2
%34 = load float, float* %2
%35 = load float, float* %2
%36 = call float @llvm.fmuladd.f32(float 3.000000e+00, float %35, float -2.400000e+01)
%37 = call float @llvm.fmuladd.f32(float %34, float %36, float 6.000000e+01)
%38 = call float @llvm.fmuladd.f32(float %33, float %37, float -4.400000e+01)
%39 = fdiv float %38, 6.000000e+00
%40 = fpext float %39 to double
br label %56
41: ; preds = %29
%42 = load float, float* %2
%43 = fcmp ole float %42, 4.000000e+00
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = load float, float* %2
%46 = load float, float* %2
%47 = fsub float 1.200000e+01, %46
%48 = load float, float* %2
%49 = call float @llvm.fmuladd.f32(float %47, float %48, float -4.800000e+01)
%50 = call float @llvm.fmuladd.f32(float %45, float %49, float 6.400000e+01)
%51 = fdiv float %50, 6.000000e+00
%52 = fpext float %51 to double
br label %54
53: ; preds = %41
br label %54
54: ; preds = %53, %44
%55 = phi double [ %52, %44 ], [ 0.000000e+00, %53 ]
br label %56
56: ; preds = %54, %32
%57 = phi double [ %40, %32 ], [ %55, %54 ]
br label %58
58: ; preds = %56, %20
%59 = phi double [ %28, %20 ], [ %57, %56 ]
br label %60
60: ; preds = %58, %9
%61 = phi double [ %16, %9 ], [ %59, %58 ]
br label %62
62: ; preds = %60, %5
%63 = phi double [ 0.000000e+00, %5 ], [ %61, %60 ]
%64 = fptrunc double %63 to float
ret float %64
}

LLVM IR (-O2):
define float @spl(float %0) {
%2 = fcmp ugt float %0, 0.000000e+00
br i1 %2, label %3, label %34
3: ; preds = %1
%4 = fcmp ugt float %0, 1.000000e+00
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = fmul float %0, %0
%7 = fmul float %6, %0
%8 = fdiv float %7, 6.000000e+00
%9 = fpext float %8 to double
br label %34
10: ; preds = %3
%11 = fcmp ugt float %0, 2.000000e+00
br i1 %11, label %18, label %12
12: ; preds = %10
%13 = tail call float @llvm.fmuladd.f32(float %0, float -3.000000e+00, float 1.200000e+01)
%14 = tail call float @llvm.fmuladd.f32(float %13, float %0, float -1.200000e+01)
%15 = tail call float @llvm.fmuladd.f32(float %0, float %14, float 4.000000e+00)
%16 = fdiv float %15, 6.000000e+00
%17 = fpext float %16 to double
br label %34
18: ; preds = %10
%19 = fcmp ugt float %0, 3.000000e+00
br i1 %19, label %26, label %20
20: ; preds = %18
%21 = tail call float @llvm.fmuladd.f32(float %0, float 3.000000e+00, float -2.400000e+01)
%22 = tail call float @llvm.fmuladd.f32(float %0, float %21, float 6.000000e+01)
%23 = tail call float @llvm.fmuladd.f32(float %0, float %22, float -4.400000e+01)
%24 = fdiv float %23, 6.000000e+00
%25 = fpext float %24 to double
br label %34
26: ; preds = %18
%27 = fcmp ugt float %0, 4.000000e+00
br i1 %27, label %34, label %28
28: ; preds = %26
%29 = fsub float 1.200000e+01, %0
%30 = tail call float @llvm.fmuladd.f32(float %29, float %0, float -4.800000e+01)
%31 = tail call float @llvm.fmuladd.f32(float %0, float %30, float 6.400000e+01)
%32 = fdiv float %31, 6.000000e+00
%33 = fpext float %32 to double
br label %34
34: ; preds = %5, %20, %26, %28, %12, %1
%35 = phi double [ 0.000000e+00, %1 ], [ %9, %5 ], [ %17, %12 ], [ %25, %20 ], [ %33, %28 ], [ 0.000000e+00, %26 ]
%36 = fptrunc double %35 to float
ret float %36
}