#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int assemble_hummus(char *);
char *basename(char *);
int /*<<< orphan*/ debug_print(char *, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ help_message(char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ set_debug_flags(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strrchr(char *, char);
int /*<<< orphan*/ usage_message(char *);
int main(int argc, char *argv[]) {
  int opt;
  char file_name_path[1024];
  char file_name[1024];
  while ((opt = getopt(argc, argv, "@:h")) != -1) {
    switch (opt) {
    case '@':
      set_debug_flags(optarg);
      break;
    case 'h':
      help_message(argv[0]);
      exit(EXIT_SUCCESS);
    default:
      usage_message(argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  if (optind >= argc) {
    fprintf(stderr, "Expected a filename after options.\n");
    usage_message(argv[0]);
    exit(EXIT_FAILURE);
  }
  strcpy(file_name_path, argv[optind]);
  strcpy(file_name, basename(file_name_path));
  debug_print("@m", stdout, "Filename+path: %s\n", file_name_path);
  debug_print("@m", stdout, "Filename:      %s\n", file_name);
  char *dot = strrchr(file_name, '.');
  if (!dot || (dot && strcmp(dot, ".hal"))) {
    fprintf(stderr, "%s is not a .hal file!", file_name);
    exit(EXIT_FAILURE);
  }
  return assemble_hummus(file_name_path);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe19(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     126f <main+0xaf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x82c(%rbp)
sub    $0x40,%eax
je     1223 <main+0x63>
jmp    120f <main+0x4f>
mov    -0x82c(%rbp),%eax
sub    $0x68,%eax
je     1236 <main+0x76>
jmp    1250 <main+0x90>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1040 <set_debug_flags@plt>
jmp    126a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <help_message@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10e0 <usage_message@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    11d9 <main+0x19>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12b2 <main+0xf2>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10e0 <usage_message@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x2d1c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
lea    -0x820(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x420(%rbp),%rdi
call   1080 <basename@plt>
mov    -0x838(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%esi
lea    -0x420(%rbp),%rcx
lea    0xd18(%rip),%rdi
lea    0xd14(%rip),%rdx
call   10c0 <debug_print@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%esi
lea    -0x820(%rbp),%rcx
lea    0xcf5(%rip),%rdi
lea    0xd04(%rip),%rdx
call   10c0 <debug_print@plt>
lea    -0x820(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
je     1390 <main+0x1d0>
cmpq   $0x0,-0x828(%rbp)
je     13bc <main+0x1fc>
mov    -0x828(%rbp),%rdi
lea    0xcd0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     13bc <main+0x1fc>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    -0x820(%rbp),%rdx
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x420(%rbp),%rdi
call   10d0 <assemble_hummus@plt>
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe27(%rip),%r14
mov    0x2e18(%rip),%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10a0 <getopt@plt>
cmp    $0x40,%eax
jne    11fc <main+0x3c>
mov    (%r15),%edi
call   1040 <set_debug_flags@plt>
jmp    11e0 <main+0x20>
cmp    $0xffffffff,%eax
jne    12b8 <main+0xf8>
mov    0x2dd4(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    12ef <main+0x12f>
mov    (%rbx,%rax,8),%rsi
lea    0x400(%rsp),%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1080 <basename@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    0x2d78(%rip),%rbx
mov    (%rbx),%esi
lea    0xdd7(%rip),%rbp
lea    0xdd3(%rip),%rdx
mov    %rbp,%rdi
mov    %r15,%rcx
call   10c0 <debug_print@plt>
mov    (%rbx),%esi
lea    0xdd2(%rip),%rdx
mov    %rbp,%rdi
mov    %r14,%rcx
call   10c0 <debug_print@plt>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     12d3 <main+0x113>
lea    0xdc1(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12d3 <main+0x113>
lea    0x400(%rsp),%rdi
call   10d0 <assemble_hummus@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x68,%eax
jne    1306 <main+0x146>
mov    (%rbx),%rdi
call   1090 <help_message@plt>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    130e <main+0x14e>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%rdi
call   10e0 <usage_message@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"@:h\00"
@optarg = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [36 x i8] c"Expected a filename after options.\0A\00"
@.str.2 = [3 x i8] c"@m\00"
@stdout = global i32 0
@.str.3 = [19 x i8] c"Filename+path: %s\0A\00"
@.str.4 = [19 x i8] c"Filename: %s\0A\00"
@.str.5 = [5 x i8] c".hal\00"
@.str.6 = [23 x i8] c"%s is not a .hal file!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %35
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %27 [
i32 64, label %17
i32 104, label %20
]
17: ; preds = %15
%18 = load i32, i32* @optarg
%19 = call i32 @set_debug_flags(i32 %18)
br label %34
20: ; preds = %15
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @help_message(i8* %23)
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %15
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @usage_message(i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %17
br label %10
35: ; preds = %10
%36 = load i32, i32* @optind
%37 = load i32, i32* %4
%38 = icmp sge i32 %36, %37
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 @usage_message(i8* %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %35
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%50 = load i8**, i8*** %5
%51 = load i32, i32* @optind
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @strcpy(i8* %49, i8* %54)
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%58 = call i8* @basename(i8* %57)
%59 = call i32 @strcpy(i8* %56, i8* %58)
%60 = load i32, i32* @stdout
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%62 = call i32 @debug_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %60, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %61)
%63 = load i32, i32* @stdout
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%65 = call i32 @debug_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%67 = call i8* @strrchr(i8* %66, i8 signext 46)
store i8* %67, i8** %9
%68 = load i8*, i8** %9
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %77
70: ; preds = %48
%71 = load i8*, i8** %9
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %83
73: ; preds = %70
%74 = load i8*, i8** %9
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %73, %48
%78 = load i32, i32* @stderr
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %79)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %73, %70
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%85 = call i32 @assemble_hummus(i8* %84)
ret i32 %85
}

LLVM IR (-O2):
@.str = [4 x i8] c"@:h\00"
@optarg = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [36 x i8] c"Expected a filename after options.\0A\00"
@.str.2 = [3 x i8] c"@m\00"
@stdout = global i32 0
@.str.3 = [19 x i8] c"Filename+path: %s\0A\00"
@.str.4 = [19 x i8] c"Filename: %s\0A\00"
@.str.5 = [5 x i8] c".hal\00"
@.str.6 = [23 x i8] c"%s is not a .hal file!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %9, %2
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %17 [
i32 -1, label %22
i32 64, label %9
i32 104, label %12
]
9: ; preds = %7
%10 = load i32, i32* @optarg
%11 = tail call i32 @set_debug_flags(i32 %10)
br label %7
12: ; preds = %7
%13 = load i8*, i8** %1
%14 = tail call i32 @help_message(i8* %13)
%15 = load i32, i32* @EXIT_SUCCESS
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %7
%18 = load i8*, i8** %1
%19 = tail call i32 @usage_message(i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %7
%23 = load i32, i32* @optind
%24 = icmp slt i32 %23, %0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8*, i8** %1
%29 = tail call i32 @usage_message(i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = sext i32 %23 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %5, i8* %35)
%37 = call i8* @basename(i8* %5)
%38 = call i32 @strcpy(i8* %6, i8* %37)
%39 = load i32, i32* @stdout
%40 = call i32 @debug_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %39, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%41 = load i32, i32* @stdout
%42 = call i32 @debug_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %41, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%43 = call i8* @strrchr(i8* %6, i8 signext 46)
%44 = icmp eq i8* %43, null
br i1 %44, label %48, label %45
45: ; preds = %32
%46 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %45, %32
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %45
%54 = call i32 @assemble_hummus(i8* %5)
ret i32 %54
}