#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 BsplnDWght3(long i, double x) {
  double f;
  x -= (double)i;
  f = fabs(x);
  if (f < 1.0)
    f *= f * 1.5 - 2.0;
  else if (f < 2.0) {
    f = 2.0 - f;
    f *= -0.5 * f;
  } else
    return (0.0);
  return ((x > 0.0) ? (f) : (-f));
}


x86 assembly (clang, -O0):
<BsplnDWght3>:
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 0xf03(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1175 <BsplnDWght3+0x75>
movsd  -0x20(%rbp),%xmm0
movsd  0xec2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xebe(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c8 <BsplnDWght3+0xc8>
movsd  0xe8b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11b6 <BsplnDWght3+0xb6>
movsd  0xe78(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe6e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c3 <BsplnDWght3+0xc3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1214 <BsplnDWght3+0x114>
jmp    11c8 <BsplnDWght3+0xc8>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e9 <BsplnDWght3+0xe9>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    120a <BsplnDWght3+0x10a>
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):
<BsplnDWght3>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
movapd 0xeef(%rip),%xmm3
andpd  %xmm0,%xmm3
movsd  0xf03(%rip),%xmm1
ucomisd %xmm3,%xmm1
jbe    113d <BsplnDWght3+0x3d>
movsd  0xf0d(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xf09(%rip),%xmm2
mulsd  %xmm3,%xmm2
jmp    1163 <BsplnDWght3+0x63>
xorpd  %xmm1,%xmm1
movsd  0xedf(%rip),%xmm4
ucomisd %xmm3,%xmm4
jbe    1184 <BsplnDWght3+0x84>
subsd  %xmm3,%xmm4
movsd  0xed5(%rip),%xmm2
mulsd  %xmm4,%xmm2
mulsd  %xmm4,%xmm2
movapd 0xea5(%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 @BsplnDWght3(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 %20
15: ; preds = %2
%16 = load double, double* %6
%17 = call double @llvm.fmuladd.f64(double %16, double 1.500000e+00, double -2.000000e+00)
%18 = load double, double* %6
%19 = fmul double %18, %17
store double %19, double* %6
br label %32
20: ; preds = %2
%21 = load double, double* %6
%22 = fcmp olt double %21, 2.000000e+00
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load double, double* %6
%25 = fsub double 2.000000e+00, %24
store double %25, double* %6
%26 = load double, double* %6
%27 = fmul double -5.000000e-01, %26
%28 = load double, double* %6
%29 = fmul double %28, %27
store double %29, double* %6
br label %31
30: ; preds = %20
store double 0.000000e+00, double* %3
br label %42
31: ; preds = %23
br label %32
32: ; preds = %31, %15
%33 = load double, double* %5
%34 = fcmp ogt double %33, 0.000000e+00
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load double, double* %6
br label %40
37: ; preds = %32
%38 = load double, double* %6
%39 = fneg double %38
br label %40
40: ; preds = %37, %35
%41 = phi double [ %36, %35 ], [ %39, %37 ]
store double %41, double* %3
br label %42
42: ; preds = %40, %30
%43 = load double, double* %3
ret double %43
}

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