#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*/ getLine(char *, int);
int /*<<< orphan*/ initialiseFlags();
int /*<<< orphan*/ printf(char *);
scalar_t__ runFirstPass(char *);
scalar_t__ runSecondPass();
scalar_t__ writeInstructionsToFile(char *);
int main() {
  initialiseFlags();
  char filename[100];
  printf("Enter name of file to load: ");
  getLine(filename, 100);
  if (runFirstPass(filename) != 0)
    return -1;
  if (runSecondPass() != 0)
    return -1;
  if (writeInstructionsToFile("out.sml") != 0)
    return -1;
  else
    printf("Instructions successfully written to \"out.sml\"\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <initialiseFlags@plt>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getLine@plt>
lea    -0x70(%rbp),%rdi
call   1080 <runFirstPass@plt>
cmp    $0x0,%rax
je     11af <main+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <main+0xa1>
mov    $0x0,%al
call   1070 <runSecondPass@plt>
cmp    $0x0,%rax
je     11cc <main+0x6c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <main+0xa1>
lea    0xe4a(%rip),%rdi
call   1040 <writeInstructionsToFile@plt>
cmp    $0x0,%rax
je     11ee <main+0x8e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <main+0xa1>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xor    %eax,%eax
call   1060 <initialiseFlags@plt>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getLine@plt>
mov    %rbx,%rdi
call   1090 <runFirstPass@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    11d5 <main+0x65>
xor    %eax,%eax
call   1080 <runSecondPass@plt>
test   %rax,%rax
jne    11d5 <main+0x65>
lea    0xe60(%rip),%rdi
call   1050 <writeInstructionsToFile@plt>
test   %rax,%rax
jne    11d5 <main+0x65>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter name of file to load: \00"
@.str.1 = [8 x i8] c"out.sml\00"
@.str.2 = [48 x i8] c"Instructions successfully written to \22out.sml\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
%3 = call i32 (...) @initialiseFlags()
%4 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @getLine(i8* %5, i32 100)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i64 @runFirstPass(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 -1, i32* %1
br label %22
11: ; preds = %0
%12 = call i64 (...) @runSecondPass()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %1
br label %22
15: ; preds = %11
%16 = call i64 @writeInstructionsToFile(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 -1, i32* %1
br label %22
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19
store i32 0, i32* %1
br label %22
22: ; preds = %21, %18, %14, %10
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter name of file to load: \00"
@.str.1 = [8 x i8] c"out.sml\00"
@str = [47 x i8] c"Instructions successfully written to \22out.sml\22\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 (...) @initialiseFlags()
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @getLine(i8* %3, i32 100)
%6 = call i64 @runFirstPass(i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = call i64 (...) @runSecondPass()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call i64 @writeInstructionsToFile(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %11, %8, %0, %14
%17 = phi i32 [ 0, %14 ], [ -1, %0 ], [ -1, %8 ], [ -1, %11 ]
ret i32 %17
}