#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 pow(double, double);
double frac_cover_choud(double ndvi_min, double ndvi_max, double ndvi_obs,
                        double choud_p) {
  double nc, fcover;
  double ndviscale = 0.999;
  if (ndvi_obs > ndviscale * ndvi_max)
    ndvi_obs = ndviscale * ndvi_max;
  else if (ndvi_obs < ndvi_min)
    ndvi_obs = ndvi_min;
  nc = (ndvi_max - ndvi_obs) / (ndvi_max - ndvi_min);
  fcover = 1.0 - pow(nc, choud_p);
  return (fcover);
}


x86 assembly (clang, -O0):
<frac_cover_choud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1166 <frac_cover_choud+0x56>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1189 <frac_cover_choud+0x79>
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1184 <frac_cover_choud+0x74>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1189 <frac_cover_choud+0x79>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe48(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frac_cover_choud>:
push   %rax
movsd  0xee7(%rip),%xmm4
mulsd  %xmm1,%xmm4
ucomisd %xmm4,%xmm2
ja     1131 <frac_cover_choud+0x21>
ucomisd %xmm2,%xmm0
movapd %xmm2,%xmm4
jbe    1131 <frac_cover_choud+0x21>
movapd %xmm0,%xmm4
movapd %xmm1,%xmm2
subsd  %xmm4,%xmm2
subsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
movaps %xmm3,%xmm1
call   1030 <pow@plt>
movsd  0xeb3(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @frac_cover_choud(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
store double 0x3FEFF7CED916872B, double* %11
%12 = load double, double* %7
%13 = load double, double* %11
%14 = load double, double* %6
%15 = fmul double %13, %14
%16 = fcmp ogt double %12, %15
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load double, double* %11
%19 = load double, double* %6
%20 = fmul double %18, %19
store double %20, double* %7
br label %28
21: ; preds = %4
%22 = load double, double* %7
%23 = load double, double* %5
%24 = fcmp olt double %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load double, double* %5
store double %26, double* %7
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27, %17
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fsub double %29, %30
%32 = load double, double* %6
%33 = load double, double* %5
%34 = fsub double %32, %33
%35 = fdiv double %31, %34
store double %35, double* %9
%36 = load double, double* %9
%37 = load double, double* %8
%38 = call double @pow(double %36, double %37)
%39 = fsub double 1.000000e+00, %38
store double %39, double* %10
%40 = load double, double* %10
ret double %40
}

LLVM IR (-O2):
define double @frac_cover_choud(double %0, double %1, double %2, double %3) {
%5 = fmul double %1, 0x3FEFF7CED916872B
%6 = fcmp olt double %5, %2
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = fcmp olt double %2, %0
br i1 %8, label %9, label %10
9: ; preds = %7
br label %10
10: ; preds = %4, %7, %9
%11 = phi double [ %0, %9 ], [ %2, %7 ], [ %5, %4 ]
%12 = fsub double %1, %11
%13 = fsub double %1, %0
%14 = fdiv double %12, %13
%15 = tail call double @pow(double %14, double %3)
%16 = fsub double 1.000000e+00, %15
ret double %16
}