#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 pow(int, int);
double kernel_function(double r, double h) {
  double q = r / h;
  double alpha = 3. / (2. * 3.14159265358979323846 * h * h * h);
  if (q >= 2.) {
    return 0.;
  } else if (q < 2. && q >= 1.) {
    return alpha * pow((2. - q), 3) / 6.;
  } else {
    return alpha * (0.666666666666667 - q * q + 0.5 * q * q * q);
  }
}


x86 assembly (clang, -O0):
<kernel_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed7(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xeb8(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     117d <kernel_function+0x6d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124c <kernel_function+0x13c>
movsd  0xe7b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11ee <kernel_function+0xde>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ee <kernel_function+0xde>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe47(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    $0x3,%esi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124c <kernel_function+0x13c>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xe08(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xdf4(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_function>:
push   %rax
divsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd 0xeef(%rip),%xmm0
jae    11b9 <kernel_function+0xa9>
movsd  0xed1(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xec5(%rip),%xmm3
divsd  %xmm2,%xmm3
movsd  0xec1(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1189 <kernel_function+0x79>
ucomisd 0xebb(%rip),%xmm0
jb     1189 <kernel_function+0x79>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
mov    $0x3,%esi
movsd  %xmm3,(%rsp)
call   1030 <pow@plt>
movsd  (%rsp),%xmm3
mulsd  %xmm0,%xmm3
divsd  0xea9(%rip),%xmm3
jmp    11b9 <kernel_function+0xa9>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe87(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  0xe83(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @kernel_function(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = load double, double* %5
%10 = fdiv double %8, %9
store double %10, double* %6
%11 = load double, double* %5
%12 = fmul double 0x401921FB54442D18, %11
%13 = load double, double* %5
%14 = fmul double %12, %13
%15 = load double, double* %5
%16 = fmul double %14, %15
%17 = fdiv double 3.000000e+00, %16
store double %17, double* %7
%18 = load double, double* %6
%19 = fcmp oge double %18, 2.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %2
store double 0.000000e+00, double* %3
br label %48
21: ; preds = %2
%22 = load double, double* %6
%23 = fcmp olt double %22, 2.000000e+00
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load double, double* %6
%26 = fcmp oge double %25, 1.000000e+00
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load double, double* %7
%29 = load double, double* %6
%30 = fsub double 2.000000e+00, %29
%31 = fptosi double %30 to i32
%32 = call double @pow(i32 %31, i32 3)
%33 = fmul double %28, %32
%34 = fdiv double %33, 6.000000e+00
store double %34, double* %3
br label %48
35: ; preds = %24, %21
%36 = load double, double* %7
%37 = load double, double* %6
%38 = load double, double* %6
%39 = fneg double %37
%40 = call double @llvm.fmuladd.f64(double %39, double %38, double 0x3FE5555555555558)
%41 = load double, double* %6
%42 = fmul double 5.000000e-01, %41
%43 = load double, double* %6
%44 = fmul double %42, %43
%45 = load double, double* %6
%46 = call double @llvm.fmuladd.f64(double %44, double %45, double %40)
%47 = fmul double %36, %46
store double %47, double* %3
br label %48
48: ; preds = %35, %27, %20
%49 = load double, double* %3
ret double %49
}

LLVM IR (-O2):
define double @kernel_function(double %0, double %1) {
%3 = fdiv double %0, %1
%4 = fmul double %1, 0x401921FB54442D18
%5 = fmul double %4, %1
%6 = fmul double %5, %1
%7 = fdiv double 3.000000e+00, %6
%8 = fcmp ult double %3, 2.000000e+00
br i1 %8, label %9, label %26
9: ; preds = %2
%10 = fcmp olt double %3, 2.000000e+00
%11 = fcmp oge double %3, 1.000000e+00
%12 = and i1 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = fsub double 2.000000e+00, %3
%15 = fptosi double %14 to i32
%16 = tail call double @pow(i32 %15, i32 3)
%17 = fmul double %7, %16
%18 = fdiv double %17, 6.000000e+00
br label %26
19: ; preds = %9
%20 = fneg double %3
%21 = tail call double @llvm.fmuladd.f64(double %20, double %3, double 0x3FE5555555555558)
%22 = fmul double %3, 5.000000e-01
%23 = fmul double %3, %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %3, double %21)
%25 = fmul double %7, %24
br label %26
26: ; preds = %2, %19, %13
%27 = phi double [ %18, %13 ], [ %25, %19 ], [ 0.000000e+00, %2 ]
ret double %27
}