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


x86 assembly (clang, -O0):
<BsplnWght2>:
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 0xefd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    117a <BsplnWght2+0x7a>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xea4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c7 <BsplnWght2+0xc7>
movsd  0xe86(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11bf <BsplnWght2+0xbf>
movsd  -0x18(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe55(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c7 <BsplnWght2+0xc7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnWght2>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
andpd  0xeef(%rip),%xmm0
movsd  0xef7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1134 <BsplnWght2+0x34>
mulsd  %xmm0,%xmm0
movsd  0xefd(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret
xorpd  %xmm1,%xmm1
movsd  0xed8(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1162 <BsplnWght2+0x62>
movsd  0xed2(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

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

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