#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  unsigned char rom[1500];
  unsigned char ram[65536];
  FILE *arch;
  unsigned char c, opcode, flag;
  int ptr = 0, oldptr, siz, count, scan;
  arch = fopen("65C02.bin", "rb");
  if (arch == NULL) {
    printf("\n***Problem opening Opcode List '65C02.bin'!***\n");
    return -1;
  }
  fseek(arch, 0, SEEK_END);
  siz = ftell(arch);
  fseek(arch, 0, SEEK_SET);
  fread(rom, siz, 1, arch);
  arch = fopen("test.bin", "rb");
  if (arch == NULL) {
    printf("\n***Problem opening CODE!***\n");
    return -1;
  }
  fseek(arch, 0, SEEK_END);
  siz = ftell(arch);
  fseek(arch, 0, SEEK_SET);
  fread(ram, siz, 1, arch);
  for (scan = 0; scan < siz; scan++)
    printf("%02x;", ram[scan]);
  do {
    opcode = ram[ptr];
    printf("%04x: %02x... ", ptr, opcode);
    count = 0;
    scan = 0;
    while (opcode != count && count < 256) {
      while (rom[scan] < 128)
        scan++;
      scan++;
      count++;
    }
    do {
      flag = rom[scan] & 128;
      c = rom[scan] & 127;
      switch (c) {
      case '@':
        printf("$%02x", ram[++ptr]);
        break;
      case '&':
        printf("$%04x", ram[++ptr] + 256 * ram[++ptr]);
        break;
      default:
        printf("%c", c);
      }
      scan++;
    } while (!flag);
    ptr++;
    printf("\n");
  } while (ram[ptr]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10610,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x105f0(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x105e8(%rbp)
cmpq   $0x0,-0x105e8(%rbp)
jne    11ae <main+0x5e>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151f <main+0x3cf>
mov    -0x105e8(%rbp),%rdi
mov    0x2e2c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x105e8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x105f8(%rbp)
mov    -0x105e8(%rbp),%rdi
mov    0x2df3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    -0x5e0(%rbp),%rdi
mov    -0x105f8(%rbp),%esi
mov    -0x105e8(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
lea    0xe2b(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x105e8(%rbp)
cmpq   $0x0,-0x105e8(%rbp)
jne    124e <main+0xfe>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151f <main+0x3cf>
mov    -0x105e8(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x105e8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x105f8(%rbp)
mov    -0x105e8(%rbp),%rdi
mov    0x2d53(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    -0x105e0(%rbp),%rdi
mov    -0x105f8(%rbp),%esi
mov    -0x105e8(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x0,-0x10600(%rbp)
mov    -0x10600(%rbp),%eax
cmp    -0x105f8(%rbp),%eax
jge    12f9 <main+0x1a9>
movslq -0x10600(%rbp),%rax
movzbl -0x105e0(%rbp,%rax,1),%esi
ff
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10600(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10600(%rbp)
jmp    12b6 <main+0x166>
jmp    12fe <main+0x1ae>
movslq -0x105f0(%rbp),%rax
mov    -0x105e0(%rbp,%rax,1),%al
mov    %al,-0x105ea(%rbp)
mov    -0x105f0(%rbp),%esi
movzbl -0x105ea(%rbp),%edx
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x105fc(%rbp)
movl   $0x0,-0x10600(%rbp)
movzbl -0x105ea(%rbp),%ecx
xor    %eax,%eax
cmp    -0x105fc(%rbp),%ecx
mov    %al,-0x10601(%rbp)
je     136f <main+0x21f>
cmpl   $0x100,-0x105fc(%rbp)
setl   %al
mov    %al,-0x10601(%rbp)
mov    -0x10601(%rbp),%al
test   $0x1,%al
jne    1382 <main+0x232>
jmp    13d8 <main+0x288>
jmp    1387 <main+0x237>
movslq -0x10600(%rbp),%rax
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
cmp    $0x80,%eax
jge    13b5 <main+0x265>
mov    -0x10600(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10600(%rbp)
jmp    1387 <main+0x237>
mov    -0x10600(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10600(%rbp)
mov    -0x105fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105fc(%rbp)
jmp    1341 <main+0x1f1>
jmp    13dd <main+0x28d>
movslq -0x10600(%rbp),%rax
mov    -0x5e0(%rbp,%rax,1),%al
and    $0x80,%al
mov    %al,-0x105eb(%rbp)
movslq -0x10600(%rbp),%rax
mov    -0x5e0(%rbp,%rax,1),%al
and    $0x7f,%al
mov    %al,-0x105e9(%rbp)
movzbl -0x105e9(%rbp),%eax
mov    %eax,-0x10608(%rbp)
sub    $0x26,%eax
je     1464 <main+0x314>
jmp    1424 <main+0x2d4>
mov    -0x10608(%rbp),%eax
sub    $0x40,%eax
jne    14ae <main+0x35e>
jmp    1438 <main+0x2e8>
mov    -0x105f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105f0(%rbp)
cltq
movzbl -0x105e0(%rbp,%rax,1),%esi
ff
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14c3 <main+0x373>
mov    -0x105f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105f0(%rbp)
cltq
movzbl -0x105e0(%rbp,%rax,1),%esi
ff
mov    -0x105f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105f0(%rbp)
cltq
movzbl -0x105e0(%rbp,%rax,1),%eax
ff
shl    $0x8,%eax
add    %eax,%esi
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14c3 <main+0x373>
movzbl -0x105e9(%rbp),%esi
lea    0xbca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10600(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10600(%rbp)
cmpb   $0x0,-0x105eb(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13dd <main+0x28d>
mov    -0x105f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105f0(%rbp)
lea    0xb40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x105f0(%rbp),%rax
cmpb   $0x0,-0x105e0(%rbp,%rax,1)
jne    12fe <main+0x1ae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10610,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x105e8,%rsp
lea    0xe78(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13d1 <main+0x261>
mov    %rax,%rbx
mov    0x2e41(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%ebp
mov    0x2e13(%rip),%r15
mov    (%r15),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rsp,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
lea    0xe22(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13da <main+0x26a>
mov    %rax,%rbx
mov    (%r14),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%ebp
mov    (%r15),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0x5e0(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
test   %ebp,%ebp
jle    126b <main+0xfb>
mov    %ebp,%ebp
lea    0xdc8(%rip),%r14
xor    %ebx,%ebx
movzbl 0x5e0(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1250 <main+0xe0>
mov    0x5e0(%rsp),%al
lea    0xdb2(%rip),%r13
movabs $0x100000000,%r14
xor    %r12d,%r12d
jmp    12b0 <main+0x140>
nopl   0x0(%rax,%rax,1)
movslq %r12d,%rbx
lea    0x1(%rbx),%r12
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x5e1(%rsp,%rbx,1),%al
test   %al,%al
je     13cd <main+0x25d>
mov    %r15,%rbx
movzbl %al,%ebp
xor    %r15d,%r15d
lea    0xd5c(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %bpl,%bpl
je     135d <main+0x1ed>
add    $0xffffffff,%ebp
cmp    $0xff,%ebp
mov    $0xff,%eax
cmovae %eax,%ebp
lea    0x1(%rbp),%eax
test   %ebp,%ebp
je     1340 <main+0x1d0>
mov    %eax,%ecx
and    $0x1fe,%ecx
xor    %r15d,%r15d
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movslq %r15d,%r15
lea    (%rsp,%r15,1),%rsi
shl    $0x20,%r15
nopl   0x0(%rax,%rax,1)
add    %r14,%r15
cmpb   $0x0,(%rsi)
lea    0x1(%rsi),%rsi
jns    1310 <main+0x1a0>
sar    $0x20,%r15
cmpb   $0x0,(%rsp,%r15,1)
lea    0x1(%r15),%r15
jns    1320 <main+0x1b0>
add    $0x2,%edx
cmp    %ecx,%edx
jne    1300 <main+0x190>
test   $0x1,%al
jne    1347 <main+0x1d7>
jmp    135d <main+0x1ed>
nopl   0x0(%rax,%rax,1)
xor    %r15d,%r15d
test   $0x1,%al
je     135d <main+0x1ed>
movslq %r15d,%rax
add    %rsp,%rax
nopl   (%rax)
add    $0x1,%r15d
cmpb   $0x0,(%rax)
lea    0x1(%rax),%rax
jns    1350 <main+0x1e0>
movslq %r15d,%rax
lea    (%rsp,%rax,1),%rbp
mov    %rbx,%r15
jmp    1381 <main+0x211>
nopl   0x0(%rax)
call   1030 <putchar@plt>
add    $0x1,%rbp
test   %bl,%bl
js     1290 <main+0x120>
movzbl 0x0(%rbp),%ebx
mov    %ebx,%edi
and    $0x7f,%edi
cmp    $0x26,%edi
je     13b0 <main+0x240>
cmp    $0x40,%edi
jne    1370 <main+0x200>
movslq %r12d,%r12
movzbl 0x5e1(%rsp,%r12,1),%esi
add    $0x1,%r12
mov    %r13,%rdi
jmp    13c4 <main+0x254>
nopl   0x0(%rax)
movslq %r12d,%rax
lea    0x2(%rax),%r12d
movzwl 0x1(%rax,%r15,1),%esi
lea    0xc6d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1375 <main+0x205>
xor    %eax,%eax
jmp    13eb <main+0x27b>
lea    0xc7c(%rip),%rdi
jmp    13e1 <main+0x271>
lea    0xc56(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x105e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"65C02.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [49 x i8] c"\0A***Problem opening Opcode List '65C02.bin'!***\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [9 x i8] c"test.bin\00"
@.str.4 = [30 x i8] c"\0A***Problem opening CODE!***\0A\00"
@.str.5 = [6 x i8] c"%02x;\00"
@.str.6 = [15 x i8] c"%04x: %02x... \00"
@.str.7 = [6 x i8] c"$%02x\00"
@.str.8 = [6 x i8] c"$%04x\00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1500 x i8]
%3 = alloca [65536 x i8]
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%13 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %163
18: ; preds = %0
%19 = load i32*, i32** %4
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
%22 = load i32*, i32** %4
%23 = call i32 @ftell(i32* %22)
store i32 %23, i32* %10
%24 = load i32*, i32** %4
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %24, i32 0, i32 %25)
%27 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* %10
%29 = load i32*, i32** %4
%30 = call i32 @fread(i8* %27, i32 %28, i32 1, i32* %29)
%31 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %4
%32 = load i32*, i32** %4
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %36
34: ; preds = %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %163
36: ; preds = %18
%37 = load i32*, i32** %4
%38 = load i32, i32* @SEEK_END
%39 = call i32 @fseek(i32* %37, i32 0, i32 %38)
%40 = load i32*, i32** %4
%41 = call i32 @ftell(i32* %40)
store i32 %41, i32* %10
%42 = load i32*, i32** %4
%43 = load i32, i32* @SEEK_SET
%44 = call i32 @fseek(i32* %42, i32 0, i32 %43)
%45 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%46 = load i32, i32* %10
%47 = load i32*, i32** %4
%48 = call i32 @fread(i8* %45, i32 %46, i32 1, i32* %47)
store i32 0, i32* %12
br label %49
49: ; preds = %60, %36
%50 = load i32, i32* %12
%51 = load i32, i32* %10
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32, i32* %12
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %53
%61 = load i32, i32* %12
%62 = add nsw i32 %61, 1
store i32 %62, i32* %12
br label %49
63: ; preds = %49
br label %64
64: ; preds = %156, %63
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %66
%68 = load i8, i8* %67
store i8 %68, i8* %6
%69 = load i32, i32* %8
%70 = load i8, i8* %6
%71 = zext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %69, i32 %71)
store i32 0, i32* %11
store i32 0, i32* %12
br label %73
73: ; preds = %94, %64
%74 = load i8, i8* %6
%75 = zext i8 %74 to i32
%76 = load i32, i32* %11
%77 = icmp ne i32 %75, %76
br i1 %77, label %78, label %81
78: ; preds = %73
%79 = load i32, i32* %11
%80 = icmp slt i32 %79, 256
br label %81
81: ; preds = %78, %73
%82 = phi i1 [ false, %73 ], [ %80, %78 ]
br i1 %82, label %83, label %99
83: ; preds = %81
br label %84
84: ; preds = %91, %83
%85 = load i32, i32* %12
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = icmp slt i32 %89, 128
br i1 %90, label %91, label %94
91: ; preds = %84
%92 = load i32, i32* %12
%93 = add nsw i32 %92, 1
store i32 %93, i32* %12
br label %84
94: ; preds = %84
%95 = load i32, i32* %12
%96 = add nsw i32 %95, 1
store i32 %96, i32* %12
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 1
store i32 %98, i32* %11
br label %73
99: ; preds = %81
br label %100
100: ; preds = %148, %99
%101 = load i32, i32* %12
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %102
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
%106 = and i32 %105, 128
%107 = trunc i32 %106 to i8
store i8 %107, i8* %7
%108 = load i32, i32* %12
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = and i32 %112, 127
%114 = trunc i32 %113 to i8
store i8 %114, i8* %5
%115 = load i8, i8* %5
%116 = zext i8 %115 to i32
switch i32 %116, label %141 [
i32 64, label %117
i32 38, label %125
]
117: ; preds = %100
%118 = load i32, i32* %8
%119 = add nsw i32 %118, 1
store i32 %119, i32* %8
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %120
%122 = load i8, i8* %121
%123 = zext i8 %122 to i32
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %123)
br label %145
125: ; preds = %100
%126 = load i32, i32* %8
%127 = add nsw i32 %126, 1
store i32 %127, i32* %8
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = zext i8 %130 to i32
%132 = load i32, i32* %8
%133 = add nsw i32 %132, 1
store i32 %133, i32* %8
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %134
%136 = load i8, i8* %135
%137 = zext i8 %136 to i32
%138 = mul nsw i32 256, %137
%139 = add nsw i32 %131, %138
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %139)
br label %145
141: ; preds = %100
%142 = load i8, i8* %5
%143 = zext i8 %142 to i32
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %143)
br label %145
145: ; preds = %141, %125, %117
%146 = load i32, i32* %12
%147 = add nsw i32 %146, 1
store i32 %147, i32* %12
br label %148
148: ; preds = %145
%149 = load i8, i8* %7
%150 = icmp ne i8 %149, 0
%151 = xor i1 %150, true
br i1 %151, label %100, label %152
152: ; preds = %148
%153 = load i32, i32* %8
%154 = add nsw i32 %153, 1
store i32 %154, i32* %8
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %156
156: ; preds = %152
%157 = load i32, i32* %8
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 %158
%160 = load i8, i8* %159
%161 = icmp ne i8 %160, 0
br i1 %161, label %64, label %162
162: ; preds = %156
store i32 0, i32* %1
br label %163
163: ; preds = %162, %34, %16
%164 = load i32, i32* %1
ret i32 %164
}

LLVM IR (-O2):
@.str = [10 x i8] c"65C02.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [9 x i8] c"test.bin\00"
@.str.5 = [6 x i8] c"%02x;\00"
@.str.6 = [15 x i8] c"%04x: %02x... \00"
@.str.7 = [6 x i8] c"$%02x\00"
@.str.8 = [6 x i8] c"$%04x\00"
@str = [29 x i8] c"\0A***Problem opening CODE!***\00"
@str.11 = [48 x i8] c"\0A***Problem opening Opcode List '65C02.bin'!***\00"
define i32 @main() {
%1 = alloca [1500 x i8]
%2 = alloca [65536 x i8]
%3 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %134, label %7
7: ; preds = %0
%8 = load i32, i32* @SEEK_END
%9 = tail call i32 @fseek(i32* %5, i32 0, i32 %8)
%10 = tail call i32 @ftell(i32* %5)
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @fseek(i32* %5, i32 0, i32 %11)
%13 = call i32 @fread(i8* %3, i32 %10, i32 1, i32* %5)
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %134, label %16
16: ; preds = %7
%17 = load i32, i32* @SEEK_END
%18 = tail call i32 @fseek(i32* %14, i32 0, i32 %17)
%19 = tail call i32 @ftell(i32* %14)
%20 = load i32, i32* @SEEK_SET
%21 = tail call i32 @fseek(i32* %14, i32 0, i32 %20)
%22 = call i32 @fread(i8* %4, i32 %19, i32 1, i32* %14)
%23 = icmp sgt i32 %19, 0
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = zext i32 %19 to i64
br label %28
26: ; preds = %28, %16
%27 = load i8, i8* %4
br label %36
28: ; preds = %24, %28
%29 = phi i64 [ 0, %24 ], [ %34, %28 ]
%30 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %29, 1
%35 = icmp eq i64 %34, %25
br i1 %35, label %26, label %28
36: ; preds = %26, %127
%37 = phi i8 [ %132, %127 ], [ %27, %26 ]
%38 = phi i32 [ %128, %127 ], [ 0, %26 ]
%39 = zext i8 %37 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %38, i32 %39)
%41 = icmp eq i8 %37, 0
br i1 %41, label %65, label %42
42: ; preds = %36
%43 = add nsw i32 %39, -1
%44 = call i32 @llvm.umin.i32(i32 %43, i32 255)
%45 = add nuw nsw i32 %44, 1
%46 = and i32 %45, 1
%47 = icmp eq i32 %44, 0
br i1 %47, label %50, label %48
48: ; preds = %42
%49 = and i32 %45, 510
br label %68
50: ; preds = %88, %42
%51 = phi i32 [ undef, %42 ], [ %90, %88 ]
%52 = phi i32 [ 0, %42 ], [ %90, %88 ]
%53 = icmp eq i32 %46, 0
br i1 %53, label %65, label %54
54: ; preds = %50
%55 = sext i32 %52 to i64
br label %56
56: ; preds = %56, %54
%57 = phi i64 [ %61, %56 ], [ %55, %54 ]
%58 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = icmp sgt i8 %59, -1
%61 = add i64 %57, 1
br i1 %60, label %56, label %62
62: ; preds = %56
%63 = trunc i64 %57 to i32
%64 = add nsw i32 %63, 1
br label %65
65: ; preds = %62, %50, %36
%66 = phi i32 [ 0, %36 ], [ %51, %50 ], [ %64, %62 ]
%67 = sext i32 %66 to i64
br label %93
68: ; preds = %88, %48
%69 = phi i32 [ 0, %48 ], [ %90, %88 ]
%70 = phi i32 [ 0, %48 ], [ %91, %88 ]
%71 = sext i32 %69 to i64
br label %72
72: ; preds = %72, %68
%73 = phi i64 [ %77, %72 ], [ %71, %68 ]
%74 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = icmp sgt i8 %75, -1
%77 = add i64 %73, 1
br i1 %76, label %72, label %78
78: ; preds = %72
%79 = shl i64 %73, 32
%80 = add i64 %79, 4294967296
%81 = ashr exact i64 %80, 32
br label %82
82: ; preds = %82, %78
%83 = phi i64 [ %87, %82 ], [ %81, %78 ]
%84 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = icmp sgt i8 %85, -1
%87 = add i64 %83, 1
br i1 %86, label %82, label %88
88: ; preds = %82
%89 = trunc i64 %83 to i32
%90 = add nsw i32 %89, 1
%91 = add i32 %70, 2
%92 = icmp eq i32 %91, %49
br i1 %92, label %50, label %68
93: ; preds = %65, %123
%94 = phi i64 [ %67, %65 ], [ %125, %123 ]
%95 = phi i32 [ %38, %65 ], [ %124, %123 ]
%96 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %94
%97 = load i8, i8* %96
%98 = and i8 %97, 127
%99 = zext i8 %98 to i32
switch i32 %99, label %121 [
i32 64, label %100
i32 38, label %107
]
100: ; preds = %93
%101 = add nsw i32 %95, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 %102
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %105)
br label %123
107: ; preds = %93
%108 = add nsw i32 %95, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = add nsw i32 %95, 2
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = shl nuw nsw i32 %117, 8
%119 = or i32 %118, %112
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %119)
br label %123
121: ; preds = %93
%122 = tail call i32 @putchar(i32 %99)
br label %123
123: ; preds = %121, %107, %100
%124 = phi i32 [ %95, %121 ], [ %113, %107 ], [ %101, %100 ]
%125 = add i64 %94, 1
%126 = icmp sgt i8 %97, -1
br i1 %126, label %93, label %127
127: ; preds = %123
%128 = add nsw i32 %124, 1
%129 = tail call i32 @putchar(i32 10)
%130 = sext i32 %128 to i64
%131 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 %130
%132 = load i8, i8* %131
%133 = icmp eq i8 %132, 0
br i1 %133, label %137, label %36
134: ; preds = %7, %0
%135 = phi i8* [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0), %0 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), %7 ]
%136 = tail call i32 @puts(i8* dereferenceable(1) %135)
br label %137
137: ; preds = %127, %134
%138 = phi i32 [ -1, %134 ], [ 0, %127 ]
ret i32 %138
}