float catrom(float x) {
  if (x > 2) {
    return 0;
  }
  if (x < 1) {
    return (1.5f * x - 2.5f) * x * x + 1;
  }
  return (((5 - x) * x - 8) * x + 4) / 2;
}


x86 assembly (clang, -O0):
<catrom>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xeea(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    112c <catrom+0x2c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <catrom+0xc7>
movss  0xed0(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    117f <catrom+0x7f>
movss  -0x8(%rbp),%xmm0
movss  0xec9(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xec1(%rip),%xmm1
addss  %xmm1,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe93(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <catrom+0xc7>
movss  0xe89(%rip),%xmm0
subss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe6f(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe56(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe42(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<catrom>:
xorps  %xmm1,%xmm1
ucomiss 0xef6(%rip),%xmm0
ja     116d <catrom+0x6d>
movss  0xef0(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1141 <catrom+0x41>
movss  0xef7(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xeef(%rip),%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  0xec7(%rip),%xmm1
movaps %xmm1,%xmm0
ret
movss  0xebf(%rip),%xmm1
subss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  0xeb3(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xeab(%rip),%xmm1
mulss  0xea7(%rip),%xmm1
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @catrom(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = fcmp ogt float %4, 2.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store float 0.000000e+00, float* %2
br label %25
7: ; preds = %1
%8 = load float, float* %3
%9 = fcmp olt float %8, 1.000000e+00
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load float, float* %3
%12 = call float @llvm.fmuladd.f32(float 1.500000e+00, float %11, float -2.500000e+00)
%13 = load float, float* %3
%14 = fmul float %12, %13
%15 = load float, float* %3
%16 = call float @llvm.fmuladd.f32(float %14, float %15, float 1.000000e+00)
store float %16, float* %2
br label %25
17: ; preds = %7
%18 = load float, float* %3
%19 = fsub float 5.000000e+00, %18
%20 = load float, float* %3
%21 = call float @llvm.fmuladd.f32(float %19, float %20, float -8.000000e+00)
%22 = load float, float* %3
%23 = call float @llvm.fmuladd.f32(float %21, float %22, float 4.000000e+00)
%24 = fdiv float %23, 2.000000e+00
store float %24, float* %2
br label %25
25: ; preds = %17, %10, %6
%26 = load float, float* %2
ret float %26
}

LLVM IR (-O2):
define float @catrom(float %0) {
%2 = fcmp ogt float %0, 2.000000e+00
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = fcmp olt float %0, 1.000000e+00
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = tail call float @llvm.fmuladd.f32(float %0, float 1.500000e+00, float -2.500000e+00)
%7 = fmul float %6, %0
%8 = tail call float @llvm.fmuladd.f32(float %7, float %0, float 1.000000e+00)
br label %14
9: ; preds = %3
%10 = fsub float 5.000000e+00, %0
%11 = tail call float @llvm.fmuladd.f32(float %10, float %0, float -8.000000e+00)
%12 = tail call float @llvm.fmuladd.f32(float %11, float %0, float 4.000000e+00)
%13 = fmul float %12, 5.000000e-01
br label %14
14: ; preds = %1, %9, %5
%15 = phi float [ %8, %5 ], [ %13, %9 ], [ 0.000000e+00, %1 ]
ret float %15
}