#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *stderr;
scalar_t__ symtab_lookup(struct SymTab **, char *, int /*<<< orphan*/ *, int *);
int asmout_make_hex(struct SymTab **curSyms, char *out, char *data) {
  FILE *handle;
  int x, t, checksum, datasize, mifwords, mifbytes;
  ;
  int bytewidth, mifwidth = 8;
  if (symtab_lookup(curSyms, "$filesize", NULL, &datasize) != 0) {
    fprintf(stderr, "ERROR - Unknown file size\n");
    return -1;
  }
  if (symtab_lookup(curSyms, "$mifwords", NULL, &mifwords) != 0) {
    fprintf(stderr, "ERROR - Unknown HEX output size\n");
    return -1;
  }
  if (symtab_lookup(curSyms, "$mifwidth", NULL, &mifwidth) == 0) {
    if ((mifwidth == 0) && ((mifwidth % 8) != 0)) {
      fprintf(stderr, "ERROR - Illegal HEX width size "
                      "(must be multiple of 8)\n");
      return -1;
    }
  }
  bytewidth = mifwidth / 8;
  mifbytes = mifwords * bytewidth;
  if (datasize > mifbytes) {
    fprintf(stderr, "ERROR - Assembled file will not fit within "
                    "hex filesize\n");
    return -1;
  }
  if ((handle = fopen(out, "w")) == NULL) {
    perror("ERROR - Could not open output file");
    return -1;
  }
  for (x = 0; x < mifbytes; x += bytewidth) {
    checksum = 4 + (x / bytewidth & 0xff) + (x / (bytewidth * 256) & 0xff);
    fprintf(handle, ":04%04X00", x / bytewidth);
    for (t = 0; t < bytewidth; t++) {
      if ((x + t) < datasize) {
        fprintf(handle, "%02X", data[x + t] & 0xff);
        checksum = checksum + (data[x + t] & 0xff);
      } else {
        fprintf(handle, "00");
      }
    }
    fprintf(handle, "%02X\n", (-checksum) & 0xff);
  }
  fprintf(handle, ":00000001FF\n");
  fclose(handle);
  return 0;
}


x86 assembly (clang, -O0):
<asmout_make_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x8,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x38(%rbp),%rcx
call   1030 <symtab_lookup@plt>
cmp    $0x0,%rax
je     11b1 <asmout_make_hex+0x61>
mov    0x2e4c(%rip),%rax
mov    (%rax),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141b <asmout_make_hex+0x2cb>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x3c(%rbp),%rcx
call   1030 <symtab_lookup@plt>
cmp    $0x0,%rax
je     11f7 <asmout_make_hex+0xa7>
mov    0x2e06(%rip),%rax
mov    (%rax),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141b <asmout_make_hex+0x2cb>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x48(%rbp),%rcx
call   1030 <symtab_lookup@plt>
cmp    $0x0,%rax
jne    1260 <asmout_make_hex+0x110>
cmpl   $0x0,-0x48(%rbp)
jne    125b <asmout_make_hex+0x10b>
mov    -0x48(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     125b <asmout_make_hex+0x10b>
mov    0x2da2(%rip),%rax
mov    (%rax),%rdi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141b <asmout_make_hex+0x2cb>
jmp    1260 <asmout_make_hex+0x110>
mov    -0x48(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x44(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
jle    12a8 <asmout_make_hex+0x158>
mov    0x2d55(%rip),%rax
mov    (%rax),%rdi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141b <asmout_make_hex+0x2cb>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12de <asmout_make_hex+0x18e>
lea    0xe00(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141b <asmout_make_hex+0x2cb>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    13f9 <asmout_make_hex+0x2a9>
mov    -0x2c(%rbp),%eax
cltd
idivl  -0x44(%rbp)
and    $0xff,%eax
add    $0x4,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x44(%rbp),%ecx
shl    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%eax
cltd
idivl  -0x44(%rbp)
mov    %eax,%edx
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    13ce <asmout_make_hex+0x27e>
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    13a9 <asmout_make_hex+0x259>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
and    $0xff,%edx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%edx
add    -0x30(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    13bb <asmout_make_hex+0x26b>
mov    -0x28(%rbp),%rdi
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    13c0 <asmout_make_hex+0x270>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1341 <asmout_make_hex+0x1f1>
mov    -0x28(%rbp),%rdi
xor    %edx,%edx
sub    -0x34(%rbp),%edx
and    $0xff,%edx
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    12e5 <asmout_make_hex+0x195>
mov    -0x28(%rbp),%rdi
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asmout_make_hex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x8,0x10(%rsp)
lea    0xe7a(%rip),%rsi
lea    0x14(%rsp),%rcx
xor    %edx,%edx
call   1030 <symtab_lookup@plt>
test   %rax,%rax
je     11b2 <asmout_make_hex+0x52>
mov    0x2e42(%rip),%rax
mov    (%rax),%rcx
lea    0xe62(%rip),%rdi
mov    $0x1a,%esi
jmp    1236 <asmout_make_hex+0xd6>
lea    0xe6c(%rip),%rsi
lea    0x1c(%rsp),%rcx
mov    %rbp,%rdi
xor    %edx,%edx
call   1030 <symtab_lookup@plt>
test   %rax,%rax
je     11e5 <asmout_make_hex+0x85>
mov    0x2e0c(%rip),%rax
mov    (%rax),%rcx
lea    0xe51(%rip),%rdi
mov    $0x20,%esi
jmp    1236 <asmout_make_hex+0xd6>
lea    0xe64(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %rbp,%rdi
xor    %edx,%edx
call   1030 <symtab_lookup@plt>
mov    0x10(%rsp),%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
mov    %rax,0x30(%rsp)
cmovns %eax,%ecx
sar    $0x3,%ecx
mov    0x1c(%rsp),%ebp
mov    %ecx,0xc(%rsp)
imul   %ecx,%ebp
cmp    %ebp,0x14(%rsp)
jle    1254 <asmout_make_hex+0xf4>
mov    0x2db9(%rip),%rax
mov    (%rax),%rcx
lea    0xe29(%rip),%rdi
mov    $0x38,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     138b <asmout_make_hex+0x22b>
mov    %rax,%r12
test   %ebp,%ebp
jle    1363 <asmout_make_hex+0x203>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
shl    $0x8,%ecx
mov    %ecx,0x18(%rsp)
movslq %eax,%rcx
mov    %rcx,0x28(%rsp)
mov    %ebp,%ecx
mov    %rcx,0x20(%rsp)
mov    %eax,%r13d
xor    %r15d,%r15d
jmp    12cd <asmout_make_hex+0x16d>
nopl   0x0(%rax,%rax,1)
neg    %ebp
movzbl %bpl,%edx
mov    %r12,%rdi
lea    0xe17(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x28(%rsp),%rax
add    %rax,%r15
add    %rax,%r14
cmp    0x20(%rsp),%r15
jge    1363 <asmout_make_hex+0x203>
mov    %r15d,%eax
cltd
idivl  0xc(%rsp)
mov    %eax,%ebp
mov    %r15d,%eax
cltd
idivl  0x18(%rsp)
mov    %eax,%ebx
mov    %r12,%rdi
lea    0xdcd(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl %bpl,%eax
movzbl %bl,%ecx
lea    (%rax,%rcx,1),%ebp
add    $0x4,%ebp
cmpl   $0x8,0x30(%rsp)
jl     12a0 <asmout_make_hex+0x140>
xor    %ebx,%ebx
jmp    1336 <asmout_make_hex+0x1d6>
nopl   0x0(%rax)
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xd9e(%rip),%rdi
mov    %r12,%rcx
call   1080 <fwrite@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     12a0 <asmout_make_hex+0x140>
lea    (%r15,%rbx,1),%rax
movslq 0x14(%rsp),%rcx
cmp    %rcx,%rax
jge    1310 <asmout_make_hex+0x1b0>
movzbl (%r14,%rbx,1),%edx
mov    %r12,%rdi
lea    0xd6f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
movzbl (%r14,%rbx,1),%eax
add    %eax,%ebp
jmp    1329 <asmout_make_hex+0x1c9>
lea    0xd63(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1245 <asmout_make_hex+0xe5>
lea    0xd03(%rip),%rdi
call   1070 <perror@plt>
jmp    1240 <asmout_make_hex+0xe0>

LLVM IR (-O0):
%struct.SymTab = type { i32 }
@.str = [10 x i8] c"$filesize\00"
@stderr = global i32* null
@.str.1 = [27 x i8] c"ERROR - Unknown file size\0A\00"
@.str.2 = [10 x i8] c"$mifwords\00"
@.str.3 = [33 x i8] c"ERROR - Unknown HEX output size\0A\00"
@.str.4 = [10 x i8] c"$mifwidth\00"
@.str.5 = [56 x i8] c"ERROR - Illegal HEX width size (must be multiple of 8)\0A\00"
@.str.6 = [57 x i8] c"ERROR - Assembled file will not fit within hex filesize\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [35 x i8] c"ERROR - Could not open output file\00"
@.str.9 = [10 x i8] c":04%04X00\00"
@.str.10 = [5 x i8] c"%02X\00"
@.str.11 = [3 x i8] c"00\00"
@.str.12 = [6 x i8] c"%02X\0A\00"
@.str.13 = [13 x i8] c":00000001FF\0A\00"
define i32 @asmout_make_hex(%struct.SymTab** %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.SymTab**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store %struct.SymTab** %0, %struct.SymTab*** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 8, i32* %16
%17 = load %struct.SymTab**, %struct.SymTab*** %5
%18 = call i64 @symtab_lookup(%struct.SymTab** %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* null, i32* %12)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i32*, i32** @stderr
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %140
23: ; preds = %3
%24 = load %struct.SymTab**, %struct.SymTab*** %5
%25 = call i64 @symtab_lookup(%struct.SymTab** %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* %13)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32*, i32** @stderr
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %140
30: ; preds = %23
%31 = load %struct.SymTab**, %struct.SymTab*** %5
%32 = call i64 @symtab_lookup(%struct.SymTab** %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* %16)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = load i32, i32* %16
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %16
%39 = srem i32 %38, 8
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32*, i32** @stderr
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %4
br label %140
44: ; preds = %37, %34
br label %45
45: ; preds = %44, %30
%46 = load i32, i32* %16
%47 = sdiv i32 %46, 8
store i32 %47, i32* %15
%48 = load i32, i32* %13
%49 = load i32, i32* %15
%50 = mul nsw i32 %48, %49
store i32 %50, i32* %14
%51 = load i32, i32* %12
%52 = load i32, i32* %14
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %45
%55 = load i32*, i32** @stderr
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %4
br label %140
57: ; preds = %45
%58 = load i8*, i8** %6
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %59, i32** %8
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %4
br label %140
63: ; preds = %57
store i32 0, i32* %9
br label %64
64: ; preds = %131, %63
%65 = load i32, i32* %9
%66 = load i32, i32* %14
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %135
68: ; preds = %64
%69 = load i32, i32* %9
%70 = load i32, i32* %15
%71 = sdiv i32 %69, %70
%72 = and i32 %71, 255
%73 = add nsw i32 4, %72
%74 = load i32, i32* %9
%75 = load i32, i32* %15
%76 = mul nsw i32 %75, 256
%77 = sdiv i32 %74, %76
%78 = and i32 %77, 255
%79 = add nsw i32 %73, %78
store i32 %79, i32* %11
%80 = load i32*, i32** %8
%81 = load i32, i32* %9
%82 = load i32, i32* %15
%83 = sdiv i32 %81, %82
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %83)
store i32 0, i32* %10
br label %85
85: ; preds = %122, %68
%86 = load i32, i32* %10
%87 = load i32, i32* %15
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %125
89: ; preds = %85
%90 = load i32, i32* %9
%91 = load i32, i32* %10
%92 = add nsw i32 %90, %91
%93 = load i32, i32* %12
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %118
95: ; preds = %89
%96 = load i32*, i32** %8
%97 = load i8*, i8** %7
%98 = load i32, i32* %9
%99 = load i32, i32* %10
%100 = add nsw i32 %98, %99
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %97, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = and i32 %104, 255
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %11
%108 = load i8*, i8** %7
%109 = load i32, i32* %9
%110 = load i32, i32* %10
%111 = add nsw i32 %109, %110
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %108, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = and i32 %115, 255
%117 = add nsw i32 %107, %116
store i32 %117, i32* %11
br label %121
118: ; preds = %89
%119 = load i32*, i32** %8
%120 = call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %121
121: ; preds = %118, %95
br label %122
122: ; preds = %121
%123 = load i32, i32* %10
%124 = add nsw i32 %123, 1
store i32 %124, i32* %10
br label %85
125: ; preds = %85
%126 = load i32*, i32** %8
%127 = load i32, i32* %11
%128 = sub nsw i32 0, %127
%129 = and i32 %128, 255
%130 = call i32 (i32*, i8*, ...) @fprintf(i32* %126, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %125
%132 = load i32, i32* %15
%133 = load i32, i32* %9
%134 = add nsw i32 %133, %132
store i32 %134, i32* %9
br label %64
135: ; preds = %64
%136 = load i32*, i32** %8
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%138 = load i32*, i32** %8
%139 = call i32 @fclose(i32* %138)
store i32 0, i32* %4
br label %140
140: ; preds = %135, %61, %54, %41, %27, %20
%141 = load i32, i32* %4
ret i32 %141
}

LLVM IR (-O2):
%struct.SymTab = type { i32 }
@.str = [10 x i8] c"$filesize\00"
@stderr = global i32* null
@.str.1 = [27 x i8] c"ERROR - Unknown file size\0A\00"
@.str.2 = [10 x i8] c"$mifwords\00"
@.str.3 = [33 x i8] c"ERROR - Unknown HEX output size\0A\00"
@.str.4 = [10 x i8] c"$mifwidth\00"
@.str.6 = [57 x i8] c"ERROR - Assembled file will not fit within hex filesize\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [35 x i8] c"ERROR - Could not open output file\00"
@.str.9 = [10 x i8] c":04%04X00\00"
@.str.10 = [5 x i8] c"%02X\00"
@.str.11 = [3 x i8] c"00\00"
@.str.12 = [6 x i8] c"%02X\0A\00"
@.str.13 = [13 x i8] c":00000001FF\0A\00"
define i32 @asmout_make_hex(%struct.SymTab** %0, i8* nocapture %1, i8* nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
store i32 8, i32* %6
%10 = call i64 @symtab_lookup(%struct.SymTab** %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* null, i32* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32*, i32** @stderr
%14 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 26, i64 1, i32* %13)
br label %86
15: ; preds = %3
%16 = call i64 @symtab_lookup(%struct.SymTab** %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32*, i32** @stderr
%20 = call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i64 32, i64 1, i32* %19)
br label %86
21: ; preds = %15
%22 = call i64 @symtab_lookup(%struct.SymTab** %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* %6)
%23 = load i32, i32* %6
%24 = sdiv i32 %23, 8
%25 = load i32, i32* %5
%26 = mul nsw i32 %25, %24
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, %26
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32*, i32** @stderr
%31 = call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0), i64 56, i64 1, i32* %30)
br label %86
32: ; preds = %21
%33 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %43, label %35
35: ; preds = %32
%36 = icmp sgt i32 %26, 0
br i1 %36, label %37, label %83
37: ; preds = %35
%38 = shl nsw i32 %24, 8
%39 = icmp sgt i32 %23, 7
%40 = sext i32 %24 to i64
%41 = zext i32 %26 to i64
%42 = zext i32 %24 to i64
br label %45
43: ; preds = %32
%44 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
br label %86
45: ; preds = %37, %76
%46 = phi i64 [ 0, %37 ], [ %81, %76 ]
%47 = trunc i64 %46 to i32
%48 = sdiv i32 %47, %24
%49 = and i32 %48, 255
%50 = add nuw nsw i32 %49, 4
%51 = sdiv i32 %47, %38
%52 = and i32 %51, 255
%53 = add nuw nsw i32 %50, %52
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %48)
br i1 %39, label %55, label %76
55: ; preds = %45, %72
%56 = phi i64 [ %74, %72 ], [ 0, %45 ]
%57 = phi i32 [ %73, %72 ], [ %53, %45 ]
%58 = add nsw i64 %56, %46
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = icmp slt i64 %58, %60
br i1 %61, label %62, label %70
62: ; preds = %55
%63 = getelementptr inbounds i8, i8* %2, i64 %58
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 %65)
%67 = load i8, i8* %63
%68 = zext i8 %67 to i32
%69 = add nsw i32 %57, %68
br label %72
70: ; preds = %55
%71 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 2, i64 1, i32* %33)
br label %72
72: ; preds = %62, %70
%73 = phi i32 [ %69, %62 ], [ %57, %70 ]
%74 = add nuw nsw i64 %56, 1
%75 = icmp eq i64 %74, %42
br i1 %75, label %76, label %55
76: ; preds = %72, %45
%77 = phi i32 [ %53, %45 ], [ %73, %72 ]
%78 = sub nsw i32 0, %77
%79 = and i32 %78, 255
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %79)
%81 = add i64 %46, %40
%82 = icmp slt i64 %81, %41
br i1 %82, label %45, label %83
83: ; preds = %76, %35
%84 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i64 12, i64 1, i32* %33)
%85 = call i32 @fclose(i32* %33)
br label %86
86: ; preds = %83, %43, %29, %18, %12
%87 = phi i32 [ -1, %12 ], [ -1, %18 ], [ -1, %29 ], [ -1, %43 ], [ 0, %83 ]
ret i32 %87
}