#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 */
int log(double);
double pow(int, int);
int /*<<< orphan*/ printf(char *);
double z0m(double crop_age, int libcropcode) {
  if (libcropcode == 0) {
    printf("unknown crop\n");
    return (-28768);
  }
  if (libcropcode == 1) {
    printf("CIA Corn 2008-2010 (unpublished)\n");
    return (log(crop_age - 24) / 10 - 0.1 * pow(crop_age, 2) / pow(181, 2));
  }
}


x86 assembly (clang, -O0):
<z0m>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1168 <z0m+0x38>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f1 <z0m+0xc1>
cmpl   $0x1,-0x14(%rbp)
jne    11f1 <z0m+0xc1>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <log@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x10(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe41(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0xb5,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<z0m>:
sub    $0x18,%rsp
cmp    $0x1,%edi
je     115a <z0m+0x2a>
test   %edi,%edi
jne    11e3 <z0m+0xb3>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
movsd  0xebb(%rip),%xmm0
add    $0x18,%rsp
ret
lea    0xeb7(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <puts@plt>
movsd  0xe8c(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si 0x8(%rsp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mulsd  0xe4e(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xb5,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
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 @z0m(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 %27
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %27
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 = fsub double %15, 2.400000e+01
%17 = call i32 @log(double %16)
%18 = sdiv i32 %17, 10
%19 = sitofp i32 %18 to double
%20 = load double, double* %4
%21 = fptosi double %20 to i32
%22 = call double @pow(i32 %21, i32 2)
%23 = fmul double 1.000000e-01, %22
%24 = call double @pow(i32 181, i32 2)
%25 = fdiv double %23, %24
%26 = fsub double %19, %25
store double %26, double* %3
br label %27
27: ; preds = %8, %13, %10
%28 = load double, double* %3
ret double %28
}

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 @z0m(double %0, i32 %1) {
switch i32 %1, label %17 [
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 %17
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 = fadd double %0, -2.400000e+01
%8 = tail call i32 @log(double %7)
%9 = sdiv i32 %8, 10
%10 = sitofp i32 %9 to double
%11 = fptosi double %0 to i32
%12 = tail call double @pow(i32 %11, i32 2)
%13 = fmul double %12, 1.000000e-01
%14 = tail call double @pow(i32 181, i32 2)
%15 = fdiv double %13, %14
%16 = fsub double %10, %15
br label %17
17: ; preds = %2, %3, %5
%18 = phi double [ -2.876800e+04, %3 ], [ %16, %5 ], [ undef, %2 ]
ret double %18
}