#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 pow(double, double);
double cubicon(double x) {
  double xa, bval;
  double ca = -0.5;
  xa = fabs(x);
  if ((xa >= 0) && (xa <= 1)) {
    bval = ((ca + 2.0) * pow(xa, 3.0)) - ((ca + 3.0) * pow(xa, 2.0)) + 1.0;
  } else {
    bval = (ca * pow(xa, 3.0)) - (5.0 * ca * pow(xa, 2.0)) + (8.0 * ca * xa) -
           (4.0 * ca);
  }
  return (bval);
}


x86 assembly (clang, -O0):
<cubicon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xeca(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11fc <cubicon+0xec>
movsd  0xebf(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11fc <cubicon+0xec>
movsd  0xec4(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xeab(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe2a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12aa <cubicon+0x19a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe2d(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xe13(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdaa(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xd83(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubicon>:
sub    $0x28,%rsp
movapd %xmm0,0x10(%rsp)
movapd 0xede(%rip),%xmm2
andpd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
movsd  0xedd(%rip),%xmm1
movapd %xmm2,%xmm0
call   1030 <pow@plt>
movapd 0x10(%rsp),%xmm3
movapd (%rsp),%xmm2
ucomisd %xmm3,%xmm3
mulsd  %xmm3,%xmm3
jp     1181 <cubicon+0x71>
movsd  0xebf(%rip),%xmm1
ucomisd %xmm2,%xmm1
jb     1181 <cubicon+0x71>
mulsd  0xed9(%rip),%xmm3
mulsd  0xed9(%rip),%xmm0
addsd  %xmm3,%xmm0
addsd  0xe9d(%rip),%xmm0
movapd %xmm0,%xmm2
jmp    11a9 <cubicon+0x99>
mulsd  0xe97(%rip),%xmm3
mulsd  0xe97(%rip),%xmm0
mulsd  0xe97(%rip),%xmm2
addsd  %xmm3,%xmm0
addsd  %xmm0,%xmm2
addsd  0xe8f(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

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

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