#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*/ compile(char *);
int /*<<< orphan*/ err(char *);
int /*<<< orphan*/ free(char *);
char *read_file(char *);
int main(int argc, char *argv[]) {
  if (argc != 2)
    err("Usage: compiler-x64 <inputfile>");
  char *text_body = read_file(argv[1]);
  if (text_body == NULL)
    err("Unable to read file");
  compile(text_body);
  free(text_body);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116c <main+0x2c>
lea    0xe99(%rip),%rdi
call   1060 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <read_file@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1194 <main+0x54>
lea    0xe91(%rip),%rdi
call   1060 <err@plt>
mov    -0x18(%rbp),%rdi
call   1040 <compile@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1155 <main+0x15>
lea    0xeb0(%rip),%rdi
call   1060 <err@plt>
mov    0x8(%rbx),%rdi
call   1050 <read_file@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1172 <main+0x32>
lea    0xeb3(%rip),%rdi
call   1060 <err@plt>
mov    %rbx,%rdi
call   1040 <compile@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: compiler-x64 <inputfile>\00"
@.str.1 = [20 x i8] c"Unable to read file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @err(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @read_file(i8* %14)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %11
%21 = load i8*, i8** %6
%22 = call i32 @compile(i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [32 x i8] c"Usage: compiler-x64 <inputfile>\00"
@.str.1 = [20 x i8] c"Unable to read file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @err(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i8* @read_file(i8* %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = tail call i32 @compile(i8* %9)
%15 = tail call i32 @free(i8* %9)
ret i32 0
}