#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 BsplnDWght5(long i, double x) {
  double f;
  x -= (double)i;
  f = fabs(x);
  if (f < 1.0)
    f *= f * f * (1.0 - f * (5.0 / 12.0)) - 1.0;
  else if (f < 2.0)
    f = f * (f * (f * (f * (5.0 / 24.0) - 1.5) + 3.75) - 3.5) + 0.625;
  else if (f < 3.0) {
    f -= 3.0;
    f *= f;
    f *= f * (-1.0 / 24.0);
  } else
    return (0.0);
  return ((x > 0.0) ? (f) : (-f));
}


x86 assembly (clang, -O0):
<BsplnDWght5>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xf33(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11a6 <BsplnDWght5+0xa6>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xed9(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe7d(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb5(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    128a <BsplnDWght5+0x18a>
movsd  0xe5a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    121f <BsplnDWght5+0x11f>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  0xe63(%rip),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe5f(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe3f(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe27(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1285 <BsplnDWght5+0x185>
movsd  0xde9(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1273 <BsplnDWght5+0x173>
movsd  -0x20(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdb9(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1280 <BsplnDWght5+0x180>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d6 <BsplnDWght5+0x1d6>
jmp    1285 <BsplnDWght5+0x185>
jmp    128a <BsplnDWght5+0x18a>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ab <BsplnDWght5+0x1ab>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12cc <BsplnDWght5+0x1cc>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnDWght5>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm2
andpd  %xmm0,%xmm2
movsd  0xf03(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1151 <BsplnDWght5+0x51>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xf3d(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xee1(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0xf2d(%rip),%xmm3
mulsd  %xmm2,%xmm3
jmp    11cb <BsplnDWght5+0xcb>
movsd  0xecf(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1199 <BsplnDWght5+0x99>
movsd  0xee1(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xedd(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xed9(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xed5(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xed1(%rip),%xmm3
jmp    11cb <BsplnDWght5+0xcb>
xorpd  %xmm1,%xmm1
movsd  0xe8b(%rip),%xmm3
ucomisd %xmm2,%xmm3
jbe    11ec <BsplnDWght5+0xec>
movsd  0xe85(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe7d(%rip),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movapd 0xe3d(%rip),%xmm2
xorpd  %xmm3,%xmm2
xorpd  %xmm1,%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm2,%xmm1
orpd   %xmm3,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnDWght5(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 i64, i64* %4
%8 = sitofp i64 %7 to double
%9 = load double, double* %5
%10 = fsub double %9, %8
store double %10, double* %5
%11 = load double, double* %5
%12 = call double @llvm.fabs.f64(double %11)
store double %12, double* %6
%13 = load double, double* %6
%14 = fcmp olt double %13, 1.000000e+00
br i1 %14, label %15, label %25
15: ; preds = %2
%16 = load double, double* %6
%17 = load double, double* %6
%18 = fmul double %16, %17
%19 = load double, double* %6
%20 = fneg double %19
%21 = call double @llvm.fmuladd.f64(double %20, double 0x3FDAAAAAAAAAAAAB, double 1.000000e+00)
%22 = call double @llvm.fmuladd.f64(double %18, double %21, double -1.000000e+00)
%23 = load double, double* %6
%24 = fmul double %23, %22
store double %24, double* %6
br label %53
25: ; preds = %2
%26 = load double, double* %6
%27 = fcmp olt double %26, 2.000000e+00
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load double, double* %6
%30 = load double, double* %6
%31 = load double, double* %6
%32 = load double, double* %6
%33 = call double @llvm.fmuladd.f64(double %32, double 0x3FCAAAAAAAAAAAAB, double -1.500000e+00)
%34 = call double @llvm.fmuladd.f64(double %31, double %33, double 3.750000e+00)
%35 = call double @llvm.fmuladd.f64(double %30, double %34, double -3.500000e+00)
%36 = call double @llvm.fmuladd.f64(double %29, double %35, double 6.250000e-01)
store double %36, double* %6
br label %52
37: ; preds = %25
%38 = load double, double* %6
%39 = fcmp olt double %38, 3.000000e+00
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = load double, double* %6
%42 = fsub double %41, 3.000000e+00
store double %42, double* %6
%43 = load double, double* %6
%44 = load double, double* %6
%45 = fmul double %44, %43
store double %45, double* %6
%46 = load double, double* %6
%47 = fmul double %46, 0xBFA5555555555555
%48 = load double, double* %6
%49 = fmul double %48, %47
store double %49, double* %6
br label %51
50: ; preds = %37
store double 0.000000e+00, double* %3
br label %63
51: ; preds = %40
br label %52
52: ; preds = %51, %28
br label %53
53: ; preds = %52, %15
%54 = load double, double* %5
%55 = fcmp ogt double %54, 0.000000e+00
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = load double, double* %6
br label %61
58: ; preds = %53
%59 = load double, double* %6
%60 = fneg double %59
br label %61
61: ; preds = %58, %56
%62 = phi double [ %57, %56 ], [ %60, %58 ]
store double %62, double* %3
br label %63
63: ; preds = %61, %50
%64 = load double, double* %3
ret double %64
}

LLVM IR (-O2):
define double @BsplnDWght5(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 0x3FDAAAAAAAAAAAAB, double 1.000000e+00)
%11 = tail call double @llvm.fmuladd.f64(double %8, double %10, double -1.000000e+00)
%12 = fmul double %5, %11
br label %27
13: ; preds = %2
%14 = fcmp olt double %5, 2.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FCAAAAAAAAAAAAB, double -1.500000e+00)
%17 = tail call double @llvm.fmuladd.f64(double %5, double %16, double 3.750000e+00)
%18 = tail call double @llvm.fmuladd.f64(double %5, double %17, double -3.500000e+00)
%19 = tail call double @llvm.fmuladd.f64(double %5, double %18, double 6.250000e-01)
br label %27
20: ; preds = %13
%21 = fcmp olt double %5, 3.000000e+00
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = fadd double %5, -3.000000e+00
%24 = fmul double %23, %23
%25 = fmul double %24, 0xBFA5555555555555
%26 = fmul double %24, %25
br label %27
27: ; preds = %15, %22, %7
%28 = phi double [ %12, %7 ], [ %19, %15 ], [ %26, %22 ]
%29 = fcmp ogt double %4, 0.000000e+00
%30 = fneg double %28
%31 = select i1 %29, double %28, double %30
br label %32
32: ; preds = %20, %27
%33 = phi double [ %31, %27 ], [ 0.000000e+00, %20 ]
ret double %33
}