#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeVM();
int /*<<< orphan*/ initVM();
int /*<<< orphan*/ repl();
int /*<<< orphan*/ runFile(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  initVM();
  if (argc == 1)
    repl();
  else if (argc == 2)
    runFile(argv[1]);
  else {
    fprintf(stderr, "Usage: clox [path]\n");
    exit(64);
  }
  freeVM();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <initVM@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1193 <main+0x33>
mov    $0x0,%al
call   1030 <repl@plt>
jmp    11d3 <main+0x73>
cmpl   $0x2,-0x8(%rbp)
jne    11af <main+0x4f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <runFile@plt>
jmp    11ce <main+0x6e>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x40,%edi
call   1080 <exit@plt>
jmp    11d3 <main+0x73>
mov    $0x0,%al
call   1070 <freeVM@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <initVM@plt>
cmp    $0x2,%ebp
je     1182 <main+0x22>
cmp    $0x1,%ebp
jne    119b <main+0x3b>
xor    %eax,%eax
call   1030 <repl@plt>
jmp    118b <main+0x2b>
mov    0x8(%rbx),%rdi
call   1060 <runFile@plt>
xor    %eax,%eax
call   1070 <freeVM@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x40,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: clox [path]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @initVM()
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @repl()
br label %24
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @runFile(i8* %17)
br label %23
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 64)
unreachable
23: ; preds = %14
br label %24
24: ; preds = %23, %9
%25 = call i32 (...) @freeVM()
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: clox [path]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @initVM()
switch i32 %0, label %10 [
i32 1, label %4
i32 2, label %6
]
4: ; preds = %2
%5 = tail call i32 (...) @repl()
br label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @runFile(i8* %8)
br label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 64)
unreachable
14: ; preds = %6, %4
%15 = tail call i32 (...) @freeVM()
ret i32 0
}