#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_weight(double x, double a, double b) {
  double v = fabs(x);
  double q = 0.0;
  if (v < 1) {
    q = (-6 * a - 9 * b + 12) * v * v * v + (6 * a + 12 * b - 18) * v * v -
        2 * b + 6;
  } else if (v < 2) {
    q = (-6 * a - b) * v * v * v + (30 * a + 6 * b) * v * v +
        (-48 * a - 12 * b) * v + 24 * a + 8 * b;
  }
  return 1.0 / 6.0 * q;
}


x86 assembly (clang, -O0):
<cubic_weight>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xf41(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec8(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11fa <cubic_weight+0xfa>
movsd  -0x10(%rbp),%xmm0
movsd  0xf00(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xecc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xea4(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
movsd  0xe84(%rip),%xmm3
mulsd  -0x18(%rbp),%xmm3
movsd  0xe87(%rip),%xmm4
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
movsd  0xe87(%rip),%xmm3
subsd  %xmm3,%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe4c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12fb <cubic_weight+0x1fb>
movsd  0xe06(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12f6 <cubic_weight+0x1f6>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe0a(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
movsd  0xdde(%rip),%xmm3
mulsd  -0x18(%rbp),%xmm3
movsd  0xdc9(%rip),%xmm4
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xd9a(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xd6e(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xd44(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xd27(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12fb <cubic_weight+0x1fb>
movsd  0xd55(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubic_weight>:
andpd  0xef8(%rip),%xmm0
movsd  0xf00(%rip),%xmm3
ucomisd %xmm0,%xmm3
jbe    1183 <cubic_weight+0x83>
movsd  0xf3a(%rip),%xmm4
mulsd  %xmm2,%xmm4
movsd  0xef6(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
movsd  0xf26(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm2,%xmm4
movsd  0xeda(%rip),%xmm5
mulsd  %xmm5,%xmm1
addsd  %xmm4,%xmm1
addsd  0xf0a(%rip),%xmm1
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm3
addsd  %xmm5,%xmm3
jmp    121d <cubic_weight+0x11d>
xorpd  %xmm3,%xmm3
movsd  0xe89(%rip),%xmm4
ucomisd %xmm0,%xmm4
jbe    121d <cubic_weight+0x11d>
movsd  0xe7f(%rip),%xmm3
mulsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movsd  0xe6f(%rip),%xmm4
mulsd  %xmm2,%xmm4
movsd  0xe6b(%rip),%xmm5
mulsd  %xmm1,%xmm5
addsd  %xmm4,%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm0,%xmm3
addsd  %xmm5,%xmm3
movsd  0xe53(%rip),%xmm4
mulsd  %xmm2,%xmm4
movsd  0xe4f(%rip),%xmm5
mulsd  %xmm1,%xmm5
addsd  %xmm4,%xmm5
mulsd  %xmm0,%xmm5
addsd  %xmm3,%xmm5
mulsd  0xe3f(%rip),%xmm1
addsd  %xmm5,%xmm1
mulsd  0xe3b(%rip),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
mulsd  0xe4b(%rip),%xmm3
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @cubic_weight(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %4
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %7
store double 0.000000e+00, double* %8
%11 = load double, double* %7
%12 = fcmp olt double %11, 1.000000e+00
br i1 %12, label %13, label %38
13: ; preds = %3
%14 = load double, double* %5
%15 = load double, double* %6
%16 = fmul double 9.000000e+00, %15
%17 = fneg double %16
%18 = call double @llvm.fmuladd.f64(double -6.000000e+00, double %14, double %17)
%19 = fadd double %18, 1.200000e+01
%20 = load double, double* %7
%21 = fmul double %19, %20
%22 = load double, double* %7
%23 = fmul double %21, %22
%24 = load double, double* %7
%25 = load double, double* %5
%26 = load double, double* %6
%27 = fmul double 1.200000e+01, %26
%28 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %25, double %27)
%29 = fsub double %28, 1.800000e+01
%30 = load double, double* %7
%31 = fmul double %29, %30
%32 = load double, double* %7
%33 = fmul double %31, %32
%34 = call double @llvm.fmuladd.f64(double %23, double %24, double %33)
%35 = load double, double* %6
%36 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %35, double %34)
%37 = fadd double %36, 6.000000e+00
store double %37, double* %8
br label %72
38: ; preds = %3
%39 = load double, double* %7
%40 = fcmp olt double %39, 2.000000e+00
br i1 %40, label %41, label %71
41: ; preds = %38
%42 = load double, double* %5
%43 = load double, double* %6
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double -6.000000e+00, double %42, double %44)
%46 = load double, double* %7
%47 = fmul double %45, %46
%48 = load double, double* %7
%49 = fmul double %47, %48
%50 = load double, double* %7
%51 = load double, double* %5
%52 = load double, double* %6
%53 = fmul double 6.000000e+00, %52
%54 = call double @llvm.fmuladd.f64(double 3.000000e+01, double %51, double %53)
%55 = load double, double* %7
%56 = fmul double %54, %55
%57 = load double, double* %7
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %49, double %50, double %58)
%60 = load double, double* %5
%61 = load double, double* %6
%62 = fmul double 1.200000e+01, %61
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double -4.800000e+01, double %60, double %63)
%65 = load double, double* %7
%66 = call double @llvm.fmuladd.f64(double %64, double %65, double %59)
%67 = load double, double* %5
%68 = call double @llvm.fmuladd.f64(double 2.400000e+01, double %67, double %66)
%69 = load double, double* %6
%70 = call double @llvm.fmuladd.f64(double 8.000000e+00, double %69, double %68)
store double %70, double* %8
br label %71
71: ; preds = %41, %38
br label %72
72: ; preds = %71, %13
%73 = load double, double* %8
%74 = fmul double 0x3FC5555555555555, %73
ret double %74
}

LLVM IR (-O2):
define double @cubic_weight(double %0, double %1, double %2) {
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = fcmp olt double %4, 1.000000e+00
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = fmul double %2, -9.000000e+00
%8 = tail call double @llvm.fmuladd.f64(double %1, double -6.000000e+00, double %7)
%9 = fadd double %8, 1.200000e+01
%10 = fmul double %4, %9
%11 = fmul double %4, %10
%12 = fmul double %2, 1.200000e+01
%13 = tail call double @llvm.fmuladd.f64(double %1, double 6.000000e+00, double %12)
%14 = fadd double %13, -1.800000e+01
%15 = fmul double %4, %14
%16 = fmul double %4, %15
%17 = tail call double @llvm.fmuladd.f64(double %11, double %4, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %2, double -2.000000e+00, double %17)
%19 = fadd double %18, 6.000000e+00
br label %37
20: ; preds = %3
%21 = fcmp olt double %4, 2.000000e+00
br i1 %21, label %22, label %37
22: ; preds = %20
%23 = fneg double %2
%24 = tail call double @llvm.fmuladd.f64(double %1, double -6.000000e+00, double %23)
%25 = fmul double %4, %24
%26 = fmul double %4, %25
%27 = fmul double %2, 6.000000e+00
%28 = tail call double @llvm.fmuladd.f64(double %1, double 3.000000e+01, double %27)
%29 = fmul double %4, %28
%30 = fmul double %4, %29
%31 = tail call double @llvm.fmuladd.f64(double %26, double %4, double %30)
%32 = fmul double %2, -1.200000e+01
%33 = tail call double @llvm.fmuladd.f64(double %1, double -4.800000e+01, double %32)
%34 = tail call double @llvm.fmuladd.f64(double %33, double %4, double %31)
%35 = tail call double @llvm.fmuladd.f64(double %1, double 2.400000e+01, double %34)
%36 = tail call double @llvm.fmuladd.f64(double %2, double 8.000000e+00, double %35)
br label %37
37: ; preds = %20, %22, %6
%38 = phi double [ %19, %6 ], [ %36, %22 ], [ 0.000000e+00, %20 ]
%39 = fmul double %38, 0x3FC5555555555555
ret double %39
}