#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 /*<<< orphan*/ free(char *);
double le_eval(int, char **);
int /*<<< orphan*/ le_init();
int le_loadexpr(char *, char **);
int /*<<< orphan*/ le_setvar(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int cookie, cookie2;
  int k;
  char *msg = NULL, *msg2 = NULL;
  if (!le_init()) {
    printf("can't init LE\n");
    return 1;
  }
  if (argc < 3) {
    printf("Usage: t-le \"write_cost\" \"read_cost\"\n");
    return 1;
  }
  cookie = le_loadexpr(argv[1], &msg);
  if (msg) {
    printf("can't load: %s\n", msg);
    free(msg);
    return 1;
  }
  cookie2 = le_loadexpr(argv[2], &msg2);
  if (msg2) {
    printf("can't load: %s\n", msg2);
    free(msg2);
    return 1;
  }
  printf("  x    wr    rd\n"
         "------ --------\n");
  for (k = 1; k < 11; ++k) {
    double r, w;
    le_setvar("N", 41652230);
    le_setvar("E", 1468365182);
    le_setvar("k", k);
    w = le_eval(cookie, &msg);
    if (msg) {
      printf("can't eval: %s\n", msg);
      free(msg);
      return 1;
    }
    r = le_eval(cookie2, &msg2);
    if (msg2) {
      printf("can't eval: %s\n", msg2);
      free(msg2);
      return 1;
    }
    printf("%2d %15.3f %15.3f %1.4f\n", k, w, r, w / r);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   1080 <le_init@plt>
cmp    $0x0,%eax
jne    11b0 <main+0x50>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
cmpl   $0x3,-0x8(%rbp)
jge    11d4 <main+0x74>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <le_loadexpr@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     121a <main+0xba>
mov    -0x28(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <le_loadexpr@plt>
mov    %eax,-0x18(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1260 <main+0x100>
mov    -0x30(%rbp),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0xb,-0x1c(%rbp)
jge    1369 <main+0x209>
lea    0xde0(%rip),%rdi
mov    $0x27b9006,%esi
call   1070 <le_setvar@plt>
lea    0xdd1(%rip),%rdi
mov    $0x5785797e,%esi
call   1070 <le_setvar@plt>
mov    -0x1c(%rbp),%esi
lea    0xdbf(%rip),%rdi
call   1070 <le_setvar@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <le_eval@plt>
movsd  %xmm0,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12f3 <main+0x193>
mov    -0x28(%rbp),%rsi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <le_eval@plt>
movsd  %xmm0,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1336 <main+0x1d6>
mov    -0x30(%rbp),%rsi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1369 <main+0x209>
mov    -0x1c(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
divsd  -0x38(%rbp),%xmm2
lea    0xd28(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1275 <main+0x115>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
xor    %eax,%eax
call   1090 <le_init@plt>
test   %eax,%eax
je     11ad <main+0x3d>
cmp    $0x2,%ebx
jg     11bb <main+0x4b>
lea    0xec0(%rip),%rdi
jmp    11b4 <main+0x44>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
jmp    1216 <main+0xa6>
mov    0x8(%rbp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <le_loadexpr@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     11e8 <main+0x78>
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
jmp    1211 <main+0xa1>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
mov    %rsp,%rsi
call   1070 <le_loadexpr@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     122a <main+0xba>
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r14d
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
lea    0xdcd(%rip),%r13
lea    0x8(%rsp),%r15
mov    %rsp,%r12
nopl   (%rax)
lea    0xdb9(%rip),%rdi
mov    $0x27b9006,%esi
call   1080 <le_setvar@plt>
lea    0xde1(%rip),%rdi
mov    $0x5785797e,%esi
call   1080 <le_setvar@plt>
mov    %r13,%rdi
mov    %ebp,%esi
call   1080 <le_setvar@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1060 <le_eval@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jne    12df <main+0x16f>
movsd  %xmm0,0x10(%rsp)
mov    %r14d,%edi
mov    %r12,%rsi
call   1060 <le_eval@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
jne    12eb <main+0x17b>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xd61(%rip),%rdi
mov    %ebp,%esi
mov    $0x3,%al
call   1050 <printf@plt>
add    $0x1,%ebp
xor    %eax,%eax
cmp    $0xb,%ebp
jne    1250 <main+0xe0>
jmp    121b <main+0xab>
lea    0xd2e(%rip),%rdi
jmp    11da <main+0x6a>
lea    0xd22(%rip),%rdi
jmp    1206 <main+0x96>

LLVM IR (-O0):
@.str = [15 x i8] c"can't init LE\0A\00"
@.str.1 = [38 x i8] c"Usage: t-le \22write_cost\22 \22read_cost\22\0A\00"
@.str.2 = [16 x i8] c"can't load: %s\0A\00"
@.str.3 = [33 x i8] c" x wr rd\0A------ --------\0A\00"
@.str.4 = [2 x i8] c"N\00"
@.str.5 = [2 x i8] c"E\00"
@.str.6 = [2 x i8] c"k\00"
@.str.7 = [16 x i8] c"can't eval: %s\0A\00"
@.str.8 = [25 x i8] c"%2d %15.3f %15.3f %1.4f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca double
%12 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %9
store i8* null, i8** %10
%13 = call i32 (...) @le_init()
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %86
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %86
22: ; preds = %17
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @le_loadexpr(i8* %25, i8** %9)
store i32 %26, i32* %6
%27 = load i8*, i8** %9
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i8*, i8** %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %9
%33 = call i32 @free(i8* %32)
store i32 1, i32* %3
br label %86
34: ; preds = %22
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @le_loadexpr(i8* %37, i8** %10)
store i32 %38, i32* %7
%39 = load i8*, i8** %10
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %46
41: ; preds = %34
%42 = load i8*, i8** %10
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %10
%45 = call i32 @free(i8* %44)
store i32 1, i32* %3
br label %86
46: ; preds = %34
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %8
br label %48
48: ; preds = %83, %46
%49 = load i32, i32* %8
%50 = icmp slt i32 %49, 11
br i1 %50, label %51, label %86
51: ; preds = %48
%52 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 41652230)
%53 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1468365182)
%54 = load i32, i32* %8
%55 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %6
%57 = call double @le_eval(i32 %56, i8** %9)
store double %57, double* %12
%58 = load i8*, i8** %9
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %65
60: ; preds = %51
%61 = load i8*, i8** %9
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
store i32 1, i32* %3
br label %86
65: ; preds = %51
%66 = load i32, i32* %7
%67 = call double @le_eval(i32 %66, i8** %10)
store double %67, double* %11
%68 = load i8*, i8** %10
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %75
70: ; preds = %65
%71 = load i8*, i8** %10
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** %10
%74 = call i32 @free(i8* %73)
store i32 1, i32* %3
br label %86
75: ; preds = %65
%76 = load i32, i32* %8
%77 = load double, double* %12
%78 = load double, double* %11
%79 = load double, double* %12
%80 = load double, double* %11
%81 = fdiv double %79, %80
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %76, double %77, double %78, double %81)
br label %83
83: ; preds = %75
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %48
86: ; preds = %15, %20, %29, %41, %60, %70, %48
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"can't load: %s\0A\00"
@.str.4 = [2 x i8] c"N\00"
@.str.5 = [2 x i8] c"E\00"
@.str.6 = [2 x i8] c"k\00"
@.str.7 = [16 x i8] c"can't eval: %s\0A\00"
@.str.8 = [25 x i8] c"%2d %15.3f %15.3f %1.4f\0A\00"
@str = [14 x i8] c"can't init LE\00"
@str.9 = [32 x i8] c" x wr rd\0A------ --------\00"
@str.10 = [37 x i8] c"Usage: t-le \22write_cost\22 \22read_cost\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = tail call i32 (...) @le_init()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %62
11: ; preds = %2
%12 = icmp slt i32 %0, 3
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
br label %62
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @le_loadexpr(i8* %17, i8** %3)
%19 = load i8*, i8** %3
%20 = icmp eq i8* %19, null
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
br label %62
25: ; preds = %15
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @le_loadexpr(i8* %27, i8** %4)
%29 = load i8*, i8** %4
%30 = icmp eq i8* %29, null
br i1 %30, label %35, label %31
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%33 = load i8*, i8** %4
%34 = call i32 @free(i8* %33)
br label %62
35: ; preds = %25
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %37
37: ; preds = %35, %57
%38 = phi i32 [ 1, %35 ], [ %60, %57 ]
%39 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 41652230)
%40 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1468365182)
%41 = call i32 @le_setvar(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%42 = call double @le_eval(i32 %18, i8** %3)
%43 = load i8*, i8** %3
%44 = icmp eq i8* %43, null
br i1 %44, label %49, label %45
45: ; preds = %37
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %43)
%47 = load i8*, i8** %3
%48 = call i32 @free(i8* %47)
br label %62
49: ; preds = %37
%50 = call double @le_eval(i32 %28, i8** %4)
%51 = load i8*, i8** %4
%52 = icmp eq i8* %51, null
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %51)
%55 = load i8*, i8** %4
%56 = call i32 @free(i8* %55)
br label %62
57: ; preds = %49
%58 = fdiv double %42, %50
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %38, double %42, double %50, double %58)
%60 = add nuw nsw i32 %38, 1
%61 = icmp eq i32 %60, 11
br i1 %61, label %62, label %37
62: ; preds = %57, %45, %53, %31, %21, %13, %9
%63 = phi i32 [ 1, %13 ], [ 1, %21 ], [ 1, %31 ], [ 1, %9 ], [ 1, %53 ], [ 1, %45 ], [ 0, %57 ]
ret i32 %63
}