#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 BsplnDDWght5(long i, double x) {
  x = fabs(x - (double)i);
  if (x < 1.0)
    return (x * x * (3.0 - x * (5.0 / 3.0)) - 1.0);
  if (x < 2.0)
    return (x * (x * (x * (5.0 / 6.0) - 4.5) + 7.5) - 3.5);
  if (x < 3.0) {
    x -= 3.0;
    return (x * x * x * (-1.0 / 6.0));
  }
  return (0.0);
}


x86 assembly (clang, -O0):
<BsplnDDWght5>:
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 0xf2d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1197 <BsplnDDWght5+0x97>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xedb(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe97(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <BsplnDDWght5+0x151>
movsd  0xe69(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11fb <BsplnDDWght5+0xfb>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  0xe6f(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe6b(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe4b(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <BsplnDDWght5+0x151>
movsd  0xe0d(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1249 <BsplnDDWght5+0x149>
movsd  -0x18(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <BsplnDDWght5+0x151>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnDDWght5>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm2
andpd  %xmm0,%xmm2
movsd  0xef3(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    114c <BsplnDDWght5+0x4c>
movsd  0xf2d(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xee9(%rip),%xmm1
mulsd  %xmm0,%xmm0
mulsd  %xmm0,%xmm1
addsd  0xf19(%rip),%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xec4(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    1187 <BsplnDDWght5+0x87>
movsd  0xed6(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xed2(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xece(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeca(%rip),%xmm0
ret
xorpd  %xmm0,%xmm0
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    11b9 <BsplnDDWght5+0xb9>
movsd  0xe87(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe77(%rip),%xmm0
ret

LLVM IR (-O0):
define double @BsplnDDWght5(i64 %0, double %1) {
%3 = alloca double
%4 = alloca i64
%5 = alloca double
store i64 %0, i64* %4
store double %1, double* %5
%6 = load double, double* %5
%7 = load i64, i64* %4
%8 = sitofp i64 %7 to double
%9 = fsub double %6, %8
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %5
%11 = load double, double* %5
%12 = fcmp olt double %11, 1.000000e+00
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fmul double %14, %15
%17 = load double, double* %5
%18 = fneg double %17
%19 = call double @llvm.fmuladd.f64(double %18, double 0x3FFAAAAAAAAAAAAB, double 3.000000e+00)
%20 = call double @llvm.fmuladd.f64(double %16, double %19, double -1.000000e+00)
store double %20, double* %3
br label %44
21: ; preds = %2
%22 = load double, double* %5
%23 = fcmp olt double %22, 2.000000e+00
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load double, double* %5
%26 = load double, double* %5
%27 = load double, double* %5
%28 = call double @llvm.fmuladd.f64(double %27, double 0x3FEAAAAAAAAAAAAB, double -4.500000e+00)
%29 = call double @llvm.fmuladd.f64(double %26, double %28, double 7.500000e+00)
%30 = call double @llvm.fmuladd.f64(double %25, double %29, double -3.500000e+00)
store double %30, double* %3
br label %44
31: ; preds = %21
%32 = load double, double* %5
%33 = fcmp olt double %32, 3.000000e+00
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load double, double* %5
%36 = fsub double %35, 3.000000e+00
store double %36, double* %5
%37 = load double, double* %5
%38 = load double, double* %5
%39 = fmul double %37, %38
%40 = load double, double* %5
%41 = fmul double %39, %40
%42 = fmul double %41, 0xBFC5555555555555
store double %42, double* %3
br label %44
43: ; preds = %31
store double 0.000000e+00, double* %3
br label %44
44: ; preds = %43, %34, %24, %13
%45 = load double, double* %3
ret double %45
}

LLVM IR (-O2):
define double @BsplnDDWght5(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 %12
7: ; preds = %2
%8 = fmul double %4, %4
%9 = fneg double %5
%10 = tail call double @llvm.fmuladd.f64(double %9, double 0x3FFAAAAAAAAAAAAB, double 3.000000e+00)
%11 = tail call double @llvm.fmuladd.f64(double %8, double %10, double -1.000000e+00)
br label %25
12: ; preds = %2
%13 = fcmp olt double %5, 2.000000e+00
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FEAAAAAAAAAAAAB, double -4.500000e+00)
%16 = tail call double @llvm.fmuladd.f64(double %5, double %15, double 7.500000e+00)
%17 = tail call double @llvm.fmuladd.f64(double %5, double %16, double -3.500000e+00)
br label %25
18: ; preds = %12
%19 = fcmp olt double %5, 3.000000e+00
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = fadd double %5, -3.000000e+00
%22 = fmul double %21, %21
%23 = fmul double %21, %22
%24 = fmul double %23, 0xBFC5555555555555
br label %25
25: ; preds = %18, %20, %14, %7
%26 = phi double [ %11, %7 ], [ %17, %14 ], [ %24, %20 ], [ 0.000000e+00, %18 ]
ret double %26
}