#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);
float lkdrag(double, double, double, double, double);
void latsens(double Tsurf, double Tcutk, double hice, double tair, double wind,
             double pressure, double vp, double air_density, double *evap,
             double *qsen, double wind_h) {
  float dragcoeff;
  double eog, delT;
  double qair, qlake;
  double delq;
  if (hice > 0.)
    dragcoeff = lkdrag(Tsurf, tair + 273.15, wind, 0.005, wind_h);
  else
    dragcoeff = lkdrag(Tsurf, tair + 273.15, wind, 0.0045, wind_h);
  if ((hice <= 0.) && (Tsurf > Tcutk)) {
    eog = .611 * exp(17.269 * (Tsurf - 273.15) / (Tsurf + 237.3 - 273.15));
  } else {
    eog = .611 * exp(21.874 * (Tsurf - 273.15) / (Tsurf - 7.66));
  }
  qlake = 0.622 * (eog / (pressure - 0.378 * eog));
  qair = 0.622 * (vp / (pressure - 0.378 * vp));
  delq = qair - qlake;
  *evap = -1 * dragcoeff * wind * air_density * delq;
  delT = tair + 273.15 - Tsurf;
  *qsen = dragcoeff * wind * air_density * 1013.0;
  *qsen = *qsen * delT;
}


x86 assembly (clang, -O0):
<latsens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  0x10(%rbp),%xmm8
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  %xmm7,-0x40(%rbp)
mov    %rdi,-0x48(%rbp)
mov    %rsi,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a6 <latsens+0x86>
movsd  -0x8(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0x10(%rbp),%xmm4
movsd  0xe79(%rip),%xmm3
call   1040 <lkdrag@plt>
movss  %xmm0,-0x54(%rbp)
jmp    11d4 <latsens+0xb4>
movsd  -0x8(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0x10(%rbp),%xmm4
movsd  0xe36(%rip),%xmm3
call   1040 <lkdrag@plt>
movss  %xmm0,-0x54(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     124a <latsens+0x12a>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    124a <latsens+0x12a>
movsd  -0x8(%rbp),%xmm1
movsd  0xe09(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe2d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe19(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  0xde4(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xddc(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1295 <latsens+0x175>
movsd  -0x8(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xdc5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xdac(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xd8c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm0
movsd  0xda4(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xd88(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  0xd70(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xd54(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movss  0xd44(%rip),%xmm0
mulss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xccc(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xcda(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x68(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latsens>:
push   %r14
push   %rbx
sub    $0x58,%rsp
xorpd  %xmm8,%xmm8
xor    %eax,%eax
movsd  %xmm2,0x8(%rsp)
ucomisd %xmm8,%xmm2
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm7,0x30(%rsp)
movsd  %xmm6,0x20(%rsp)
movsd  %xmm5,0x18(%rsp)
movaps %xmm4,%xmm2
movapd %xmm3,%xmm5
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
seta   %al
movsd  0x70(%rsp),%xmm4
addsd  0xe8c(%rip),%xmm5
lea    0xee5(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm3
movsd  %xmm5,0x38(%rsp)
movapd %xmm5,%xmm1
movsd  %xmm2,0x28(%rsp)
call   1040 <lkdrag@plt>
movsd  (%rsp),%xmm2
movaps %xmm0,%xmm1
ucomisd 0x10(%rsp),%xmm2
movsd  0xe5d(%rip),%xmm0
addsd  %xmm2,%xmm0
movaps %xmm1,0x40(%rsp)
jbe    11e0 <latsens+0xc0>
xorpd  %xmm3,%xmm3
ucomisd 0x8(%rsp),%xmm3
jb     11e0 <latsens+0xc0>
mulsd  0xe56(%rip),%xmm0
movsd  0xe56(%rip),%xmm1
addsd  %xmm2,%xmm1
addsd  0xe2a(%rip),%xmm1
jmp    11f4 <latsens+0xd4>
mulsd  0xe28(%rip),%xmm0
movsd  0xe28(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  0xe2b(%rip),%xmm0
movsd  0xe2b(%rip),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
movsd  0xe15(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x20(%rsp),%xmm4
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
divsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
subsd  %xmm0,%xmm4
movaps 0xe20(%rip),%xmm0
movaps 0x40(%rsp),%xmm5
xorps  %xmm5,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x28(%rsp),%xmm3
mulsd  %xmm3,%xmm0
movsd  0x30(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm0,(%rbx)
movsd  0x38(%rsp),%xmm1
subsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm5,%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
mulsd  0xdae(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @latsens(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* %8, double* %9, double %10) {
%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*
%22 = alloca double
%23 = alloca float
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double* %8, double** %20
store double* %9, double** %21
store double %10, double* %22
%29 = load double, double* %14
%30 = fcmp ogt double %29, 0.000000e+00
br i1 %30, label %31, label %38
31: ; preds = %11
%32 = load double, double* %12
%33 = load double, double* %15
%34 = fadd double %33, 2.731500e+02
%35 = load double, double* %16
%36 = load double, double* %22
%37 = call float @lkdrag(double %32, double %34, double %35, double 5.000000e-03, double %36)
store float %37, float* %23
br label %45
38: ; preds = %11
%39 = load double, double* %12
%40 = load double, double* %15
%41 = fadd double %40, 2.731500e+02
%42 = load double, double* %16
%43 = load double, double* %22
%44 = call float @lkdrag(double %39, double %41, double %42, double 4.500000e-03, double %43)
store float %44, float* %23
br label %45
45: ; preds = %38, %31
%46 = load double, double* %14
%47 = fcmp ole double %46, 0.000000e+00
br i1 %47, label %48, label %62
48: ; preds = %45
%49 = load double, double* %12
%50 = load double, double* %13
%51 = fcmp ogt double %49, %50
br i1 %51, label %52, label %62
52: ; preds = %48
%53 = load double, double* %12
%54 = fsub double %53, 2.731500e+02
%55 = fmul double 1.726900e+01, %54
%56 = load double, double* %12
%57 = fadd double %56, 2.373000e+02
%58 = fsub double %57, 2.731500e+02
%59 = fdiv double %55, %58
%60 = call double @exp(double %59)
%61 = fmul double 0x3FE38D4FDF3B645A, %60
store double %61, double* %24
br label %71
62: ; preds = %48, %45
%63 = load double, double* %12
%64 = fsub double %63, 2.731500e+02
%65 = fmul double 2.187400e+01, %64
%66 = load double, double* %12
%67 = fsub double %66, 7.660000e+00
%68 = fdiv double %65, %67
%69 = call double @exp(double %68)
%70 = fmul double 0x3FE38D4FDF3B645A, %69
store double %70, double* %24
br label %71
71: ; preds = %62, %52
%72 = load double, double* %24
%73 = load double, double* %17
%74 = load double, double* %24
%75 = call double @llvm.fmuladd.f64(double -3.780000e-01, double %74, double %73)
%76 = fdiv double %72, %75
%77 = fmul double 6.220000e-01, %76
store double %77, double* %27
%78 = load double, double* %18
%79 = load double, double* %17
%80 = load double, double* %18
%81 = call double @llvm.fmuladd.f64(double -3.780000e-01, double %80, double %79)
%82 = fdiv double %78, %81
%83 = fmul double 6.220000e-01, %82
store double %83, double* %26
%84 = load double, double* %26
%85 = load double, double* %27
%86 = fsub double %84, %85
store double %86, double* %28
%87 = load float, float* %23
%88 = fmul float -1.000000e+00, %87
%89 = fpext float %88 to double
%90 = load double, double* %16
%91 = fmul double %89, %90
%92 = load double, double* %19
%93 = fmul double %91, %92
%94 = load double, double* %28
%95 = fmul double %93, %94
%96 = load double*, double** %20
store double %95, double* %96
%97 = load double, double* %15
%98 = fadd double %97, 2.731500e+02
%99 = load double, double* %12
%100 = fsub double %98, %99
store double %100, double* %25
%101 = load float, float* %23
%102 = fpext float %101 to double
%103 = load double, double* %16
%104 = fmul double %102, %103
%105 = load double, double* %19
%106 = fmul double %104, %105
%107 = fmul double %106, 1.013000e+03
%108 = load double*, double** %21
store double %107, double* %108
%109 = load double*, double** %21
%110 = load double, double* %109
%111 = load double, double* %25
%112 = fmul double %110, %111
%113 = load double*, double** %21
store double %112, double* %113
ret void
}

LLVM IR (-O2):
define void @latsens(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* nocapture writeonly %8, double* nocapture writeonly %9, double %10) {
%12 = fcmp ogt double %2, 0.000000e+00
%13 = fadd double %3, 2.731500e+02
%14 = select i1 %12, double 5.000000e-03, double 4.500000e-03
%15 = tail call float @lkdrag(double %0, double %13, double %4, double %14, double %10)
%16 = fcmp ole double %2, 0.000000e+00
%17 = fcmp ogt double %0, %1
%18 = and i1 %17, %16
%19 = fadd double %0, -2.731500e+02
br i1 %18, label %20, label %25
20: ; preds = %11
%21 = fmul double %19, 1.726900e+01
%22 = fadd double %0, 2.373000e+02
%23 = fadd double %22, -2.731500e+02
%24 = fdiv double %21, %23
br label %29
25: ; preds = %11
%26 = fmul double %19, 2.187400e+01
%27 = fadd double %0, -7.660000e+00
%28 = fdiv double %26, %27
br label %29
29: ; preds = %25, %20
%30 = phi double [ %28, %25 ], [ %24, %20 ]
%31 = tail call double @exp(double %30)
%32 = fmul double %31, 0x3FE38D4FDF3B645A
%33 = tail call double @llvm.fmuladd.f64(double %32, double -3.780000e-01, double %5)
%34 = fdiv double %32, %33
%35 = fmul double %34, 6.220000e-01
%36 = tail call double @llvm.fmuladd.f64(double %6, double -3.780000e-01, double %5)
%37 = fdiv double %6, %36
%38 = fmul double %37, 6.220000e-01
%39 = fsub double %38, %35
%40 = fneg float %15
%41 = fpext float %40 to double
%42 = fmul double %41, %4
%43 = fmul double %42, %7
%44 = fmul double %43, %39
store double %44, double* %8
%45 = fadd double %3, 2.731500e+02
%46 = fsub double %45, %0
%47 = fpext float %15 to double
%48 = fmul double %47, %4
%49 = fmul double %48, %7
%50 = fmul double %49, 1.013000e+03
%51 = fmul double %46, %50
store double %51, double* %9
ret void
}