#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(double, double);
double pr_sphere(double R, double r) {
  if (r <= 2.0 * R) {
    return 12.0 * pow(0.5 * r / R, 2.0) * pow(1.0 - 0.5 * r / R, 2.0) *
           (2.0 + 0.5 * r / R);
  } else {
    return 0.0;
  }
}


x86 assembly (clang, -O0):
<pr_sphere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xed1(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11d4 <pr_sphere+0xc4>
movsd  0xec2(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xeb0(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8f(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xe85(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe69(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
divsd  -0x10(%rbp),%xmm2
movsd  0xe3e(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <pr_sphere+0xcc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_sphere>:
movapd %xmm0,%xmm3
addsd  %xmm0,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm3
jb     1152 <pr_sphere+0x52>
mulsd  0xee6(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xeda(%rip),%xmm0
movsd  0xeda(%rip),%xmm2
subsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm2
addsd  0xece(%rip),%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm2
movapd %xmm2,%xmm0
ret

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

LLVM IR (-O2):
define double @pr_sphere(double %0, double %1) {
%3 = fmul double %0, 2.000000e+00
%4 = fcmp ult double %3, %1
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = fmul double %1, 5.000000e-01
%7 = fdiv double %6, %0
%8 = fmul double %7, %7
%9 = fmul double %8, 1.200000e+01
%10 = fsub double 1.000000e+00, %7
%11 = fmul double %10, %10
%12 = fmul double %9, %11
%13 = fadd double %7, 2.000000e+00
%14 = fmul double %13, %12
br label %15
15: ; preds = %2, %5
%16 = phi double [ %14, %5 ], [ 0.000000e+00, %2 ]
ret double %16
}