#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(double);
double LAI_choudfunc(double frac_cover, double Beta) {
  double LAI;
  if (frac_cover < 0.0)
    LAI = -1;
  else if (frac_cover >= 1.0)
    LAI = -2;
  else
    LAI = -(log(1.0 - frac_cover)) / Beta;
  return (LAI);
}


x86 assembly (clang, -O0):
<LAI_choudfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1142 <LAI_choudfunc+0x32>
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a3 <LAI_choudfunc+0x93>
movsd  -0x8(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     116b <LAI_choudfunc+0x5b>
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119e <LAI_choudfunc+0x8e>
movsd  0xe8d(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a3 <LAI_choudfunc+0x93>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LAI_choudfunc>:
push   %rax
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    1125 <LAI_choudfunc+0x15>
movsd  0xedd(%rip),%xmm0
pop    %rax
ret
ucomisd 0xee3(%rip),%xmm0
jae    1158 <LAI_choudfunc+0x48>
movsd  0xed9(%rip),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <log@plt>
xorpd  0xecf(%rip),%xmm0
divsd  (%rsp),%xmm0
pop    %rax
ret
movsd  0xea8(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @LAI_choudfunc(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %2
store double -1.000000e+00, double* %5
br label %21
9: ; preds = %2
%10 = load double, double* %3
%11 = fcmp oge double %10, 1.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
store double -2.000000e+00, double* %5
br label %20
13: ; preds = %9
%14 = load double, double* %3
%15 = fsub double 1.000000e+00, %14
%16 = call double @log(double %15)
%17 = fneg double %16
%18 = load double, double* %4
%19 = fdiv double %17, %18
store double %19, double* %5
br label %20
20: ; preds = %13, %12
br label %21
21: ; preds = %20, %8
%22 = load double, double* %5
ret double %22
}

LLVM IR (-O2):
define double @LAI_choudfunc(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = fcmp ult double %0, 1.000000e+00
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = fsub double 1.000000e+00, %0
%8 = tail call double @log(double %7)
%9 = fneg double %8
%10 = fdiv double %9, %1
br label %11
11: ; preds = %4, %2, %6
%12 = phi double [ %10, %6 ], [ -1.000000e+00, %2 ], [ -2.000000e+00, %4 ]
ret double %12
}