#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 */
struct SymTab {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ asmgen_assemble(struct SymTab **, int /*<<< orphan*/ *,
                           unsigned char *);
scalar_t__ asmgen_parse_syms(struct SymTab **, int /*<<< orphan*/ *);
scalar_t__ asmout_make_hex(struct SymTab **, unsigned char *, unsigned char *);
scalar_t__ asmout_make_mif(struct SymTab **, unsigned char *, unsigned char *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ guess_output(struct SymTab **, unsigned char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(unsigned char *, char *);
int /*<<< orphan*/ strncpy(unsigned char *, char *, int);
int /*<<< orphan*/ symtab_clear(struct SymTab **);
scalar_t__ symtab_lookup(struct SymTab **, char *, unsigned char *, int *);
int /*<<< orphan*/ symtab_show(struct SymTab **);
int main(int argc, char **argv) {
  struct SymTab *prgSyms = NULL;
  FILE *inFile;
  unsigned char *data, outfmt[64];
  unsigned char *outName, guessed[1024];
  int prgSize;
  int ret;
  symtab_clear(&prgSyms);
  if (argc < 2) {
    printf("No input specified\n\n");
    printf("Usage:\n\t%s <input> [<output>]\n", argv[0]);
    return 0;
  }
  if ((inFile = fopen(argv[1], "r")) == NULL) {
    perror("FATAL - Could not open input file");
    return -1;
  }
  if (asmgen_parse_syms(&prgSyms, inFile) != 0) {
    fprintf(stderr, "FATAL - Could not parse input\n");
    symtab_clear(&prgSyms);
    return -1;
  }
  if (0) {
    symtab_show(&prgSyms);
  }
  if (symtab_lookup(&prgSyms, "$filesize", NULL, &prgSize) != 0) {
    fprintf(stderr, "ERROR - Unknown file size\n");
    return -1;
  }
  if ((data = (unsigned char *)calloc(sizeof(unsigned char), prgSize)) ==
      NULL) {
    fprintf(stderr, "ERROR - Memory allocation failed\n");
    return -1;
  }
  if (fseek(inFile, 0L, SEEK_SET) != 0) {
    perror("FATAL - Could not rewind file");
    return -1;
  }
  if (asmgen_assemble(&prgSyms, inFile, data) != 0) {
    fprintf(stderr, "FATAL - Could not assemble\n");
    return -1;
  }
  if (argc < 3) {
    outName = guessed;
    strncpy(guessed, argv[1], 1024);
    guess_output(&prgSyms, guessed);
  } else {
    outName = argv[2];
  }
  printf("Output name is \'%s\'\n", outName);
  symtab_lookup(&prgSyms, "$outfmt", outfmt, NULL);
  if (strcmp(outfmt, "hex") == 0) {
    ret = asmout_make_hex(&prgSyms, outName, data) != 0;
  } else {
    ret = asmout_make_mif(&prgSyms, outName, data) != 0;
  }
  if (ret != 0) {
    fprintf(stderr, "FATAL - File output failed\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   10b0 <symtab_clear@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1253 <main+0x63>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14da <main+0x2ea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd2(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    128d <main+0x9d>
lea    0xdba(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1060 <asmgen_parse_syms@plt>
cmp    $0x0,%rax
je     12ce <main+0xde>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
call   1090 <fprintf@plt>
lea    -0x18(%rbp),%rdi
call   10b0 <symtab_clear@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
lea    -0x18(%rbp),%rdi
lea    0xd9e(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x484(%rbp),%rcx
call   1040 <symtab_lookup@plt>
cmp    $0x0,%rax
je     1314 <main+0x124>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd7e(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
mov    -0x484(%rbp),%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1353 <main+0x163>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
mov    -0x20(%rbp),%rdi
mov    0x2c7a(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <fseek@plt>
cmp    $0x0,%rax
je     138b <main+0x19b>
lea    0xd44(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x18(%rbp),%rdi
call   10a0 <asmgen_assemble@plt>
cmp    $0x0,%rax
je     13c7 <main+0x1d7>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
lea    0xd26(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
cmpl   $0x3,-0x8(%rbp)
jge    140a <main+0x21a>
lea    -0x480(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x400,%edx
call   1030 <strncpy@plt>
lea    -0x480(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   10d0 <guess_output@plt>
jmp    1416 <main+0x226>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xcd6(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <symtab_lookup@plt>
lea    -0x70(%rbp),%rdi
lea    0xcca(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1482 <main+0x292>
mov    -0x78(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x18(%rbp),%rdi
call   1100 <asmout_make_hex@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x488(%rbp)
jmp    14a5 <main+0x2b5>
mov    -0x78(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x18(%rbp),%rdi
call   1110 <asmout_make_mif@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x488(%rbp)
cmpl   $0x0,-0x488(%rbp)
je     14d3 <main+0x2e3>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
lea    0xc57(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14da <main+0x2ea>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x458,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
movq   $0x0,(%rsp)
mov    %rsp,%rdi
call   10c0 <symtab_clear@plt>
cmp    $0x1,%ebp
jg     124b <main+0x4b>
lea    0xef2(%rip),%rdi
call   1040 <puts@plt>
mov    (%r15),%rsi
lea    0xdc3(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12cb <main+0xcb>
mov    0x8(%r15),%rdi
lea    0xdc9(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1332 <main+0x132>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    %rax,%rsi
call   1070 <asmgen_parse_syms@plt>
test   %rax,%rax
je     1296 <main+0x96>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
call   10a0 <fprintf@plt>
mov    %rsp,%rdi
call   10c0 <symtab_clear@plt>
jmp    12c6 <main+0xc6>
lea    0xdc5(%rip),%rsi
mov    %rsp,%rdi
lea    0xc(%rsp),%rcx
xor    %edx,%edx
call   1050 <symtab_lookup@plt>
test   %rax,%rax
je     12db <main+0xdb>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xc(%rsp),%esi
mov    $0x1,%edi
call   1080 <calloc@plt>
test   %rax,%rax
je     1340 <main+0x140>
mov    %rax,%r14
mov    0x2ce0(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
test   %rax,%rax
jne    13f5 <main+0x1f5>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <asmgen_assemble@plt>
test   %rax,%rax
je     1355 <main+0x155>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
jmp    12c1 <main+0xc1>
lea    0xce8(%rip),%rdi
call   1100 <perror@plt>
jmp    12c6 <main+0xc6>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
jmp    12c1 <main+0xc1>
cmp    $0x2,%ebp
ja     137d <main+0x17d>
lea    0x50(%rsp),%rbx
mov    0x8(%r15),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   10e0 <guess_output@plt>
jmp    1381 <main+0x181>
mov    0x10(%r15),%rbx
lea    0xd5b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd5f(%rip),%rsi
mov    %rsp,%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdx
xor    %ecx,%ecx
call   1050 <symtab_lookup@plt>
lea    0xd4e(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
test   %rax,%rax
je     13cf <main+0x1cf>
call   1120 <asmout_make_mif@plt>
jmp    13d4 <main+0x1d4>
call   1110 <asmout_make_hex@plt>
test   %rax,%rax
je     13ee <main+0x1ee>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
jmp    12c1 <main+0xc1>
xor    %ebx,%ebx
jmp    12cb <main+0xcb>
lea    0xcad(%rip),%rdi
call   1100 <perror@plt>
jmp    12c6 <main+0xc6>

LLVM IR (-O0):
%struct.SymTab = type { i32 }
@.str = [21 x i8] c"No input specified\0A\0A\00"
@.str.1 = [31 x i8] c"Usage:\0A\09%s <input> [<output>]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [34 x i8] c"FATAL - Could not open input file\00"
@stderr = global i32 0
@.str.4 = [31 x i8] c"FATAL - Could not parse input\0A\00"
@.str.5 = [10 x i8] c"$filesize\00"
@.str.6 = [27 x i8] c"ERROR - Unknown file size\0A\00"
@.str.7 = [34 x i8] c"ERROR - Memory allocation failed\0A\00"
@SEEK_SET = global i32 0
@.str.8 = [30 x i8] c"FATAL - Could not rewind file\00"
@.str.9 = [28 x i8] c"FATAL - Could not assemble\0A\00"
@.str.10 = [21 x i8] c"Output name is '%s'\0A\00"
@.str.11 = [8 x i8] c"$outfmt\00"
@.str.12 = [4 x i8] c"hex\00"
@.str.13 = [28 x i8] c"FATAL - File output failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.SymTab*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca [64 x i8]
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.SymTab* null, %struct.SymTab** %6
%14 = call i32 @symtab_clear(%struct.SymTab** %6)
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %3
br label %111
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
31: ; preds = %23
%32 = load i32*, i32** %7
%33 = call i64 @asmgen_parse_syms(%struct.SymTab** %6, i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @symtab_clear(%struct.SymTab** %6)
store i32 -1, i32* %3
br label %111
39: ; preds = %31
%40 = call i64 @symtab_lookup(%struct.SymTab** %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* null, i32* %12)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
45: ; preds = %39
%46 = load i32, i32* %12
%47 = call i64 @calloc(i32 1, i32 %46)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %8
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
53: ; preds = %45
%54 = load i32*, i32** %7
%55 = load i32, i32* @SEEK_SET
%56 = call i64 @fseek(i32* %54, i64 0, i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
60: ; preds = %53
%61 = load i32*, i32** %7
%62 = load i8*, i8** %8
%63 = call i64 @asmgen_assemble(%struct.SymTab** %6, i32* %61, i8* %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
68: ; preds = %60
%69 = load i32, i32* %4
%70 = icmp slt i32 %69, 3
br i1 %70, label %71, label %80
71: ; preds = %68
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
store i8* %72, i8** %10
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i32 @strncpy(i8* %73, i8* %76, i32 1024)
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%79 = call i32 @guess_output(%struct.SymTab** %6, i8* %78)
br label %84
80: ; preds = %68
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 2
%83 = load i8*, i8** %82
store i8* %83, i8** %10
br label %84
84: ; preds = %80, %71
%85 = load i8*, i8** %10
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %85)
%87 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%88 = call i64 @symtab_lookup(%struct.SymTab** %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %87, i32* null)
%89 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %84
%93 = load i8*, i8** %10
%94 = load i8*, i8** %8
%95 = call i64 @asmout_make_hex(%struct.SymTab** %6, i8* %93, i8* %94)
%96 = icmp ne i64 %95, 0
%97 = zext i1 %96 to i32
store i32 %97, i32* %13
br label %104
98: ; preds = %84
%99 = load i8*, i8** %10
%100 = load i8*, i8** %8
%101 = call i64 @asmout_make_mif(%struct.SymTab** %6, i8* %99, i8* %100)
%102 = icmp ne i64 %101, 0
%103 = zext i1 %102 to i32
store i32 %103, i32* %13
br label %104
104: ; preds = %98, %92
%105 = load i32, i32* %13
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %104
%108 = load i32, i32* @stderr
%109 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
store i32 -1, i32* %3
br label %111
110: ; preds = %104
store i32 0, i32* %3
br label %111
111: ; preds = %110, %107, %65, %58, %50, %42, %35, %29, %17
%112 = load i32, i32* %3
ret i32 %112
}

LLVM IR (-O2):
%struct.SymTab = type { i32 }
@.str.1 = [31 x i8] c"Usage:\0A\09%s <input> [<output>]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [34 x i8] c"FATAL - Could not open input file\00"
@stderr = global i32 0
@.str.4 = [31 x i8] c"FATAL - Could not parse input\0A\00"
@.str.5 = [10 x i8] c"$filesize\00"
@.str.6 = [27 x i8] c"ERROR - Unknown file size\0A\00"
@.str.7 = [34 x i8] c"ERROR - Memory allocation failed\0A\00"
@SEEK_SET = global i32 0
@.str.8 = [30 x i8] c"FATAL - Could not rewind file\00"
@.str.9 = [28 x i8] c"FATAL - Could not assemble\0A\00"
@.str.10 = [21 x i8] c"Output name is '%s'\0A\00"
@.str.11 = [8 x i8] c"$outfmt\00"
@.str.12 = [4 x i8] c"hex\00"
@.str.13 = [28 x i8] c"FATAL - File output failed\0A\00"
@str = [20 x i8] c"No input specified\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.SymTab*
%4 = alloca [64 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = bitcast %struct.SymTab** %3 to i8*
store %struct.SymTab* null, %struct.SymTab** %3
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
%11 = call i32 @symtab_clear(%struct.SymTab** %3)
%12 = icmp slt i32 %0, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%15 = load i8*, i8** %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %82
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %82
24: ; preds = %17
%25 = call i64 @asmgen_parse_syms(%struct.SymTab** %3, i32* %20)
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @symtab_clear(%struct.SymTab** %3)
br label %82
31: ; preds = %24
%32 = call i64 @symtab_lookup(%struct.SymTab** %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* null, i32* %6)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %82
37: ; preds = %31
%38 = load i32, i32* %6
%39 = call i64 @calloc(i32 1, i32 %38)
%40 = inttoptr i64 %39 to i8*
%41 = icmp eq i64 %39, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %82
45: ; preds = %37
%46 = load i32, i32* @SEEK_SET
%47 = call i64 @fseek(i32* %20, i64 0, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %45
%50 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %82
51: ; preds = %45
%52 = call i64 @asmgen_assemble(%struct.SymTab** %3, i32* %20, i8* %40)
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %82
57: ; preds = %51
%58 = icmp ult i32 %0, 3
br i1 %58, label %59, label %63
59: ; preds = %57
%60 = load i8*, i8** %18
%61 = call i32 @strncpy(i8* %9, i8* %60, i32 1024)
%62 = call i32 @guess_output(%struct.SymTab** %3, i8* %9)
br label %66
63: ; preds = %57
%64 = getelementptr inbounds i8*, i8** %1, i64 2
%65 = load i8*, i8** %64
br label %66
66: ; preds = %63, %59
%67 = phi i8* [ %9, %59 ], [ %65, %63 ]
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %67)
%69 = call i64 @symtab_lookup(%struct.SymTab** %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %8, i32* null)
%70 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i64 @asmout_make_hex(%struct.SymTab** %3, i8* %67, i8* %40)
br label %76
74: ; preds = %66
%75 = call i64 @asmout_make_mif(%struct.SymTab** %3, i8* %67, i8* %40)
br label %76
76: ; preds = %74, %72
%77 = phi i64 [ %73, %72 ], [ %75, %74 ]
%78 = icmp eq i64 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = load i32, i32* @stderr
%81 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %82
82: ; preds = %76, %79, %54, %49, %42, %34, %27, %22, %13
%83 = phi i32 [ 0, %13 ], [ -1, %22 ], [ -1, %27 ], [ -1, %34 ], [ -1, %42 ], [ -1, %49 ], [ -1, %54 ], [ -1, %79 ], [ 0, %76 ]
ret i32 %83
}