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


x86 assembly (clang, -O0):
<BsplnDDWght3>:
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    1166 <BsplnDDWght3+0x66>
movsd  -0x18(%rbp),%xmm0
movsd  0xec4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1198 <BsplnDDWght3+0x98>
movsd  0xe9a(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1190 <BsplnDDWght3+0x90>
movsd  0xe87(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1198 <BsplnDDWght3+0x98>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsplnDDWght3>:
cvtsi2sd %rdi,%xmm1
subsd  %xmm1,%xmm0
andpd  0xeef(%rip),%xmm0
movsd  0xef7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1138 <BsplnDDWght3+0x38>
movsd  0xef9(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xef5(%rip),%xmm1
movapd %xmm1,%xmm0
ret
xorpd  %xmm1,%xmm1
movsd  0xed4(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1152 <BsplnDDWght3+0x52>
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @BsplnDDWght3(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, 1.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load double, double* %5
%15 = call double @llvm.fmuladd.f64(double %14, double 3.000000e+00, double -2.000000e+00)
store double %15, double* %3
br label %23
16: ; preds = %2
%17 = load double, double* %5
%18 = fcmp olt double %17, 2.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load double, double* %5
%21 = fsub double 2.000000e+00, %20
store double %21, double* %3
br label %23
22: ; preds = %16
store double 0.000000e+00, double* %3
br label %23
23: ; preds = %22, %19, %13
%24 = load double, double* %3
ret double %24
}

LLVM IR (-O2):
define double @BsplnDDWght3(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 %9
7: ; preds = %2
%8 = tail call double @llvm.fmuladd.f64(double %5, double 3.000000e+00, double -2.000000e+00)
br label %13
9: ; preds = %2
%10 = fcmp olt double %5, 2.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = fsub double 2.000000e+00, %5
br label %13
13: ; preds = %9, %11, %7
%14 = phi double [ %8, %7 ], [ %12, %11 ], [ 0.000000e+00, %9 ]
ret double %14
}