#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 BsplnDWght4(long i, double x) {
  double f;
  x -= (double)i;
  f = fabs(x);
  if (f < 0.5)
    f *= f * f - 1.25;
  else if (f < 1.5)
    f = f * (f * (2.5 - f * (2.0 / 3.0)) - 2.5) + 5.0 / 24.0;
  else if (f < 2.5) {
    f -= 2.5;
    f *= f * f * (1.0 / 6.0);
  } else
    return (0.0);
  return ((x > 0.0) ? (f) : (-f));
}


x86 assembly (clang, -O0):
<BsplnDWght4>:
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 0xf13(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1172 <BsplnDWght4+0x72>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xed9(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1252 <BsplnDWght4+0x152>
movsd  0xe8e(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11ed <BsplnDWght4+0xed>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xe7d(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe51(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe59(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    124d <BsplnDWght4+0x14d>
movsd  0xe1b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    123b <BsplnDWght4+0x13b>
movsd  -0x20(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1248 <BsplnDWght4+0x148>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <BsplnDWght4+0x19e>
jmp    124d <BsplnDWght4+0x14d>
jmp    1252 <BsplnDWght4+0x152>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1273 <BsplnDWght4+0x173>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1294 <BsplnDWght4+0x194>
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):
<BsplnDWght4>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm3
andpd  %xmm0,%xmm3
movsd  0xf03(%rip),%xmm1
ucomisd %xmm3,%xmm1
jbe    1139 <BsplnDWght4+0x39>
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf25(%rip),%xmm2
mulsd  %xmm3,%xmm2
jmp    11a7 <BsplnDWght4+0xa7>
movsd  0xee7(%rip),%xmm1
ucomisd %xmm3,%xmm1
jbe    1175 <BsplnDWght4+0x75>
movsd  0xef9(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xed5(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xed1(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xedd(%rip),%xmm2
jmp    11a7 <BsplnDWght4+0xa7>
xorpd  %xmm1,%xmm1
movsd  0xeaf(%rip),%xmm2
ucomisd %xmm3,%xmm2
jbe    11c8 <BsplnDWght4+0xc8>
movsd  0xea9(%rip),%xmm1
addsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  0xe9d(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd 0xe61(%rip),%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm1,%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnDWght4(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, 5.000000e-01
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load double, double* %6
%17 = load double, double* %6
%18 = call double @llvm.fmuladd.f64(double %16, double %17, double -1.250000e+00)
%19 = load double, double* %6
%20 = fmul double %19, %18
store double %20, double* %6
br label %47
21: ; preds = %2
%22 = load double, double* %6
%23 = fcmp olt double %22, 1.500000e+00
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = load double, double* %6
%26 = load double, double* %6
%27 = load double, double* %6
%28 = fneg double %27
%29 = call double @llvm.fmuladd.f64(double %28, double 0x3FE5555555555555, double 2.500000e+00)
%30 = call double @llvm.fmuladd.f64(double %26, double %29, double -2.500000e+00)
%31 = call double @llvm.fmuladd.f64(double %25, double %30, double 0x3FCAAAAAAAAAAAAB)
store double %31, double* %6
br label %46
32: ; preds = %21
%33 = load double, double* %6
%34 = fcmp olt double %33, 2.500000e+00
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load double, double* %6
%37 = fsub double %36, 2.500000e+00
store double %37, double* %6
%38 = load double, double* %6
%39 = load double, double* %6
%40 = fmul double %38, %39
%41 = fmul double %40, 0x3FC5555555555555
%42 = load double, double* %6
%43 = fmul double %42, %41
store double %43, double* %6
br label %45
44: ; preds = %32
store double 0.000000e+00, double* %3
br label %57
45: ; preds = %35
br label %46
46: ; preds = %45, %24
br label %47
47: ; preds = %46, %15
%48 = load double, double* %5
%49 = fcmp ogt double %48, 0.000000e+00
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = load double, double* %6
br label %55
52: ; preds = %47
%53 = load double, double* %6
%54 = fneg double %53
br label %55
55: ; preds = %52, %50
%56 = phi double [ %51, %50 ], [ %54, %52 ]
store double %56, double* %3
br label %57
57: ; preds = %55, %44
%58 = load double, double* %3
ret double %58
}

LLVM IR (-O2):
define double @BsplnDWght4(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, 5.000000e-01
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double -1.250000e+00)
%9 = fmul double %5, %8
br label %24
10: ; preds = %2
%11 = fcmp olt double %5, 1.500000e+00
br i1 %11, label %12, label %17
12: ; preds = %10
%13 = fneg double %5
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0x3FE5555555555555, double 2.500000e+00)
%15 = tail call double @llvm.fmuladd.f64(double %5, double %14, double -2.500000e+00)
%16 = tail call double @llvm.fmuladd.f64(double %5, double %15, double 0x3FCAAAAAAAAAAAAB)
br label %24
17: ; preds = %10
%18 = fcmp olt double %5, 2.500000e+00
br i1 %18, label %19, label %29
19: ; preds = %17
%20 = fadd double %5, -2.500000e+00
%21 = fmul double %20, %20
%22 = fmul double %21, 0x3FC5555555555555
%23 = fmul double %20, %22
br label %24
24: ; preds = %12, %19, %7
%25 = phi double [ %9, %7 ], [ %16, %12 ], [ %23, %19 ]
%26 = fcmp ogt double %4, 0.000000e+00
%27 = fneg double %25
%28 = select i1 %26, double %25, double %27
br label %29
29: ; preds = %17, %24
%30 = phi double [ %28, %24 ], [ 0.000000e+00, %17 ]
ret double %30
}