#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 BsplnWght5(long i, double x) {
  double f;
  x = fabs(x - (double)i);
  if (x < 1.0) {
    f = x * x;
    return (f * (f * (0.25 - x * (1.0 / 12.0)) - 0.5) + 0.55);
  }
  if (x < 2.0)
    return (
        x * (x * (x * (x * (x * (1.0 / 24.0) - 0.375) + 1.25) - 1.75) + 0.625) +
        0.425);
  if (x < 3.0) {
    f = 3.0 - x;
    x = f * f;
    return (f * x * x * (1.0 / 120.0));
  }
  return (0.0);
}


x86 assembly (clang, -O0):
<BsplnWght5>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
movaps 0xf4d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11b6 <BsplnWght5+0xb6>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xee4(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xee0(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xec0(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a5 <BsplnWght5+0x1a5>
movsd  0xe4a(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1244 <BsplnWght5+0x144>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm4
movsd  0xe56(%rip),%xmm5
mulsd  %xmm5,%xmm4
movsd  0xe52(%rip),%xmm5
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe32(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe1a(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe02(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdea(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a5 <BsplnWght5+0x1a5>
movsd  0xdc4(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    129d <BsplnWght5+0x19d>
movsd  0xdb1(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xd89(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a5 <BsplnWght5+0x1a5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnWght5>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm2
andpd  %xmm0,%xmm2
movsd  0xef3(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1158 <BsplnWght5+0x58>
movsd  0xf35(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xf31(%rip),%xmm1
mulsd  %xmm0,%xmm0
mulsd  %xmm0,%xmm1
addsd  0xf29(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf25(%rip),%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xeb8(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    11ab <BsplnWght5+0xab>
movsd  0xec2(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xebe(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeba(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeb6(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeb2(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeae(%rip),%xmm0
ret
xorpd  %xmm0,%xmm0
movsd  0xe69(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    11dd <BsplnWght5+0xdd>
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xe4f(%rip),%xmm1
movapd %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @BsplnWght5(i64 %0, double %1) {
%3 = sitofp i64 %0 to double
%4 = fsub double %1, %3
%5 = tail call double @llvm.fabs.f64(double %4)
%6 = fcmp olt double %5, 1.000000e+00
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = fmul double %4, %4
%9 = fneg double %5
%10 = tail call double @llvm.fmuladd.f64(double %9, double 0x3FB5555555555555, double 2.500000e-01)
%11 = tail call double @llvm.fmuladd.f64(double %8, double %10, double -5.000000e-01)
%12 = tail call double @llvm.fmuladd.f64(double %8, double %11, double 5.500000e-01)
br label %29
13: ; preds = %2
%14 = fcmp olt double %5, 2.000000e+00
br i1 %14, label %15, label %21
15: ; preds = %13
%16 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FA5555555555555, double -3.750000e-01)
%17 = tail call double @llvm.fmuladd.f64(double %5, double %16, double 1.250000e+00)
%18 = tail call double @llvm.fmuladd.f64(double %5, double %17, double -1.750000e+00)
%19 = tail call double @llvm.fmuladd.f64(double %5, double %18, double 6.250000e-01)
%20 = tail call double @llvm.fmuladd.f64(double %5, double %19, double 4.250000e-01)
br label %29
21: ; preds = %13
%22 = fcmp olt double %5, 3.000000e+00
br i1 %22, label %23, label %29
23: ; preds = %21
%24 = fsub double 3.000000e+00, %5
%25 = fmul double %24, %24
%26 = fmul double %24, %25
%27 = fmul double %25, %26
%28 = fmul double %27, 0x3F81111111111111
br label %29
29: ; preds = %21, %23, %15, %7
%30 = phi double [ %12, %7 ], [ %20, %15 ], [ %28, %23 ], [ 0.000000e+00, %21 ]
ret double %30
}