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


x86 assembly (clang, -O0):
<BsplnDDWght2>:
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 0xf0d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1151 <BsplnDDWght2+0x51>
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <BsplnDDWght2+0xdc>
movsd  -0x18(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1180 <BsplnDDWght2+0x80>
jp     1180 <BsplnDDWght2+0x80>
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <BsplnDDWght2+0xdc>
movsd  0xe80(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a5 <BsplnDDWght2+0xa5>
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <BsplnDDWght2+0xdc>
movsd  -0x18(%rbp),%xmm0
movsd  0xe56(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11d4 <BsplnDDWght2+0xd4>
jp     11d4 <BsplnDDWght2+0xd4>
movsd  0xe36(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <BsplnDDWght2+0xdc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnDDWght2>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
andpd  0xeef(%rip),%xmm0
movsd  0xeff(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1128 <BsplnDDWght2+0x28>
movsd  0xee9(%rip),%xmm0
ret
ucomisd 0xee8(%rip),%xmm0
jne    113d <BsplnDDWght2+0x3d>
jp     113d <BsplnDDWght2+0x3d>
movsd  0xee4(%rip),%xmm0
ret
movsd  0xeeb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1154 <BsplnDDWght2+0x54>
movsd  0xed5(%rip),%xmm0
ret
cmpeqsd 0xed3(%rip),%xmm0
movsd  0xeb3(%rip),%xmm1
andpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnDDWght2(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 %14
13: ; preds = %2
store double -2.000000e+00, double* %3
br label %27
14: ; preds = %2
%15 = load double, double* %5
%16 = fcmp oeq double %15, 5.000000e-01
br i1 %16, label %17, label %18
17: ; preds = %14
store double -5.000000e-01, double* %3
br label %27
18: ; preds = %14
%19 = load double, double* %5
%20 = fcmp olt double %19, 1.500000e+00
br i1 %20, label %21, label %22
21: ; preds = %18
store double 1.000000e+00, double* %3
br label %27
22: ; preds = %18
%23 = load double, double* %5
%24 = fcmp oeq double %23, 1.500000e+00
br i1 %24, label %25, label %26
25: ; preds = %22
store double 5.000000e-01, double* %3
br label %27
26: ; preds = %22
store double 0.000000e+00, double* %3
br label %27
27: ; preds = %26, %25, %21, %17, %13
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @BsplnDDWght2(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 %14, label %7
7: ; preds = %2
%8 = fcmp oeq double %5, 5.000000e-01
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = fcmp olt double %5, 1.500000e+00
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = fcmp oeq double %5, 1.500000e+00
%13 = select i1 %12, double 5.000000e-01, double 0.000000e+00
br label %14
14: ; preds = %11, %9, %7, %2
%15 = phi double [ -2.000000e+00, %2 ], [ -5.000000e-01, %7 ], [ 1.000000e+00, %9 ], [ %13, %11 ]
ret double %15
}