#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);
int /*<<< orphan*/ printf(char *);
double lai(double ndvi, int libcropcode) {
  if (libcropcode == 0) {
    printf("unknown crop\n");
    return (-28768);
  }
  if (libcropcode == 1) {
    printf("CIA Corn 2008-2010 (unpublished)\n");
    return (3.2658 * log(ndvi) + 6.9212);
  }
}


x86 assembly (clang, -O0):
<lai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1158 <lai+0x38>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1195 <lai+0x75>
cmpl   $0x1,-0x14(%rbp)
jne    1195 <lai+0x75>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  0xe80(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lai>:
push   %rax
cmp    $0x1,%edi
je     1140 <lai+0x20>
test   %edi,%edi
jne    1136 <lai+0x16>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
movsd  0xed2(%rip),%xmm0
pop    %rax
ret
lea    0xed1(%rip),%rdi
movsd  %xmm0,(%rsp)
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
call   1040 <log@plt>
mulsd  0xe9d(%rip),%xmm0
addsd  0xe9d(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"unknown crop\0A\00"
@.str.1 = [34 x i8] c"CIA Corn 2008-2010 (unpublished)\0A\00"
define double @lai(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store double -2.876800e+04, double* %3
br label %18
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%15 = load double, double* %4
%16 = call double @log(double %15)
%17 = call double @llvm.fmuladd.f64(double 3.265800e+00, double %16, double 6.921200e+00)
store double %17, double* %3
br label %18
18: ; preds = %8, %13, %10
%19 = load double, double* %3
ret double %19
}

LLVM IR (-O2):
@str = [33 x i8] c"CIA Corn 2008-2010 (unpublished)\00"
@str.2 = [13 x i8] c"unknown crop\00"
define double @lai(double %0, i32 %1) {
switch i32 %1, label %9 [
i32 0, label %3
i32 1, label %5
]
3: ; preds = %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.2, i64 0, i64 0))
br label %9
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = tail call double @log(double %0)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 3.265800e+00, double 6.921200e+00)
br label %9
9: ; preds = %2, %3, %5
%10 = phi double [ -2.876800e+04, %3 ], [ %8, %5 ], [ undef, %2 ]
ret double %10
}