#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 bspline(double x) {
  double xa, bval;
  xa = fabs(x);
  if ((xa >= 0) && (xa <= 1)) {
    bval = (2.0 / 3.0) + (pow(xa, 3.0) / 2.0) - pow(x, 2.0);
  } else {
    bval = pow(2.0 - xa, 3.0) / 6.0;
  }
  return (bval);
}


x86 assembly (clang, -O0):
<bspline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xed7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b1 <bspline+0xa1>
movsd  0xec4(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11b1 <bspline+0xa1>
movsd  -0x10(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xeb4(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xeb0(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11dc <bspline+0xcc>
movsd  0xe6f(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe45(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bspline>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xee0(%rip),%xmm0
andpd  %xmm2,%xmm0
ucomisd %xmm2,%xmm2
jp     116c <bspline+0x5c>
movsd  0xede(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     116c <bspline+0x5c>
movsd  0xee0(%rip),%xmm1
movapd %xmm2,(%rsp)
call   1030 <pow@plt>
mulsd  0xede(%rip),%xmm0
addsd  0xede(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xea4(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  0xea0(%rip),%xmm1
movapd %xmm2,%xmm0
call   1030 <pow@plt>
divsd  0xe97(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @bspline(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = call double @llvm.fabs.f64(double %5)
store double %6, double* %3
%7 = load double, double* %3
%8 = fcmp oge double %7, 0.000000e+00
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp ole double %10, 1.000000e+00
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load double, double* %3
%14 = call double @pow(double %13, double 3.000000e+00)
%15 = fdiv double %14, 2.000000e+00
%16 = fadd double 0x3FE5555555555555, %15
%17 = load double, double* %2
%18 = call double @pow(double %17, double 2.000000e+00)
%19 = fsub double %16, %18
store double %19, double* %4
br label %25
20: ; preds = %9, %1
%21 = load double, double* %3
%22 = fsub double 2.000000e+00, %21
%23 = call double @pow(double %22, double 3.000000e+00)
%24 = fdiv double %23, 6.000000e+00
store double %24, double* %4
br label %25
25: ; preds = %20, %12
%26 = load double, double* %4
ret double %26
}

LLVM IR (-O2):
define double @bspline(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 = select i1 %3, i1 %4, i1 false
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = tail call double @pow(double %2, double 3.000000e+00)
%8 = fmul double %7, 5.000000e-01
%9 = fadd double %8, 0x3FE5555555555555
%10 = fmul double %0, %0
%11 = fsub double %9, %10
br label %16
12: ; preds = %1
%13 = fsub double 2.000000e+00, %2
%14 = tail call double @pow(double %13, double 3.000000e+00)
%15 = fdiv double %14, 6.000000e+00
br label %16
16: ; preds = %12, %6
%17 = phi double [ %11, %6 ], [ %15, %12 ]
ret double %17
}