#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  unsigned char rom[1500];
  unsigned char ram[65536];
  FILE *arch;
  unsigned char b, opcode, c, x, exit = 0;
  char buf[80];
  int ptr = 0, oldptr, siz, count, scan, oldscan, index;
  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);
  ptr = 0x400;
  do {
    printf("%04x: ", ptr);
    gets(buf);
    scan = 0;
    oldscan = 0;
    index = 0;
    opcode = 0;
    do {
      while (buf[index] == ' ')
        index++;
      while (rom[scan] == ' ')
        scan++;
      b = buf[index];
      if (b >= 'a' && b <= 'z')
        b &= 223;
      c = rom[scan] & 127;
      x = rom[scan] & 128;
      if (b != c) {
        while (rom[scan++] < 128)
          ;
        oldscan = scan;
        opcode++;
        if (!opcode) {
          x = 1;
        } else {
          index = 0;
          x = 0;
        }
      } else {
        index++;
        scan++;
        if (x == 128) {
          while (buf[index] == ' ')
            index++;
          if (buf[index]) {
            oldscan = scan;
            opcode++;
            index = 0;
            x = 0;
          }
        }
      }
    } while (!x);
    if (x == 128) {
      oldscan--;
      printf("[%02x] ", opcode);
      do {
        printf("%c", rom[++oldscan] & 127);
      } while (rom[oldscan] < 128);
    } else {
      printf("***ERROR***");
    }
    printf("\n");
    ptr++;
  } while (-1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10660,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x105ed(%rbp)
movl   $0x0,-0x10644(%rbp)
lea    0xe76(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x105e8(%rbp)
cmpq   $0x0,-0x105e8(%rbp)
jne    11c5 <main+0x65>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    155f <main+0x3ff>
mov    -0x105e8(%rbp),%rdi
mov    0x2e15(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x105e8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x1064c(%rbp)
mov    -0x105e8(%rbp),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
lea    -0x5e0(%rbp),%rdi
mov    -0x1064c(%rbp),%esi
mov    -0x105e8(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x400,-0x10644(%rbp)
mov    -0x10644(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10640(%rbp),%rdi
call   1060 <gets@plt>
movl   $0x0,-0x10654(%rbp)
movl   $0x0,-0x10658(%rbp)
movl   $0x0,-0x1065c(%rbp)
movb   $0x0,-0x105ea(%rbp)
jmp    1277 <main+0x117>
movslq -0x1065c(%rbp),%rax
movsbl -0x10640(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    12a3 <main+0x143>
mov    -0x1065c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1065c(%rbp)
jmp    1277 <main+0x117>
jmp    12a8 <main+0x148>
movslq -0x10654(%rbp),%rax
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    12d4 <main+0x174>
mov    -0x10654(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10654(%rbp)
jmp    12a8 <main+0x148>
movslq -0x1065c(%rbp),%rax
mov    -0x10640(%rbp,%rax,1),%al
mov    %al,-0x105e9(%rbp)
movzbl -0x105e9(%rbp),%eax
cmp    $0x61,%eax
jl     131a <main+0x1ba>
movzbl -0x105e9(%rbp),%eax
cmp    $0x7a,%eax
jg     131a <main+0x1ba>
movzbl -0x105e9(%rbp),%eax
and    $0xdf,%eax
mov    %al,-0x105e9(%rbp)
movslq -0x10654(%rbp),%rax
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
and    $0x7f,%eax
mov    %al,-0x105eb(%rbp)
movslq -0x10654(%rbp),%rax
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
and    $0x80,%eax
mov    %al,-0x105ec(%rbp)
movzbl -0x105e9(%rbp),%eax
movzbl -0x105eb(%rbp),%ecx
cmp    %ecx,%eax
je     13db <main+0x27b>
jmp    1367 <main+0x207>
mov    -0x10654(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10654(%rbp)
cltq
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
cmp    $0x80,%eax
jge    1392 <main+0x232>
jmp    1367 <main+0x207>
mov    -0x10654(%rbp),%eax
mov    %eax,-0x10658(%rbp)
mov    -0x105ea(%rbp),%al
add    $0x1,%al
mov    %al,-0x105ea(%rbp)
cmpb   $0x0,-0x105ea(%rbp)
jne    13c5 <main+0x265>
movb   $0x1,-0x105ec(%rbp)
jmp    13d6 <main+0x276>
movl   $0x0,-0x1065c(%rbp)
movb   $0x0,-0x105ec(%rbp)
jmp    1486 <main+0x326>
mov    -0x1065c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1065c(%rbp)
mov    -0x10654(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10654(%rbp)
movzbl -0x105ec(%rbp),%eax
cmp    $0x80,%eax
jne    1481 <main+0x321>
jmp    1410 <main+0x2b0>
movslq -0x1065c(%rbp),%rax
movsbl -0x10640(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    143c <main+0x2dc>
mov    -0x1065c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1065c(%rbp)
jmp    1410 <main+0x2b0>
movslq -0x1065c(%rbp),%rax
cmpb   $0x0,-0x10640(%rbp,%rax,1)
je     147c <main+0x31c>
mov    -0x10654(%rbp),%eax
mov    %eax,-0x10658(%rbp)
mov    -0x105ea(%rbp),%al
add    $0x1,%al
mov    %al,-0x105ea(%rbp)
movl   $0x0,-0x1065c(%rbp)
movb   $0x0,-0x105ec(%rbp)
jmp    1481 <main+0x321>
jmp    1486 <main+0x326>
jmp    148b <main+0x32b>
cmpb   $0x0,-0x105ec(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1272 <main+0x112>
movzbl -0x105ec(%rbp),%eax
cmp    $0x80,%eax
jne    151e <main+0x3be>
mov    -0x10658(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10658(%rbp)
movzbl -0x105ea(%rbp),%esi
lea    0xb77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10658(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10658(%rbp)
cltq
movzbl -0x5e0(%rbp,%rax,1),%esi
ff
and    $0x7f,%esi
lea    0xb55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x10658(%rbp),%rax
movzbl -0x5e0(%rbp,%rax,1),%eax
ff
cmp    $0x80,%eax
jl     14d5 <main+0x375>
jmp    152c <main+0x3cc>
lea    0xb2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10644(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10644(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    122d <main+0xcd>
jmp    1558 <main+0x3f8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x638,%rsp
lea    0xe68(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     13bb <main+0x23b>
mov    %rax,%rbx
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%ebp
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x50(%rsp),%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
mov    $0x400,%r14d
movabs $0xffffffff00000000,%r13
ff ff ff
movabs $0x100000000,%r15
jmp    122c <main+0xac>
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
lea    0xdda(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rdi
call   1080 <gets@plt>
xor    %r8d,%r8d
xor    %r10d,%r10d
xor    %r12d,%r12d
xor    %r9d,%r9d
jmp    127e <main+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%ebx
and    $0x80,%bl
test   %dl,%dl
js     1325 <main+0x1a5>
mov    %r10d,%esi
mov    %edi,%r9d
mov    %esi,%r10d
test   %bl,%bl
jne    1370 <main+0x1f0>
movslq %r9d,%rcx
lea    (%rsp,%rcx,1),%rax
add    $0x1,%ecx
mov    %r9d,%edi
nopl   0x0(%rax,%rax,1)
mov    %ecx,%r9d
movzbl (%rax),%ebx
add    $0x1,%edi
add    $0x1,%rax
lea    0x1(%r9),%ecx
cmp    $0x20,%bl
je     1290 <main+0x110>
movslq %r10d,%rbp
lea    (%rsp,%rbp,1),%rcx
add    $0x50,%rcx
shl    $0x20,%rbp
add    %r13,%rbp
nopl   0x0(%rax,%rax,1)
mov    %r10d,%esi
add    %r15,%rbp
movzbl (%rcx),%edx
lea    0x1(%rsi),%r10d
add    $0x1,%rcx
cmp    $0x20,%dl
je     12c0 <main+0x140>
lea    -0x61(%rbx),%ecx
movzbl %bl,%ebp
and    $0xdf,%bl
cmp    $0x1a,%cl
movzbl %bl,%ecx
cmovae %ebp,%ecx
mov    %edx,%eax
and    $0x7f,%al
cmp    %al,%cl
je     1260 <main+0xe0>
movslq %esi,%rax
add    %rsp,%rax
add    $0x50,%rax
xchg   %ax,%ax
add    $0x1,%esi
cmpb   $0x0,(%rax)
lea    0x1(%rax),%rax
jns    1300 <main+0x180>
xor    %ebx,%ebx
mov    %esi,%r12d
mov    $0x0,%r9d
inc    %r8b
jne    1273 <main+0xf3>
jmp    1210 <main+0x90>
movslq %r9d,%rax
add    %rsp,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
cmp    $0x20,%cl
jne    1342 <main+0x1c2>
add    $0x1,%r9d
add    $0x1,%rax
jmp    1330 <main+0x1b0>
test   %cl,%cl
jne    134e <main+0x1ce>
mov    %r10d,%esi
jmp    1273 <main+0xf3>
add    $0x1,%r8b
xor    %ebx,%ebx
mov    %r10d,%esi
mov    %r10d,%r12d
xor    %r9d,%r9d
jmp    1273 <main+0xf3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%r12d
movzbl %r8b,%esi
lea    0xc95(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %r12d,%rbx
lea    0x51(%rsp),%rax
add    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%ebp
mov    %ebp,%edi
and    $0x7f,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
test   %bpl,%bpl
jns    13a0 <main+0x220>
jmp    121e <main+0x9e>
lea    0xc66(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x638,%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 = [7 x i8] c"%04x: \00"
@.str.4 = [8 x i8] c"[%02x] \00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [12 x i8] c"***ERROR***\00"
@.str.7 = [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 i8
%9 = alloca i8
%10 = alloca [80 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %1
store i8 0, i8* %9
store i32 0, i32* %11
%18 = 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* %18, i32** %4
%19 = load i32*, i32** %4
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = 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 %190
23: ; preds = %0
%24 = load i32*, i32** %4
%25 = load i32, i32* @SEEK_END
%26 = call i32 @fseek(i32* %24, i32 0, i32 %25)
%27 = load i32*, i32** %4
%28 = call i32 @ftell(i32* %27)
store i32 %28, i32* %13
%29 = load i32*, i32** %4
%30 = load i32, i32* @SEEK_SET
%31 = call i32 @fseek(i32* %29, i32 0, i32 %30)
%32 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 0
%33 = load i32, i32* %13
%34 = load i32*, i32** %4
%35 = call i32 @fread(i8* %32, i32 %33, i32 1, i32* %34)
store i32 1024, i32* %11
br label %36
36: ; preds = %188, %23
%37 = load i32, i32* %11
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%40 = call i32 @gets(i8* %39)
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i8 0, i8* %6
br label %41
41: ; preds = %151, %36
br label %42
42: ; preds = %49, %41
%43 = load i32, i32* %17
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 32
br i1 %48, label %49, label %52
49: ; preds = %42
%50 = load i32, i32* %17
%51 = add nsw i32 %50, 1
store i32 %51, i32* %17
br label %42
52: ; preds = %42
br label %53
53: ; preds = %60, %52
%54 = load i32, i32* %15
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = icmp eq i32 %58, 32
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = load i32, i32* %15
%62 = add nsw i32 %61, 1
store i32 %62, i32* %15
br label %53
63: ; preds = %53
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %65
%67 = load i8, i8* %66
store i8 %67, i8* %5
%68 = load i8, i8* %5
%69 = zext i8 %68 to i32
%70 = icmp sge i32 %69, 97
br i1 %70, label %71, label %80
71: ; preds = %63
%72 = load i8, i8* %5
%73 = zext i8 %72 to i32
%74 = icmp sle i32 %73, 122
br i1 %74, label %75, label %80
75: ; preds = %71
%76 = load i8, i8* %5
%77 = zext i8 %76 to i32
%78 = and i32 %77, 223
%79 = trunc i32 %78 to i8
store i8 %79, i8* %5
br label %80
80: ; preds = %75, %71, %63
%81 = load i32, i32* %15
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %82
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = and i32 %85, 127
%87 = trunc i32 %86 to i8
store i8 %87, i8* %7
%88 = load i32, i32* %15
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = and i32 %92, 128
%94 = trunc i32 %93 to i8
store i8 %94, i8* %8
%95 = load i8, i8* %5
%96 = zext i8 %95 to i32
%97 = load i8, i8* %7
%98 = zext i8 %97 to i32
%99 = icmp ne i32 %96, %98
br i1 %99, label %100, label %119
100: ; preds = %80
br label %101
101: ; preds = %109, %100
%102 = load i32, i32* %15
%103 = add nsw i32 %102, 1
store i32 %103, i32* %15
%104 = sext i32 %102 to i64
%105 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %104
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = icmp slt i32 %107, 128
br i1 %108, label %109, label %110
109: ; preds = %101
br label %101
110: ; preds = %101
%111 = load i32, i32* %15
store i32 %111, i32* %16
%112 = load i8, i8* %6
%113 = add i8 %112, 1
store i8 %113, i8* %6
%114 = load i8, i8* %6
%115 = icmp ne i8 %114, 0
br i1 %115, label %117, label %116
116: ; preds = %110
store i8 1, i8* %8
br label %118
117: ; preds = %110
store i32 0, i32* %17
store i8 0, i8* %8
br label %118
118: ; preds = %117, %116
br label %150
119: ; preds = %80
%120 = load i32, i32* %17
%121 = add nsw i32 %120, 1
store i32 %121, i32* %17
%122 = load i32, i32* %15
%123 = add nsw i32 %122, 1
store i32 %123, i32* %15
%124 = load i8, i8* %8
%125 = zext i8 %124 to i32
%126 = icmp eq i32 %125, 128
br i1 %126, label %127, label %149
127: ; preds = %119
br label %128
128: ; preds = %135, %127
%129 = load i32, i32* %17
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %130
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 32
br i1 %134, label %135, label %138
135: ; preds = %128
%136 = load i32, i32* %17
%137 = add nsw i32 %136, 1
store i32 %137, i32* %17
br label %128
138: ; preds = %128
%139 = load i32, i32* %17
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %140
%142 = load i8, i8* %141
%143 = icmp ne i8 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %138
%145 = load i32, i32* %15
store i32 %145, i32* %16
%146 = load i8, i8* %6
%147 = add i8 %146, 1
store i8 %147, i8* %6
store i32 0, i32* %17
store i8 0, i8* %8
br label %148
148: ; preds = %144, %138
br label %149
149: ; preds = %148, %119
br label %150
150: ; preds = %149, %118
br label %151
151: ; preds = %150
%152 = load i8, i8* %8
%153 = icmp ne i8 %152, 0
%154 = xor i1 %153, true
br i1 %154, label %41, label %155
155: ; preds = %151
%156 = load i8, i8* %8
%157 = zext i8 %156 to i32
%158 = icmp eq i32 %157, 128
br i1 %158, label %159, label %182
159: ; preds = %155
%160 = load i32, i32* %16
%161 = add nsw i32 %160, -1
store i32 %161, i32* %16
%162 = load i8, i8* %6
%163 = zext i8 %162 to i32
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %163)
br label %165
165: ; preds = %174, %159
%166 = load i32, i32* %16
%167 = add nsw i32 %166, 1
store i32 %167, i32* %16
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %168
%170 = load i8, i8* %169
%171 = zext i8 %170 to i32
%172 = and i32 %171, 127
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %172)
br label %174
174: ; preds = %165
%175 = load i32, i32* %16
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 %176
%178 = load i8, i8* %177
%179 = zext i8 %178 to i32
%180 = icmp slt i32 %179, 128
br i1 %180, label %165, label %181
181: ; preds = %174
br label %184
182: ; preds = %155
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %184
184: ; preds = %182, %181
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%186 = load i32, i32* %11
%187 = add nsw i32 %186, 1
store i32 %187, i32* %11
br label %188
188: ; preds = %184
br i1 true, label %36, label %189
189: ; preds = %188
store i32 0, i32* %1
br label %190
190: ; preds = %189, %21
%191 = load i32, i32* %1
ret i32 %191
}

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 = [7 x i8] c"%04x: \00"
@.str.4 = [8 x i8] c"[%02x] \00"
@.str.6 = [12 x i8] c"***ERROR***\00"
@str = [48 x i8] c"\0A***Problem opening Opcode List '65C02.bin'!***\00"
define i32 @main() {
%1 = alloca [1500 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 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 %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
ret i32 -1
9: ; preds = %0
%10 = load i32, i32* @SEEK_END
%11 = tail call i32 @fseek(i32* %5, i32 0, i32 %10)
%12 = tail call i32 @ftell(i32* %5)
%13 = load i32, i32* @SEEK_SET
%14 = tail call i32 @fseek(i32* %5, i32 0, i32 %13)
%15 = call i32 @fread(i8* %3, i32 %12, i32 1, i32* %5)
br label %16
16: ; preds = %102, %9
%17 = phi i32 [ 1024, %9 ], [ %104, %102 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @gets(i8* %4)
br label %20
20: ; preds = %79, %16
%21 = phi i8 [ 0, %16 ], [ %81, %79 ]
%22 = phi i32 [ 0, %16 ], [ %82, %79 ]
%23 = phi i32 [ 0, %16 ], [ %83, %79 ]
%24 = phi i32 [ 0, %16 ], [ %84, %79 ]
%25 = sext i32 %24 to i64
br label %26
26: ; preds = %26, %20
%27 = phi i64 [ %31, %26 ], [ %25, %20 ]
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 32
%31 = add i64 %27, 1
br i1 %30, label %26, label %32
32: ; preds = %26
%33 = sext i32 %22 to i64
br label %34
34: ; preds = %34, %32
%35 = phi i64 [ %39, %34 ], [ %33, %32 ]
%36 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 32
%39 = add i64 %35, 1
br i1 %38, label %34, label %40
40: ; preds = %34
%41 = add i8 %29, -97
%42 = icmp ult i8 %41, 26
%43 = and i8 %29, -33
%44 = select i1 %42, i8 %43, i8 %29
%45 = and i8 %37, 127
%46 = and i8 %37, -128
%47 = icmp eq i8 %44, %45
br i1 %47, label %61, label %48
48: ; preds = %40
%49 = shl i64 %35, 32
%50 = ashr exact i64 %49, 32
br label %51
51: ; preds = %48, %51
%52 = phi i64 [ %50, %48 ], [ %53, %51 ]
%53 = add i64 %52, 1
%54 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %52
%55 = load i8, i8* %54
%56 = icmp sgt i8 %55, -1
br i1 %56, label %51, label %57
57: ; preds = %51
%58 = trunc i64 %53 to i32
%59 = add i8 %21, 1
%60 = icmp eq i8 %59, 0
br i1 %60, label %100, label %79
61: ; preds = %40
%62 = trunc i64 %35 to i32
%63 = trunc i64 %27 to i32
%64 = add i32 %63, 1
%65 = add nsw i32 %62, 1
%66 = icmp slt i8 %37, 0
br i1 %66, label %67, label %79
67: ; preds = %61
%68 = sext i32 %64 to i64
br label %69
69: ; preds = %67, %73
%70 = phi i64 [ %68, %67 ], [ %74, %73 ]
%71 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %70
%72 = load i8, i8* %71
switch i8 %72, label %75 [
i8 32, label %73
i8 0, label %77
]
73: ; preds = %69
%74 = add i64 %70, 1
br label %69
75: ; preds = %69
%76 = add i8 %21, 1
br label %79
77: ; preds = %69
%78 = trunc i64 %70 to i32
br label %79
79: ; preds = %77, %57, %75, %61
%80 = phi i8 [ 0, %75 ], [ %46, %61 ], [ 0, %57 ], [ %46, %77 ]
%81 = phi i8 [ %76, %75 ], [ %21, %61 ], [ %59, %57 ], [ %21, %77 ]
%82 = phi i32 [ %65, %75 ], [ %65, %61 ], [ %58, %57 ], [ %65, %77 ]
%83 = phi i32 [ %65, %75 ], [ %23, %61 ], [ %58, %57 ], [ %23, %77 ]
%84 = phi i32 [ 0, %75 ], [ %64, %61 ], [ 0, %57 ], [ %78, %77 ]
%85 = icmp eq i8 %80, 0
br i1 %85, label %20, label %86
86: ; preds = %79
%87 = add i32 %83, -1
%88 = zext i8 %81 to i32
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %88)
%90 = sext i32 %87 to i64
br label %91
91: ; preds = %91, %86
%92 = phi i64 [ %93, %91 ], [ %90, %86 ]
%93 = add i64 %92, 1
%94 = getelementptr inbounds [1500 x i8], [1500 x i8]* %1, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = and i8 %95, 127
%97 = zext i8 %96 to i32
%98 = call i32 @putchar(i32 %97)
%99 = icmp sgt i8 %95, -1
br i1 %99, label %91, label %102
100: ; preds = %57
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %102
102: ; preds = %91, %100
%103 = call i32 @putchar(i32 10)
%104 = add nuw nsw i32 %17, 1
br label %16
}