#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 _quadratic_kernel(double x) {
  x = fabs(x);
  if (x <= 0.5) {
    return 0.75 - x * x;
  }
  if (x < 1.5) {
    x = 1.5 - x;
    return (x * x) * 0.5;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_quadratic_kernel>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xf0b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeda(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     116c <_quadratic_kernel+0x6c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xeb2(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b9 <_quadratic_kernel+0xb9>
movsd  0xe94(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b1 <_quadratic_kernel+0xb1>
movsd  0xe81(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b9 <_quadratic_kernel+0xb9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_quadratic_kernel>:
andpd  0xef8(%rip),%xmm0
movsd  0xf00(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1141 <_quadratic_kernel+0x41>
xorpd  %xmm1,%xmm1
movsd  0xefe(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    113c <_quadratic_kernel+0x3c>
subsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm2
mulsd  0xed8(%rip),%xmm2
movapd %xmm2,%xmm1
movapd %xmm1,%xmm0
ret
mulsd  %xmm0,%xmm0
movsd  0xecb(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @_quadratic_kernel(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @llvm.fabs.f64(double %4)
store double %5, double* %3
%6 = load double, double* %3
%7 = fcmp ole double %6, 5.000000e-01
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load double, double* %3
%10 = load double, double* %3
%11 = fneg double %9
%12 = call double @llvm.fmuladd.f64(double %11, double %10, double 7.500000e-01)
store double %12, double* %2
br label %24
13: ; preds = %1
%14 = load double, double* %3
%15 = fcmp olt double %14, 1.500000e+00
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load double, double* %3
%18 = fsub double 1.500000e+00, %17
store double %18, double* %3
%19 = load double, double* %3
%20 = load double, double* %3
%21 = fmul double %19, %20
%22 = fmul double %21, 5.000000e-01
store double %22, double* %2
br label %24
23: ; preds = %13
store double 0.000000e+00, double* %2
br label %24
24: ; preds = %23, %16, %8
%25 = load double, double* %2
ret double %25
}

LLVM IR (-O2):
define double @_quadratic_kernel(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ugt double %2, 5.000000e-01
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = fneg double %2
%6 = tail call double @llvm.fmuladd.f64(double %5, double %2, double 7.500000e-01)
br label %13
7: ; preds = %1
%8 = fcmp olt double %2, 1.500000e+00
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = fsub double 1.500000e+00, %2
%11 = fmul double %10, %10
%12 = fmul double %11, 5.000000e-01
br label %13
13: ; preds = %7, %9, %4
%14 = phi double [ %6, %4 ], [ %12, %9 ], [ 0.000000e+00, %7 ]
ret double %14
}