#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fabs(double);
double k_bicub(double x, double a) {
  x = fabs(x);
  if (x <= 1.0)
    return (a + 2.0) * x * x * x - (a + 3.0) * x * x + 1.0;
  else if (x < 2.0)
    return a * x * x * x - 5.0 * a * x * x + 8.0 * a * x - 4.0 * a;
  else
    return 0.0;
}


x86 assembly (clang, -O0):
<k_bicub>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xf16(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     119e <k_bicub+0x9e>
movsd  0xeca(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xece(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe70(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <k_bicub+0x13c>
movsd  0xe62(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1234 <k_bicub+0x134>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xe53(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe15(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xdee(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <k_bicub+0x13c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<k_bicub>:
andpd  0xef8(%rip),%xmm0
movsd  0xf00(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    1179 <k_bicub+0x79>
xorpd  %xmm2,%xmm2
movsd  0xef6(%rip),%xmm3
ucomisd %xmm0,%xmm3
jbe    11ad <k_bicub+0xad>
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xee8(%rip),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
movsd  0xed4(%rip),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
mulsd  0xec8(%rip),%xmm1
addsd  %xmm3,%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xe97(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe8b(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  0xe63(%rip),%xmm2
movapd %xmm2,%xmm0
ret

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

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