double local_kernelSPH(double r) {
  if (r <= 0.5) {
    return 1. - 6. * ((r) * (r)) + 6. * ((r) * (r) * (r));
  } else if (r <= 1.0) {
    return 2. * ((1. - r) * (1. - r) * (1. - r));
  }
  return 0.0;
}


x86 assembly (clang, -O0):
<local_kernelSPH>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xeef(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1167 <local_kernelSPH+0x67>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xef2(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xece(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xec3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cc <local_kernelSPH+0xcc>
movsd  0xe99(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11bf <local_kernelSPH+0xbf>
movsd  0xe86(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe79(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe68(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe5f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cc <local_kernelSPH+0xcc>
jmp    11c4 <local_kernelSPH+0xc4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_kernelSPH>:
movsd  0xef8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1139 <local_kernelSPH+0x39>
xorpd  %xmm1,%xmm1
movsd  0xef6(%rip),%xmm2
ucomisd %xmm0,%xmm2
jb     1134 <local_kernelSPH+0x34>
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm1
movapd %xmm1,%xmm0
ret
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xebf(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xebb(%rip),%xmm2
mulsd  %xmm0,%xmm1
mulsd  0xeb7(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @local_kernelSPH(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 5.000000e-01
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load double, double* %3
%8 = load double, double* %3
%9 = fmul double %7, %8
%10 = call double @llvm.fmuladd.f64(double -6.000000e+00, double %9, double 1.000000e+00)
%11 = load double, double* %3
%12 = load double, double* %3
%13 = fmul double %11, %12
%14 = load double, double* %3
%15 = fmul double %13, %14
%16 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %15, double %10)
store double %16, double* %2
br label %32
17: ; preds = %1
%18 = load double, double* %3
%19 = fcmp ole double %18, 1.000000e+00
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load double, double* %3
%22 = fsub double 1.000000e+00, %21
%23 = load double, double* %3
%24 = fsub double 1.000000e+00, %23
%25 = fmul double %22, %24
%26 = load double, double* %3
%27 = fsub double 1.000000e+00, %26
%28 = fmul double %25, %27
%29 = fmul double 2.000000e+00, %28
store double %29, double* %2
br label %32
30: ; preds = %17
br label %31
31: ; preds = %30
store double 0.000000e+00, double* %2
br label %32
32: ; preds = %31, %20, %6
%33 = load double, double* %2
ret double %33
}

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