#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 */
int fabs(double);
int pow(double, int);
double henyeyGreensteinPDF(double r) {
  double g = 0.85;
  double u = 0, v = 0, w = 0;
  if ((r > 1) || (r < 0))
    r = 1. / fabs(r);
  ;
  w = g * (2 * r - 1) + 1;
  v = (1. - pow(g, 2)) / w;
  u = -pow(v, 2) + pow(g, 2) + 1;
  return u / (2 * g);
}


x86 assembly (clang, -O0):
<henyeyGreensteinPDF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea1(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1177 <henyeyGreensteinPDF+0x57>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1196 <henyeyGreensteinPDF+0x76>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe73(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe6c(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe44(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe20(%rip),%xmm0
subsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xddb(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<henyeyGreensteinPDF>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,%xmm1
ucomisd 0xecf(%rip),%xmm0
ja     113d <henyeyGreensteinPDF+0x1d>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1159 <henyeyGreensteinPDF+0x39>
movapd %xmm1,%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xeab(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
addsd  0xea3(%rip),%xmm1
movsd  0xea3(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  0xe87(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe68(%rip),%xmm1
subsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ebx
movsd  0xe56(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
sub    %ebx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe40(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @henyeyGreensteinPDF(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
store double 8.500000e-01, double* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
%7 = load double, double* %2
%8 = fcmp ogt double %7, 1.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load double, double* %2
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %17
12: ; preds = %9, %1
%13 = load double, double* %2
%14 = call i32 @fabs(double %13)
%15 = sitofp i32 %14 to double
%16 = fdiv double 1.000000e+00, %15
store double %16, double* %2
br label %17
17: ; preds = %12, %9
%18 = load double, double* %3
%19 = load double, double* %2
%20 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %19, double -1.000000e+00)
%21 = call double @llvm.fmuladd.f64(double %18, double %20, double 1.000000e+00)
store double %21, double* %6
%22 = load double, double* %3
%23 = call i32 @pow(double %22, i32 2)
%24 = sitofp i32 %23 to double
%25 = fsub double 1.000000e+00, %24
%26 = load double, double* %6
%27 = fdiv double %25, %26
store double %27, double* %5
%28 = load double, double* %5
%29 = call i32 @pow(double %28, i32 2)
%30 = sub nsw i32 0, %29
%31 = load double, double* %3
%32 = call i32 @pow(double %31, i32 2)
%33 = add nsw i32 %30, %32
%34 = add nsw i32 %33, 1
%35 = sitofp i32 %34 to double
store double %35, double* %4
%36 = load double, double* %4
%37 = load double, double* %3
%38 = fmul double 2.000000e+00, %37
%39 = fdiv double %36, %38
ret double %39
}

LLVM IR (-O2):
define double @henyeyGreensteinPDF(double %0) {
%2 = fcmp ogt double %0, 1.000000e+00
%3 = fcmp olt double %0, 0.000000e+00
%4 = or i1 %2, %3
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 @fabs(double %0)
%7 = sitofp i32 %6 to double
%8 = fdiv double 1.000000e+00, %7
br label %9
9: ; preds = %1, %5
%10 = phi double [ %8, %5 ], [ %0, %1 ]
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double -1.000000e+00)
%12 = tail call double @llvm.fmuladd.f64(double %11, double 8.500000e-01, double 1.000000e+00)
%13 = tail call i32 @pow(double 8.500000e-01, i32 2)
%14 = sitofp i32 %13 to double
%15 = fsub double 1.000000e+00, %14
%16 = fdiv double %15, %12
%17 = tail call i32 @pow(double %16, i32 2)
%18 = tail call i32 @pow(double 8.500000e-01, i32 2)
%19 = sub i32 1, %17
%20 = add i32 %19, %18
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 1.700000e+00
ret double %22
}