#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 clumpf;
  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;
  clumpf = clumpnadir /
           (clumpnadir + (1.0 - clumpnadir) * exp(-2.2 * pow(viewangrad, p)));
  return (clumpf);
}


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,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeac(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe8b(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1192 <clump_factor+0x72>
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bb <clump_factor+0x9b>
movsd  -0x30(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b6 <clump_factor+0x96>
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bb <clump_factor+0x9b>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe29(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe25(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%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
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%12 = load double, double* %7
%13 = load double, double* %8
%14 = fdiv double %12, %13
store double %14, double* %11
%15 = load double, double* %11
%16 = call double @llvm.fmuladd.f64(double -4.600000e-01, double %15, double 3.800000e+00)
store double %16, double* %10
%17 = load double, double* %10
%18 = fcmp olt double %17, 1.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %4
store double 1.000000e+00, double* %10
br label %25
20: ; preds = %4
%21 = load double, double* %10
%22 = fcmp ogt double %21, 3.340000e+00
br i1 %22, label %23, label %24
23: ; preds = %20
store double 3.340000e+00, double* %10
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %19
%26 = load double, double* %5
%27 = load double, double* %5
%28 = load double, double* %5
%29 = fsub double 1.000000e+00, %28
%30 = load double, double* %6
%31 = load double, double* %10
%32 = call double @pow(double %30, double %31)
%33 = fmul double -2.200000e+00, %32
%34 = call double @exp(double %33)
%35 = call double @llvm.fmuladd.f64(double %29, double %34, double %27)
%36 = fdiv double %26, %35
store double %36, double* %9
%37 = load double, double* %9
ret double %37
}

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
}