double interp2_k_quad3(double x) {
  double result = 0.0;
  if ((x >= 0.0) && (x < 0.5)) {
    result = (-2.0 * x * x) + 1.0;
  } else if ((x >= 0.5) && (x < 1.5)) {
    result = (x * x) - ((5.0 / 2.0) * x) + 1.5;
  }
  return result;
}


x86 assembly (clang, -O0):
<interp2_k_quad3>:
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     1162 <interp2_k_quad3+0x62>
movsd  0xed5(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1162 <interp2_k_quad3+0x62>
movsd  0xee2(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11d8 <interp2_k_quad3+0xd8>
movsd  -0x8(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11d3 <interp2_k_quad3+0xd3>
movsd  0xe87(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11d3 <interp2_k_quad3+0xd3>
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xe72(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11d8 <interp2_k_quad3+0xd8>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<interp2_k_quad3>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1135 <interp2_k_quad3+0x35>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1135 <interp2_k_quad3+0x35>
movsd  0xef8(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xef0(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xec3(%rip),%xmm0
jb     116d <interp2_k_quad3+0x6d>
movsd  0xec1(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    116d <interp2_k_quad3+0x6d>
movsd  0xebb(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe9f(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @interp2_k_quad3(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 %14
6: ; preds = %1
%7 = load double, double* %2
%8 = fcmp olt double %7, 5.000000e-01
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load double, double* %2
%11 = fmul double -2.000000e+00, %10
%12 = load double, double* %2
%13 = call double @llvm.fmuladd.f64(double %11, double %12, double 1.000000e+00)
store double %13, double* %3
br label %29
14: ; preds = %6, %1
%15 = load double, double* %2
%16 = fcmp oge double %15, 5.000000e-01
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load double, double* %2
%19 = fcmp olt double %18, 1.500000e+00
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load double, double* %2
%22 = load double, double* %2
%23 = load double, double* %2
%24 = fmul double 2.500000e+00, %23
%25 = fneg double %24
%26 = call double @llvm.fmuladd.f64(double %21, double %22, double %25)
%27 = fadd double %26, 1.500000e+00
store double %27, double* %3
br label %28
28: ; preds = %20, %17, %14
br label %29
29: ; preds = %28, %9
%30 = load double, double* %3
ret double %30
}

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