#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 exp(double);
double pow(double, double);
double clump_factor(double clumpnadir, double viewangrad, double canopy_ht,
                    double canopy_wdth) {
  double p, D;
  D = canopy_ht / canopy_wdth;
  p = 3.80 - 0.46 * D;
  if (p < 1.0)
    p = 1.0;
  else if (p > 3.34)
    p = 3.34;
  return (clumpnadir /
          (clumpnadir + (1.0 - clumpnadir) * exp(-2.2 * pow(viewangrad, p))));
}


x86 assembly (clang, -O0):
<clump_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeac(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8b(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1192 <clump_factor+0x72>
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11bb <clump_factor+0x9b>
movsd  -0x28(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b6 <clump_factor+0x96>
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11bb <clump_factor+0x9b>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe29(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe25(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clump_factor>:
sub    $0x18,%rsp
divsd  %xmm3,%xmm2
mulsd  0xed0(%rip),%xmm2
addsd  0xed0(%rip),%xmm2
movapd %xmm1,%xmm3
movsd  0xecc(%rip),%xmm4
ucomisd %xmm2,%xmm4
movapd %xmm4,%xmm1
ja     1164 <clump_factor+0x44>
ucomisd 0xec2(%rip),%xmm2
movapd %xmm2,%xmm1
jbe    1164 <clump_factor+0x44>
movsd  0xeb4(%rip),%xmm1
subsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,%xmm0
call   1040 <pow@plt>
mulsd  0xe9b(%rip),%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @clump_factor(double %0, double %1, double %2, double %3) {
%5 = fdiv double %2, %3
%6 = tail call double @llvm.fmuladd.f64(double %5, double -4.600000e-01, double 3.800000e+00)
%7 = fcmp olt double %6, 1.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = fcmp ogt double %6, 3.340000e+00
br i1 %9, label %10, label %11
10: ; preds = %8
br label %11
11: ; preds = %4, %8, %10
%12 = phi double [ 3.340000e+00, %10 ], [ %6, %8 ], [ 1.000000e+00, %4 ]
%13 = fsub double 1.000000e+00, %0
%14 = tail call double @pow(double %1, double %12)
%15 = fmul double %14, -2.200000e+00
%16 = tail call double @exp(double %15)
%17 = tail call double @llvm.fmuladd.f64(double %13, double %16, double %0)
%18 = fdiv double %0, %17
ret double %18
}