#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 */
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_stack();
int /*<<< orphan*/ *load_program(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("File required\n");
    return 1;
  }
  int64_t *program = load_program(argv[1]);
  init_stack();
  run(program);
  free(program);
  return 0;
}


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)
jge    1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <load_program@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <init_stack@plt>
mov    -0x18(%rbp),%rdi
call   1040 <run@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     116c <main+0x1c>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    1191 <main+0x41>
mov    0x8(%rsi),%rdi
call   1070 <load_program@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <init_stack@plt>
mov    %r14,%rdi
call   1050 <run@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"File required\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %21
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @load_program(i8* %14)
store i32* %15, i32** %6
%16 = call i32 (...) @init_stack()
%17 = load i32*, i32** %6
%18 = call i32 @run(i32* %17)
%19 = load i32*, i32** %6
%20 = call i32 @free(i32* %19)
store i32 0, i32* %3
br label %21
21: ; preds = %11, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@str = [14 x i8] c"File required\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @load_program(i8* %8)
%10 = tail call i32 (...) @init_stack()
%11 = tail call i32 @run(i32* %9)
%12 = tail call i32 @free(i32* %9)
br label %13
13: ; preds = %6, %4
%14 = phi i32 [ 1, %4 ], [ 0, %6 ]
ret i32 %14
}