#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 BsplnWght4(long i, double x) {
  x = fabs(x - (double)i);
  if (x < 0.5) {
    x *= x;
    return (x * (x * 0.25 - 0.625) + 115.0 / 192.0);
  }
  if (x < 1.5)
    return (x * (x * (x * (5.0 / 6.0 - x * (1.0 / 6.0)) - 1.25) + 5.0 / 24.0) +
            55.0 / 96.0);
  if (x < 2.5) {
    x -= 2.5;
    x *= x;
    return (x * x * (1.0 / 24.0));
  }
  return (0.0);
}


x86 assembly (clang, -O0):
<BsplnWght4>:
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 0xf3d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    118a <BsplnWght4+0x8a>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xef0(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xeec(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xecc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    127a <BsplnWght4+0x17a>
movsd  0xe76(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    121a <BsplnWght4+0x11a>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  0xe68(%rip),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe64(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe44(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe2c(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe14(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    127a <BsplnWght4+0x17a>
movsd  0xdee(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1272 <BsplnWght4+0x172>
movsd  -0x18(%rbp),%xmm0
movsd  0xdd6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdb4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    127a <BsplnWght4+0x17a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnWght4>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xef3(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    114c <BsplnWght4+0x4c>
mulsd  %xmm0,%xmm0
movsd  0xf31(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf2d(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf29(%rip),%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xec4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1193 <BsplnWght4+0x93>
movsd  0xed6(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xed2(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xece(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xeca(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xec6(%rip),%xmm0
ret
xorpd  %xmm0,%xmm0
movsd  0xe81(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11c1 <BsplnWght4+0xc1>
addsd  0xe7b(%rip),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm1
mulsd  0xe73(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnWght4(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, 5.000000e-01
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fmul double %15, %14
store double %16, double* %5
%17 = load double, double* %5
%18 = load double, double* %5
%19 = call double @llvm.fmuladd.f64(double %18, double 2.500000e-01, double -6.250000e-01)
%20 = call double @llvm.fmuladd.f64(double %17, double %19, double 0x3FE32AAAAAAAAAAB)
store double %20, double* %3
br label %48
21: ; preds = %2
%22 = load double, double* %5
%23 = fcmp olt double %22, 1.500000e+00
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load double, double* %5
%26 = load double, double* %5
%27 = load double, double* %5
%28 = load double, double* %5
%29 = fneg double %28
%30 = call double @llvm.fmuladd.f64(double %29, double 0x3FC5555555555555, double 0x3FEAAAAAAAAAAAAB)
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double -1.250000e+00)
%32 = call double @llvm.fmuladd.f64(double %26, double %31, double 0x3FCAAAAAAAAAAAAB)
%33 = call double @llvm.fmuladd.f64(double %25, double %32, double 0x3FE2555555555555)
store double %33, double* %3
br label %48
34: ; preds = %21
%35 = load double, double* %5
%36 = fcmp olt double %35, 2.500000e+00
br i1 %36, label %37, label %47
37: ; preds = %34
%38 = load double, double* %5
%39 = fsub double %38, 2.500000e+00
store double %39, double* %5
%40 = load double, double* %5
%41 = load double, double* %5
%42 = fmul double %41, %40
store double %42, double* %5
%43 = load double, double* %5
%44 = load double, double* %5
%45 = fmul double %43, %44
%46 = fmul double %45, 0x3FA5555555555555
store double %46, double* %3
br label %48
47: ; preds = %34
store double 0.000000e+00, double* %3
br label %48
48: ; preds = %47, %37, %24, %13
%49 = load double, double* %3
ret double %49
}

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