double interp2_k_lagrange4(double x) {
  double result = 0.0;
  if ((x >= 0.0) & (x < 1.0)) {
    result = ((1.0 / 2.0) * x * x * x) + ((-2.0 / 2.0) * x * x) +
             ((-1.0 / 2.0) * x) + 1.0;
  } else if ((x >= 1.0) & (x < 2.0)) {
    result = ((-1.0 / 6.0) * x * x * x) + ((6.0 / 6.0) * x * x) +
             ((-11.0 / 6.0) * x) + 1.0;
  }
  return result;
}


x86 assembly (clang, -O0):
<interp2_k_lagrange4>:
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
setae  %al
and    $0x1,%al
movzbl %al,%eax
movsd  0xed3(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11a2 <interp2_k_lagrange4+0xa2>
movsd  0xee2(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  0xec3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe9c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1238 <interp2_k_lagrange4+0x138>
movsd  -0x8(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
movsd  0xe45(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1233 <interp2_k_lagrange4+0x133>
movsd  0xe34(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  0xe05(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xdf6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdd6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1238 <interp2_k_lagrange4+0x138>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<interp2_k_lagrange4>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1142 <interp2_k_lagrange4+0x42>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1142 <interp2_k_lagrange4+0x42>
movsd  0xf00(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm1
mulsd  0xeec(%rip),%xmm0
subsd  %xmm2,%xmm1
jmp    1182 <interp2_k_lagrange4+0x82>
ucomisd 0xeb6(%rip),%xmm0
jb     1192 <interp2_k_lagrange4+0x92>
movsd  0xeb4(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1192 <interp2_k_lagrange4+0x92>
movsd  0xeae(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm1
mulsd  0xe9a(%rip),%xmm0
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  0xe72(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @interp2_k_lagrange4(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
%6 = zext i1 %5 to i32
%7 = load double, double* %2
%8 = fcmp olt double %7, 1.000000e+00
%9 = zext i1 %8 to i32
%10 = and i32 %6, %9
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %1
%13 = load double, double* %2
%14 = fmul double 5.000000e-01, %13
%15 = load double, double* %2
%16 = fmul double %14, %15
%17 = load double, double* %2
%18 = load double, double* %2
%19 = fmul double -1.000000e+00, %18
%20 = load double, double* %2
%21 = fmul double %19, %20
%22 = call double @llvm.fmuladd.f64(double %16, double %17, double %21)
%23 = load double, double* %2
%24 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %23, double %22)
%25 = fadd double %24, 1.000000e+00
store double %25, double* %3
br label %50
26: ; preds = %1
%27 = load double, double* %2
%28 = fcmp oge double %27, 1.000000e+00
%29 = zext i1 %28 to i32
%30 = load double, double* %2
%31 = fcmp olt double %30, 2.000000e+00
%32 = zext i1 %31 to i32
%33 = and i32 %29, %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %26
%36 = load double, double* %2
%37 = fmul double 0xBFC5555555555555, %36
%38 = load double, double* %2
%39 = fmul double %37, %38
%40 = load double, double* %2
%41 = load double, double* %2
%42 = fmul double 1.000000e+00, %41
%43 = load double, double* %2
%44 = fmul double %42, %43
%45 = call double @llvm.fmuladd.f64(double %39, double %40, double %44)
%46 = load double, double* %2
%47 = call double @llvm.fmuladd.f64(double 0xBFFD555555555555, double %46, double %45)
%48 = fadd double %47, 1.000000e+00
store double %48, double* %3
br label %49
49: ; preds = %35, %26
br label %50
50: ; preds = %49, %12
%51 = load double, double* %3
ret double %51
}

LLVM IR (-O2):
define double @interp2_k_lagrange4(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 %13
5: ; preds = %1
%6 = fmul double %0, 5.000000e-01
%7 = fmul double %6, %0
%8 = fneg double %0
%9 = fmul double %8, %0
%10 = tail call double @llvm.fmuladd.f64(double %7, double %0, double %9)
%11 = tail call double @llvm.fmuladd.f64(double %0, double -5.000000e-01, double %10)
%12 = fadd double %11, 1.000000e+00
br label %24
13: ; preds = %1
%14 = fcmp oge double %0, 1.000000e+00
%15 = fcmp olt double %0, 2.000000e+00
%16 = and i1 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = fmul double %0, 0xBFC5555555555555
%19 = fmul double %18, %0
%20 = fmul double %0, %0
%21 = tail call double @llvm.fmuladd.f64(double %19, double %0, double %20)
%22 = tail call double @llvm.fmuladd.f64(double %0, double 0xBFFD555555555555, double %21)
%23 = fadd double %22, 1.000000e+00
br label %24
24: ; preds = %13, %17, %5
%25 = phi double [ %12, %5 ], [ %23, %17 ], [ 0.000000e+00, %13 ]
ret double %25
}