#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 BsplnDDWght4(long i, double x) {
  x = fabs(x - (double)i);
  if (x < 0.5)
    return (3.0 * x * x - 1.25);
  if (x < 1.5)
    return (x * (5.0 - x * 2.0) - 2.5);
  if (x < 2.5) {
    x -= 2.5;
    return (x * x * 0.5);
  }
  return (0.0);
}


x86 assembly (clang, -O0):
<BsplnDDWght4>:
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 0xf1d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    116b <BsplnDDWght4+0x6b>
movsd  0xee9(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xecb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <BsplnDDWght4+0x11a>
movsd  0xe95(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11c9 <BsplnDDWght4+0xc9>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm1,%xmm1
movsd  0xe75(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <BsplnDDWght4+0x11a>
movsd  0xe3f(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1212 <BsplnDDWght4+0x112>
movsd  -0x18(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <BsplnDDWght4+0x11a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnDDWght4>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
andpd  0xeef(%rip),%xmm0
movsd  0xef7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    113c <BsplnDDWght4+0x3c>
movsd  0xf11(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf09(%rip),%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xed4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    116f <BsplnDDWght4+0x6f>
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movsd  0xed6(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xebe(%rip),%xmm1
movapd %xmm1,%xmm0
ret
xorpd  %xmm1,%xmm1
movsd  0xea5(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1199 <BsplnDDWght4+0x99>
movsd  0xe9f(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
mulsd  0xe77(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnDDWght4(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 %18
13: ; preds = %2
%14 = load double, double* %5
%15 = fmul double 3.000000e+00, %14
%16 = load double, double* %5
%17 = call double @llvm.fmuladd.f64(double %15, double %16, double -1.250000e+00)
store double %17, double* %3
br label %38
18: ; preds = %2
%19 = load double, double* %5
%20 = fcmp olt double %19, 1.500000e+00
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load double, double* %5
%23 = load double, double* %5
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %24, double 2.000000e+00, double 5.000000e+00)
%26 = call double @llvm.fmuladd.f64(double %22, double %25, double -2.500000e+00)
store double %26, double* %3
br label %38
27: ; preds = %18
%28 = load double, double* %5
%29 = fcmp olt double %28, 2.500000e+00
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load double, double* %5
%32 = fsub double %31, 2.500000e+00
store double %32, double* %5
%33 = load double, double* %5
%34 = load double, double* %5
%35 = fmul double %33, %34
%36 = fmul double %35, 5.000000e-01
store double %36, double* %3
br label %38
37: ; preds = %27
store double 0.000000e+00, double* %3
br label %38
38: ; preds = %37, %30, %21, %13
%39 = load double, double* %3
ret double %39
}

LLVM IR (-O2):
define double @BsplnDDWght4(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 = fmul double %5, 3.000000e+00
%9 = tail call double @llvm.fmuladd.f64(double %8, double %5, double -1.250000e+00)
br label %22
10: ; preds = %2
%11 = fcmp olt double %5, 1.500000e+00
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = fneg double %5
%14 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double 5.000000e+00)
%15 = tail call double @llvm.fmuladd.f64(double %5, double %14, double -2.500000e+00)
br label %22
16: ; preds = %10
%17 = fcmp olt double %5, 2.500000e+00
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = fadd double %5, -2.500000e+00
%20 = fmul double %19, %19
%21 = fmul double %20, 5.000000e-01
br label %22
22: ; preds = %16, %18, %12, %7
%23 = phi double [ %9, %7 ], [ %15, %12 ], [ %21, %18 ], [ 0.000000e+00, %16 ]
ret double %23
}