long double cubic(long double b, long double c, long double x) {
  if (x < 1.0l) {
    return ((12.0l - 9.0l * b - 6.0l * c) * x * x * x +
            (-18.0l + 12.0l * b + 6.0l * c) * x * x + (6.0l - 2.0l * b)) /
           6.0l;
  }
  if (x < 2.0l) {
    return ((-b - 6.0l * c) * x * x * x + (6.0l * b + 30.0l * c) * x * x +
            (-12.0l * b - 48.0l * c) * x + (8.0l * b + 24.0l * c)) /
           6.0l;
  }
  return 0.0;
}


x86 assembly (clang, -O0):
<cubic>:
push   %rbp
mov    %rsp,%rbp
fldt   0x30(%rbp)
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fld1
fucomip %st(1),%st
fstp   %st(0)
jbe    1187 <cubic+0x87>
jmp    112a <cubic+0x2a>
fldt   -0x20(%rbp)
flds   0xeed(%rip)
fmul   %st(1),%st
flds   0xee9(%rip)
fadd   %st,%st(1)
fldt   -0x30(%rbp)
flds   0xebe(%rip)
fmul   %st(1),%st
faddp  %st,%st(3)
fldt   -0x40(%rbp)
fmul   %st,%st(3)
fmul   %st,%st(3)
fxch   %st(2)
fmul   %st(4),%st
flds   0xecd(%rip)
faddp  %st,%st(1)
flds   0xea9(%rip)
fmul   %st,%st(2)
fxch   %st(2)
faddp  %st,%st(1)
fmul   %st(2),%st
fmul   %st(2),%st
fxch   %st(3)
fmulp  %st,%st(2)
fxch   %st(1)
faddp  %st,%st(2)
fxch   %st(2)
fadd   %st,%st(0)
fsubr  %st(2),%st
faddp  %st,%st(1)
fdivp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1213 <cubic+0x113>
fldt   -0x40(%rbp)
flds   0xe70(%rip)
fucomip %st(1),%st
fstp   %st(0)
jbe    120e <cubic+0x10e>
jmp    119f <cubic+0x9f>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
flds   0xe59(%rip)
fmul   %st(1),%st
fsub   %st(2),%st
fldt   -0x40(%rbp)
fmul   %st,%st(1)
fmul   %st,%st(1)
flds   0xe4c(%rip)
fmul   %st(3),%st
flds   0xe48(%rip)
fld    %st(5)
fmul   %st(1),%st
faddp  %st,%st(2)
fxch   %st(1)
fmul   %st(2),%st
fmul   %st(2),%st
fxch   %st(3)
fmul   %st(2),%st
faddp  %st,%st(3)
flds   0xe34(%rip)
fmul   %st(4),%st
flds   0xe30(%rip)
fmul   %st(6),%st
faddp  %st,%st(1)
fmulp  %st,%st(2)
fxch   %st(1)
faddp  %st,%st(2)
flds   0xe24(%rip)
fmulp  %st,%st(3)
flds   0xe20(%rip)
fmulp  %st,%st(4)
fxch   %st(3)
faddp  %st,%st(2)
faddp  %st,%st(1)
fdivp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1213 <cubic+0x113>
fldz
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubic>:
fldt   0x28(%rsp)
fldt   0x18(%rsp)
fldt   0x8(%rsp)
fld1
fucomip %st(3),%st
jbe    1160 <cubic+0x60>
fld    %st(0)
fmuls  0xf06(%rip)
flds   0xf04(%rip)
fadd   %st,%st(1)
fld    %st(3)
fmuls  0xeda(%rip)
faddp  %st,%st(2)
fxch   %st(1)
fmul   %st(4),%st
fxch   %st(1)
fmul   %st(2),%st
fadds  0xeee(%rip)
fxch   %st(1)
fmul   %st(4),%st
flds   0xec8(%rip)
fmul   %st,%st(4)
fxch   %st(4)
faddp  %st,%st(2)
fxch   %st(1)
fmul   %st(4),%st
fmul   %st(4),%st
fxch   %st(1)
fmulp  %st,%st(4)
faddp  %st,%st(3)
fadd   %st,%st(0)
fsubr  %st(1),%st
faddp  %st,%st(2)
fdivrp %st,%st(1)
jmp    11d2 <cubic+0xd2>
fldz
flds   0xe98(%rip)
fucomip %st(4),%st
fxch   %st(3)
fxch   %st(1)
fxch   %st(2)
jbe    11d8 <cubic+0xd8>
fstp   %st(3)
fld    %st(2)
fmuls  0xe88(%rip)
fsub   %st(2),%st
fmul   %st(1),%st
fmul   %st(1),%st
fld    %st(3)
fmuls  0xe7e(%rip)
flds   0xe7c(%rip)
fld    %st(4)
fmul   %st(1),%st
faddp  %st,%st(2)
fxch   %st(1)
fmul   %st(3),%st
fmul   %st(3),%st
fxch   %st(2)
fmul   %st(3),%st
faddp  %st,%st(2)
fld    %st(4)
fmuls  0xe66(%rip)
fld    %st(4)
fmuls  0xe62(%rip)
faddp  %st,%st(1)
fmulp  %st,%st(3)
fxch   %st(4)
fmuls  0xe5a(%rip)
fxch   %st(3)
fmuls  0xe56(%rip)
fxch   %st(2)
faddp  %st,%st(1)
fxch   %st(1)
faddp  %st,%st(2)
faddp  %st,%st(1)
fdivp  %st,%st(1)
fldz
fldz
fldz
fstp   %st(2)
fstp   %st(0)
fstp   %st(0)
ret

LLVM IR (-O0):
define x86_fp80 @cubic(x86_fp80 %0, x86_fp80 %1, x86_fp80 %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %5
store x86_fp80 %1, x86_fp80* %6
store x86_fp80 %2, x86_fp80* %7
%8 = load x86_fp80, x86_fp80* %7
%9 = fcmp olt x86_fp80 %8, 0xK3FFF8000000000000000
br i1 %9, label %10, label %33
10: ; preds = %3
%11 = load x86_fp80, x86_fp80* %5
%12 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xKC0029000000000000000, x86_fp80 %11, x86_fp80 0xK4002C000000000000000)
%13 = load x86_fp80, x86_fp80* %6
%14 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xKC001C000000000000000, x86_fp80 %13, x86_fp80 %12)
%15 = load x86_fp80, x86_fp80* %7
%16 = fmul x86_fp80 %14, %15
%17 = load x86_fp80, x86_fp80* %7
%18 = fmul x86_fp80 %16, %17
%19 = load x86_fp80, x86_fp80* %7
%20 = load x86_fp80, x86_fp80* %5
%21 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK4002C000000000000000, x86_fp80 %20, x86_fp80 0xKC0039000000000000000)
%22 = load x86_fp80, x86_fp80* %6
%23 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK4001C000000000000000, x86_fp80 %22, x86_fp80 %21)
%24 = load x86_fp80, x86_fp80* %7
%25 = fmul x86_fp80 %23, %24
%26 = load x86_fp80, x86_fp80* %7
%27 = fmul x86_fp80 %25, %26
%28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 %19, x86_fp80 %27)
%29 = load x86_fp80, x86_fp80* %5
%30 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xKC0008000000000000000, x86_fp80 %29, x86_fp80 0xK4001C000000000000000)
%31 = fadd x86_fp80 %28, %30
%32 = fdiv x86_fp80 %31, 0xK4001C000000000000000
store x86_fp80 %32, x86_fp80* %4
br label %69
33: ; preds = %3
%34 = load x86_fp80, x86_fp80* %7
%35 = fcmp olt x86_fp80 %34, 0xK40008000000000000000
br i1 %35, label %36, label %68
36: ; preds = %33
%37 = load x86_fp80, x86_fp80* %5
%38 = fneg x86_fp80 %37
%39 = load x86_fp80, x86_fp80* %6
%40 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xKC001C000000000000000, x86_fp80 %39, x86_fp80 %38)
%41 = load x86_fp80, x86_fp80* %7
%42 = fmul x86_fp80 %40, %41
%43 = load x86_fp80, x86_fp80* %7
%44 = fmul x86_fp80 %42, %43
%45 = load x86_fp80, x86_fp80* %7
%46 = load x86_fp80, x86_fp80* %5
%47 = load x86_fp80, x86_fp80* %6
%48 = fmul x86_fp80 0xK4003F000000000000000, %47
%49 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK4001C000000000000000, x86_fp80 %46, x86_fp80 %48)
%50 = load x86_fp80, x86_fp80* %7
%51 = fmul x86_fp80 %49, %50
%52 = load x86_fp80, x86_fp80* %7
%53 = fmul x86_fp80 %51, %52
%54 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %44, x86_fp80 %45, x86_fp80 %53)
%55 = load x86_fp80, x86_fp80* %5
%56 = load x86_fp80, x86_fp80* %6
%57 = fmul x86_fp80 0xK4004C000000000000000, %56
%58 = fneg x86_fp80 %57
%59 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xKC002C000000000000000, x86_fp80 %55, x86_fp80 %58)
%60 = load x86_fp80, x86_fp80* %7
%61 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %59, x86_fp80 %60, x86_fp80 %54)
%62 = load x86_fp80, x86_fp80* %5
%63 = load x86_fp80, x86_fp80* %6
%64 = fmul x86_fp80 0xK4003C000000000000000, %63
%65 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40028000000000000000, x86_fp80 %62, x86_fp80 %64)
%66 = fadd x86_fp80 %61, %65
%67 = fdiv x86_fp80 %66, 0xK4001C000000000000000
store x86_fp80 %67, x86_fp80* %4
br label %69
68: ; preds = %33
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
br label %69
69: ; preds = %68, %36, %10
%70 = load x86_fp80, x86_fp80* %4
ret x86_fp80 %70
}

LLVM IR (-O2):
define x86_fp80 @cubic(x86_fp80 %0, x86_fp80 %1, x86_fp80 %2) {
%4 = fcmp olt x86_fp80 %2, 0xK3FFF8000000000000000
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xKC0029000000000000000, x86_fp80 0xK4002C000000000000000)
%7 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %1, x86_fp80 0xKC001C000000000000000, x86_fp80 %6)
%8 = fmul x86_fp80 %7, %2
%9 = fmul x86_fp80 %8, %2
%10 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xK4002C000000000000000, x86_fp80 0xKC0039000000000000000)
%11 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %1, x86_fp80 0xK4001C000000000000000, x86_fp80 %10)
%12 = fmul x86_fp80 %11, %2
%13 = fmul x86_fp80 %12, %2
%14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %9, x86_fp80 %2, x86_fp80 %13)
%15 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xKC0008000000000000000, x86_fp80 0xK4001C000000000000000)
%16 = fadd x86_fp80 %15, %14
%17 = fdiv x86_fp80 %16, 0xK4001C000000000000000
br label %37
18: ; preds = %3
%19 = fcmp olt x86_fp80 %2, 0xK40008000000000000000
br i1 %19, label %20, label %37
20: ; preds = %18
%21 = fneg x86_fp80 %0
%22 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %1, x86_fp80 0xKC001C000000000000000, x86_fp80 %21)
%23 = fmul x86_fp80 %22, %2
%24 = fmul x86_fp80 %23, %2
%25 = fmul x86_fp80 %1, 0xK4003F000000000000000
%26 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xK4001C000000000000000, x86_fp80 %25)
%27 = fmul x86_fp80 %26, %2
%28 = fmul x86_fp80 %27, %2
%29 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %24, x86_fp80 %2, x86_fp80 %28)
%30 = fmul x86_fp80 %1, 0xKC004C000000000000000
%31 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xKC002C000000000000000, x86_fp80 %30)
%32 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 %2, x86_fp80 %29)
%33 = fmul x86_fp80 %1, 0xK4003C000000000000000
%34 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 0xK40028000000000000000, x86_fp80 %33)
%35 = fadd x86_fp80 %34, %32
%36 = fdiv x86_fp80 %35, 0xK4001C000000000000000
br label %37
37: ; preds = %18, %20, %5
%38 = phi x86_fp80 [ %17, %5 ], [ %36, %20 ], [ 0xK00000000000000000000, %18 ]
ret x86_fp80 %38
}