double interp2_k_cubic4(double x) {
  double result = 0.0;
  if ((x >= 0.0) && (x < 1.0)) {
    result = (x * x * x) - (2.0 * x * x) + 1.0;
  } else if ((x >= 1.0) && (x < 2.0)) {
    result = (-1.0 * x * x * x) + (5.0 * x * x) - (8.0 * x) + 4.0;
  }
  return result;
}


x86 assembly (clang, -O0):
<interp2_k_cubic4>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     118c <interp2_k_cubic4+0x8c>
movsd  0xed5(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118c <interp2_k_cubic4+0x8c>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xebb(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe82(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1212 <interp2_k_cubic4+0x112>
movsd  -0x8(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     120d <interp2_k_cubic4+0x10d>
movsd  0xe5d(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    120d <interp2_k_cubic4+0x10d>
movsd  0xe6a(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  0xe4b(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe24(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe0c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1212 <interp2_k_cubic4+0x112>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<interp2_k_cubic4>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1145 <interp2_k_cubic4+0x45>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1145 <interp2_k_cubic4+0x45>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xf00(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
addsd  0xec0(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xeb3(%rip),%xmm0
jb     1195 <interp2_k_cubic4+0x95>
movsd  0xeb1(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1195 <interp2_k_cubic4+0x95>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xea3(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm1
mulsd  0xe97(%rip),%xmm0
subsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
addsd  0xe8f(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

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

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