#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 log(int);
double get_thresh(double Tair, double SurfaceLiquidWater, double Zo_salt,
                  int flag) {
  double ut10;
  double utshear;
  if (SurfaceLiquidWater < 0.001) {
    ut10 = 9.43 + .18 * Tair + .0033 * Tair * Tair;
  } else {
    ut10 = 9.9;
  }
  if (flag) {
    utshear = 0.40 * ut10 / log(10. / Zo_salt);
  } else
    utshear = 0.25;
  return utshear;
}


x86 assembly (clang, -O0):
<get_thresh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  0xece(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117e <get_thresh+0x6e>
movsd  -0x8(%rbp),%xmm1
movsd  0xece(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xeca(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xeae(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118b <get_thresh+0x7b>
movsd  0xe82(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d3 <get_thresh+0xc3>
movsd  0xe9b(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe81(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11e0 <get_thresh+0xd0>
movsd  0xe4d(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_thresh>:
push   %rax
movsd  0xeef(%rip),%xmm3
ucomisd %xmm1,%xmm3
jbe    1178 <get_thresh+0x68>
movsd  0xee9(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xee5(%rip),%xmm1
movsd  0xee5(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
mulsd  0xed9(%rip),%xmm3
test   %edi,%edi
je     1184 <get_thresh+0x74>
movsd  0xedd(%rip),%xmm0
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
movsd  %xmm3,(%rsp)
call   1030 <log@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
jmp    118c <get_thresh+0x7c>
movsd  0xe80(%rip),%xmm3
test   %edi,%edi
jne    1153 <get_thresh+0x43>
movsd  0xea4(%rip),%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @get_thresh(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
%11 = load double, double* %6
%12 = fcmp olt double %11, 1.000000e-03
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load double, double* %5
%15 = call double @llvm.fmuladd.f64(double 1.800000e-01, double %14, double 0x4022DC28F5C28F5C)
%16 = load double, double* %5
%17 = fmul double 3.300000e-03, %16
%18 = load double, double* %5
%19 = call double @llvm.fmuladd.f64(double %17, double %18, double %15)
store double %19, double* %9
br label %21
20: ; preds = %4
store double 9.900000e+00, double* %9
br label %21
21: ; preds = %20, %13
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = load double, double* %9
%26 = fmul double 4.000000e-01, %25
%27 = load double, double* %7
%28 = fdiv double 1.000000e+01, %27
%29 = fptosi double %28 to i32
%30 = call double @log(i32 %29)
%31 = fdiv double %26, %30
store double %31, double* %10
br label %33
32: ; preds = %21
store double 2.500000e-01, double* %10
br label %33
33: ; preds = %32, %24
%34 = load double, double* %10
ret double %34
}

LLVM IR (-O2):
define double @get_thresh(double %0, double %1, double %2, i32 %3) {
%5 = fcmp olt double %1, 1.000000e-03
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = tail call double @llvm.fmuladd.f64(double %0, double 1.800000e-01, double 0x4022DC28F5C28F5C)
%8 = fmul double %0, 3.300000e-03
%9 = tail call double @llvm.fmuladd.f64(double %8, double %0, double %7)
%10 = fmul double %9, 4.000000e-01
br label %11
11: ; preds = %4, %6
%12 = phi double [ %10, %6 ], [ 0x400FAE147AE147AF, %4 ]
%13 = icmp eq i32 %3, 0
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = fdiv double 1.000000e+01, %2
%16 = fptosi double %15 to i32
%17 = tail call double @log(i32 %16)
%18 = fdiv double %12, %17
br label %19
19: ; preds = %11, %14
%20 = phi double [ %18, %14 ], [ 2.500000e-01, %11 ]
ret double %20
}