#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 exp(double);
double svp_slope(double);
double penman(double tair, double elevation, double rad, double vpd, double ra,
              double rc, double rarc) {
  double evap;
  double slope;
  double r_air;
  double h;
  double lv;
  double pz;
  double gamma;
  slope = svp_slope(tair);
  h = 287 / 9.81 * ((tair + 273.15) + 0.5 * (double)elevation * -0.0065);
  pz = 101300 * exp(-(double)elevation / h);
  lv = 2501000 - 2361 * tair;
  gamma = 1628.6 * pz / lv;
  r_air = 0.003486 * pz / (275 + tair);
  evap = (slope * rad + r_air * 1013 * vpd / ra) /
         (lv * (slope + gamma * (1 + (rc + rarc) / ra))) * 86400.;
  if (vpd >= 0.0 && evap < 0.0)
    evap = 0.0;
  return evap;
}


x86 assembly (clang, -O0):
<penman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <svp_slope@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xef6(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xee1(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xecc(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xeb4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x58(%rbp),%xmm0
call   1030 <exp@plt>
imul   $0x18bb4,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe55(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe34(%rip),%xmm0
mulsd  -0x68(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe15(%rip),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  0xe00(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xdd8(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movsd  -0x70(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm5
addsd  -0x38(%rbp),%xmm5
divsd  -0x28(%rbp),%xmm5
movsd  0xd93(%rip),%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xd6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12c2 <penman+0x1a2>
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    12c2 <penman+0x1a2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<penman>:
sub    $0x58,%rsp
movsd  %xmm6,0x38(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movaps %xmm2,0x40(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1040 <svp_slope@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xea0(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0xe9a(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  0xe90(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
call   1030 <exp@plt>
imul   $0x18bb4,%eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe72(%rip),%xmm0
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm0
addsd  0xe68(%rip),%xmm0
movsd  0xe68(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  0xe64(%rip),%xmm1
divsd  %xmm0,%xmm2
addsd  0xe60(%rip),%xmm3
divsd  %xmm3,%xmm1
mulsd  0xe5c(%rip),%xmm1
movsd  0x20(%rsp),%xmm4
mulsd  %xmm4,%xmm1
movsd  0x28(%rsp),%xmm5
divsd  %xmm5,%xmm1
movapd 0x40(%rsp),%xmm3
movsd  0x18(%rsp),%xmm6
mulsd  %xmm6,%xmm3
addsd  %xmm1,%xmm3
movsd  0x30(%rsp),%xmm1
addsd  0x38(%rsp),%xmm1
divsd  %xmm5,%xmm1
addsd  0xe24(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm6,%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
mulsd  0xe14(%rip),%xmm3
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
cmplesd %xmm4,%xmm1
maxsd  %xmm3,%xmm0
andpd  %xmm1,%xmm0
andnpd %xmm3,%xmm1
orpd   %xmm1,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @penman(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%22 = load double, double* %8
%23 = call double @svp_slope(double %22)
store double %23, double* %16
%24 = load double, double* %8
%25 = fadd double %24, 2.731500e+02
%26 = load double, double* %9
%27 = fmul double 5.000000e-01, %26
%28 = call double @llvm.fmuladd.f64(double %27, double 0xBF7A9FBE76C8B439, double %25)
%29 = fmul double 0x403D418021671418, %28
store double %29, double* %18
%30 = load double, double* %9
%31 = fneg double %30
%32 = load double, double* %18
%33 = fdiv double %31, %32
%34 = call i32 @exp(double %33)
%35 = mul nsw i32 101300, %34
%36 = sitofp i32 %35 to double
store double %36, double* %20
%37 = load double, double* %8
%38 = call double @llvm.fmuladd.f64(double -2.361000e+03, double %37, double 2.501000e+06)
store double %38, double* %19
%39 = load double, double* %20
%40 = fmul double 1.628600e+03, %39
%41 = load double, double* %19
%42 = fdiv double %40, %41
store double %42, double* %21
%43 = load double, double* %20
%44 = fmul double 3.486000e-03, %43
%45 = load double, double* %8
%46 = fadd double 2.750000e+02, %45
%47 = fdiv double %44, %46
store double %47, double* %17
%48 = load double, double* %16
%49 = load double, double* %10
%50 = load double, double* %17
%51 = fmul double %50, 1.013000e+03
%52 = load double, double* %11
%53 = fmul double %51, %52
%54 = load double, double* %12
%55 = fdiv double %53, %54
%56 = call double @llvm.fmuladd.f64(double %48, double %49, double %55)
%57 = load double, double* %19
%58 = load double, double* %16
%59 = load double, double* %21
%60 = load double, double* %13
%61 = load double, double* %14
%62 = fadd double %60, %61
%63 = load double, double* %12
%64 = fdiv double %62, %63
%65 = fadd double 1.000000e+00, %64
%66 = call double @llvm.fmuladd.f64(double %59, double %65, double %58)
%67 = fmul double %57, %66
%68 = fdiv double %56, %67
%69 = fmul double %68, 8.640000e+04
store double %69, double* %15
%70 = load double, double* %11
%71 = fcmp oge double %70, 0.000000e+00
br i1 %71, label %72, label %76
72: ; preds = %7
%73 = load double, double* %15
%74 = fcmp olt double %73, 0.000000e+00
br i1 %74, label %75, label %76
75: ; preds = %72
store double 0.000000e+00, double* %15
br label %76
76: ; preds = %75, %72, %7
%77 = load double, double* %15
ret double %77
}

LLVM IR (-O2):
define double @penman(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call double @svp_slope(double %0)
%9 = fadd double %0, 2.731500e+02
%10 = fmul double %1, 5.000000e-01
%11 = tail call double @llvm.fmuladd.f64(double %10, double 0xBF7A9FBE76C8B439, double %9)
%12 = fmul double %11, 0x403D418021671418
%13 = fneg double %1
%14 = fdiv double %13, %12
%15 = tail call i32 @exp(double %14)
%16 = mul nsw i32 %15, 101300
%17 = sitofp i32 %16 to double
%18 = tail call double @llvm.fmuladd.f64(double %0, double -2.361000e+03, double 2.501000e+06)
%19 = fmul double %17, 1.628600e+03
%20 = fdiv double %19, %18
%21 = fmul double %17, 3.486000e-03
%22 = fadd double %0, 2.750000e+02
%23 = fdiv double %21, %22
%24 = fmul double %23, 1.013000e+03
%25 = fmul double %24, %3
%26 = fdiv double %25, %4
%27 = tail call double @llvm.fmuladd.f64(double %8, double %2, double %26)
%28 = fadd double %5, %6
%29 = fdiv double %28, %4
%30 = fadd double %29, 1.000000e+00
%31 = tail call double @llvm.fmuladd.f64(double %20, double %30, double %8)
%32 = fmul double %18, %31
%33 = fdiv double %27, %32
%34 = fmul double %33, 8.640000e+04
%35 = fcmp oge double %3, 0.000000e+00
%36 = fcmp olt double %34, 0.000000e+00
%37 = select i1 %35, i1 %36, i1 false
%38 = select i1 %37, double 0.000000e+00, double %34
ret double %38
}