#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 _cubic_kernel(double x) {
  const double alpha = -0.5;
  x = fabs(x);
  double xx = x * x;
  if (x < 1.0) {
    return (alpha + 2) * xx * x - (alpha + 3) * xx + 1;
  }
  if (x < 2) {
    return (alpha * xx * x) - 5 * alpha * xx + 8 * alpha * x - 4 * alpha;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_cubic_kernel>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xef7(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xf1e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xebe(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a1 <_cubic_kernel+0xa1>
movsd  0xee3(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xec9(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <_cubic_kernel+0x125>
movsd  0xe67(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    121d <_cubic_kernel+0x11d>
movsd  0xe4c(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe5a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe21(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe09(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <_cubic_kernel+0x125>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cubic_kernel>:
movapd 0xef8(%rip),%xmm2
andpd  %xmm0,%xmm2
mulsd  %xmm0,%xmm0
movsd  0xef8(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1147 <_cubic_kernel+0x47>
movsd  0xf12(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xf0e(%rip),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  0xece(%rip),%xmm1
movapd %xmm1,%xmm0
ret
xorpd  %xmm1,%xmm1
movsd  0xec5(%rip),%xmm3
ucomisd %xmm2,%xmm3
jbe    118d <_cubic_kernel+0x8d>
movsd  0xebf(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0xebb(%rip),%xmm0
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
movsd  0xeb3(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
addsd  0xe8b(%rip),%xmm1
movapd %xmm1,%xmm0
ret

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

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