#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 uint8_t;
typedef int uint16_t;
typedef char time_t;
typedef int /*<<< orphan*/ secs;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ disassemble(int, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int getc_unlocked(int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc_unlocked(char, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
void display_trace(const char *filename, FILE *fp) {
  char magic[4];
  time_t secs;
  int nmos, cmos, tickcount;
  char tmstr[20];
  uint16_t pc, ppc = 0;
  uint8_t op, p1, p2, a, x, y, s, f;
  nmos = cmos = 0;
  if (fread(magic, 8, 1, fp) == 1) {
    if (strncmp(magic, "6502NMOS", 8) == 0)
      nmos = 1;
    else if (strncmp(magic, "6502CMOS", 8) == 0)
      cmos = 1;
  }
  if (nmos || cmos) {
    if (fread(&secs, sizeof(secs), 1, fp) == 1) {
      strftime(tmstr, sizeof tmstr, "%d/%m/%Y %H:%M:%S", localtime(&secs));
      printf("6502 trace starts %s\n", tmstr);
      while ((tickcount = getc_unlocked(fp)) != EOF) {
        pc = getc_unlocked(fp);
        pc |= getc_unlocked(fp) << 8;
        pc--;
        op = getc_unlocked(fp);
        p1 = getc_unlocked(fp);
        p2 = getc_unlocked(fp);
        a = getc_unlocked(fp);
        x = getc_unlocked(fp);
        y = getc_unlocked(fp);
        s = getc_unlocked(fp);
        f = getc_unlocked(fp);
        if (pc >= 0xf800 && ppc < 0xf800)
          puts("call to OS ROM");
        else if (pc < 0xf800) {
          printf("%02d ", tickcount);
          disassemble(cmos, pc, op, p1, p2, stdout);
          printf(" %02X %02X %02X %02X ", a, x, y, s);
          putc_unlocked((f & 0x80) ? 'N' : '.', stdout);
          putc_unlocked((f & 0x40) ? 'V' : '.', stdout);
          putc_unlocked((f & 0x08) ? 'D' : '.', stdout);
          putc_unlocked((f & 0x04) ? 'I' : '.', stdout);
          putc_unlocked((f & 0x02) ? 'Z' : '.', stdout);
          putc_unlocked((f & 0x01) ? 'C' : '.', stdout);
          putc_unlocked('\n', stdout);
        }
        ppc = pc;
      }
    } else
      fprintf(stderr, "disptrace: unexpected end of file on %s\n", filename);
  } else
    fprintf(stderr, "disptrace: %s not a 6502 trace file\n", filename);
}


x86 assembly (clang, -O0):
<display_trace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fread@plt>
cmp    $0x1,%eax
jne    1240 <display_trace+0xa0>
lea    -0x14(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1210 <display_trace+0x70>
movl   $0x1,-0x1c(%rbp)
jmp    123b <display_trace+0x9b>
lea    -0x14(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1236 <display_trace+0x96>
movl   $0x1,-0x20(%rbp)
jmp    123b <display_trace+0x9b>
jmp    1240 <display_trace+0xa0>
cmpl   $0x0,-0x1c(%rbp)
jne    1254 <display_trace+0xb4>
cmpl   $0x0,-0x20(%rbp)
je     1503 <display_trace+0x363>
mov    -0x10(%rbp),%rcx
lea    -0x15(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1070 <fread@plt>
cmp    $0x1,%eax
jne    14e5 <display_trace+0x345>
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x15(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xd7e(%rip),%rdx
call   10b0 <strftime@plt>
lea    -0x40(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d2a(%rip),%rcx
cmp    (%rcx),%eax
je     14e0 <display_trace+0x340>
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
shl    $0x8,%eax
or     -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xf800,-0x44(%rbp)
jl     1378 <display_trace+0x1d8>
cmpl   $0xf800,-0x48(%rbp)
jge    1378 <display_trace+0x1d8>
lea    0xccc(%rip),%rdi
call   1050 <puts@plt>
jmp    14d5 <display_trace+0x335>
cmpl   $0xf800,-0x44(%rbp)
jge    14d0 <display_trace+0x330>
mov    -0x24(%rbp),%esi
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
mov    0x2c23(%rip),%rax
mov    (%rax),%r9d
call   10c0 <disassemble@plt>
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x60(%rbp),%ecx
mov    -0x64(%rbp),%r8d
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x68(%rbp),%edx
and    $0x80,%edx
mov    $0x2e,%eax
mov    $0x4e,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2be0(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    -0x68(%rbp),%edx
and    $0x40,%edx
mov    $0x2e,%eax
mov    $0x56,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2bb9(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    -0x68(%rbp),%edx
and    $0x8,%edx
mov    $0x2e,%eax
mov    $0x44,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2b92(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    -0x68(%rbp),%edx
and    $0x4,%edx
mov    $0x2e,%eax
mov    $0x49,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2b6b(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    -0x68(%rbp),%edx
and    $0x2,%edx
mov    $0x2e,%eax
mov    $0x5a,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2b44(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    -0x68(%rbp),%edx
and    $0x1,%edx
mov    $0x2e,%eax
mov    $0x43,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    0x2b1d(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   10a0 <putc_unlocked@plt>
mov    0x2b0c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   10a0 <putc_unlocked@plt>
jmp    14d5 <display_trace+0x335>
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    12ab <display_trace+0x10b>
jmp    14fe <display_trace+0x35e>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xb6c(%rip),%rsi
call   1090 <fprintf@plt>
jmp    151c <display_trace+0x37c>
mov    0x2ace(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xb77(%rip),%rsi
call   1090 <fprintf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_trace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fread@plt>
lea    0xebc(%rip),%rbp
cmp    $0x1,%eax
jne    1450 <display_trace+0x2b0>
lea    0xe1e(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     121f <display_trace+0x7f>
lea    0xe0c(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1450 <display_trace+0x2b0>
movl   $0x1,0xc(%rsp)
jmp    1227 <display_trace+0x87>
movl   $0x0,0xc(%rsp)
lea    0xb(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fread@plt>
cmp    $0x1,%eax
jne    1449 <display_trace+0x2a9>
lea    0xb(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xdba(%rip),%rdx
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   10b0 <strftime@plt>
lea    0xdb1(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%r15d
mov    0x2d59(%rip),%rax
cmp    (%rax),%r15d
je     1464 <display_trace+0x2c4>
xor    %r13d,%r13d
jmp    12c7 <display_trace+0x127>
nopl   (%rax)
lea    0xd93(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%r15d
mov    0x2d2a(%rip),%rax
cmp    (%rax),%r15d
je     1464 <display_trace+0x2c4>
mov    %r13d,0x2c(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
or     %ebx,%ebp
lea    -0x1(%rbp),%r13d
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x28(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x24(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x1c(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x20(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x18(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,0x14(%rsp)
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1060 <getc_unlocked@plt>
mov    %eax,%r12d
cmp    $0xf801,%ebp
jl     135c <display_trace+0x1bc>
cmpl   $0xf7ff,0x2c(%rsp)
jle    12a0 <display_trace+0x100>
cmp    $0xf800,%ebp
jg     12ac <display_trace+0x10c>
lea    0xcda(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c50(%rip),%rbp
mov    0x0(%rbp),%r9d
mov    0xc(%rsp),%edi
mov    %r13d,%esi
mov    0x28(%rsp),%edx
mov    0x24(%rsp),%ecx
mov    0x1c(%rsp),%r8d
call   10c0 <disassemble@plt>
lea    0xcab(%rip),%rdi
mov    0x20(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12d,%edi
shr    $0x2,%edi
and    $0x20,%edi
mov    0x0(%rbp),%esi
add    $0x2e,%edi
call   10a0 <putc_unlocked@plt>
test   $0x40,%r12b
mov    0x0(%rbp),%esi
mov    $0x56,%edi
mov    $0x2e,%ebx
cmove  %ebx,%edi
call   10a0 <putc_unlocked@plt>
test   $0x8,%r12b
mov    0x0(%rbp),%esi
mov    $0x44,%edi
cmove  %ebx,%edi
call   10a0 <putc_unlocked@plt>
test   $0x4,%r12b
mov    0x0(%rbp),%esi
mov    $0x49,%edi
cmove  %ebx,%edi
call   10a0 <putc_unlocked@plt>
test   $0x2,%r12b
mov    0x0(%rbp),%esi
mov    $0x5a,%edi
cmove  %ebx,%edi
call   10a0 <putc_unlocked@plt>
test   $0x1,%r12b
mov    0x0(%rbp),%esi
mov    $0x43,%edi
cmove  %ebx,%edi
call   10a0 <putc_unlocked@plt>
mov    0x0(%rbp),%esi
mov    $0xa,%edi
call   10a0 <putc_unlocked@plt>
jmp    12ac <display_trace+0x10c>
lea    0xc15(%rip),%rbp
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fprintf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"6502NMOS\00"
@.str.1 = [9 x i8] c"6502CMOS\00"
@.str.2 = [18 x i8] c"%d/%m/%Y %H:%M:%S\00"
@.str.3 = [22 x i8] c"6502 trace starts %s\0A\00"
@EOF = global i32 0
@.str.4 = [15 x i8] c"call to OS ROM\00"
@.str.5 = [6 x i8] c"%02d \00"
@stdout = global i32 0
@.str.6 = [22 x i8] c" %02X %02X %02X %02X \00"
@stderr = global i32 0
@.str.7 = [41 x i8] c"disptrace: unexpected end of file on %s\0A\00"
@.str.8 = [37 x i8] c"disptrace: %s not a 6502 trace file\0A\00"
define void @display_trace(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [4 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [20 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %12
store i32 0, i32* %8
store i32 0, i32* %7
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%22 = load i32*, i32** %4
%23 = call i32 @fread(i8* %21, i32 8, i32 1, i32* %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %37
25: ; preds = %2
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%27 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %7
br label %36
30: ; preds = %25
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %8
br label %35
35: ; preds = %34, %30
br label %36
36: ; preds = %35, %29
br label %37
37: ; preds = %36, %2
%38 = load i32, i32* %7
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %8
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %168
43: ; preds = %40, %37
%44 = load i32*, i32** %4
%45 = call i32 @fread(i8* %6, i32 1, i32 1, i32* %44)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %163
47: ; preds = %43
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%49 = call i32 @localtime(i8* %6)
%50 = call i32 @strftime(i8* %48, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %160, %47
%54 = load i32*, i32** %4
%55 = call i32 @getc_unlocked(i32* %54)
store i32 %55, i32* %9
%56 = load i32, i32* @EOF
%57 = icmp ne i32 %55, %56
br i1 %57, label %58, label %162
58: ; preds = %53
%59 = load i32*, i32** %4
%60 = call i32 @getc_unlocked(i32* %59)
store i32 %60, i32* %11
%61 = load i32*, i32** %4
%62 = call i32 @getc_unlocked(i32* %61)
%63 = shl i32 %62, 8
%64 = load i32, i32* %11
%65 = or i32 %64, %63
store i32 %65, i32* %11
%66 = load i32, i32* %11
%67 = add nsw i32 %66, -1
store i32 %67, i32* %11
%68 = load i32*, i32** %4
%69 = call i32 @getc_unlocked(i32* %68)
store i32 %69, i32* %13
%70 = load i32*, i32** %4
%71 = call i32 @getc_unlocked(i32* %70)
store i32 %71, i32* %14
%72 = load i32*, i32** %4
%73 = call i32 @getc_unlocked(i32* %72)
store i32 %73, i32* %15
%74 = load i32*, i32** %4
%75 = call i32 @getc_unlocked(i32* %74)
store i32 %75, i32* %16
%76 = load i32*, i32** %4
%77 = call i32 @getc_unlocked(i32* %76)
store i32 %77, i32* %17
%78 = load i32*, i32** %4
%79 = call i32 @getc_unlocked(i32* %78)
store i32 %79, i32* %18
%80 = load i32*, i32** %4
%81 = call i32 @getc_unlocked(i32* %80)
store i32 %81, i32* %19
%82 = load i32*, i32** %4
%83 = call i32 @getc_unlocked(i32* %82)
store i32 %83, i32* %20
%84 = load i32, i32* %11
%85 = icmp sge i32 %84, 63488
br i1 %85, label %86, label %91
86: ; preds = %58
%87 = load i32, i32* %12
%88 = icmp slt i32 %87, 63488
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %160
91: ; preds = %86, %58
%92 = load i32, i32* %11
%93 = icmp slt i32 %92, 63488
br i1 %93, label %94, label %159
94: ; preds = %91
%95 = load i32, i32* %9
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %95)
%97 = load i32, i32* %8
%98 = load i32, i32* %11
%99 = load i32, i32* %13
%100 = load i32, i32* %14
%101 = load i32, i32* %15
%102 = load i32, i32* @stdout
%103 = call i32 @disassemble(i32 %97, i32 %98, i32 %99, i32 %100, i32 %101, i32 %102)
%104 = load i32, i32* %16
%105 = load i32, i32* %17
%106 = load i32, i32* %18
%107 = load i32, i32* %19
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %104, i32 %105, i32 %106, i32 %107)
%109 = load i32, i32* %20
%110 = and i32 %109, 128
%111 = icmp ne i32 %110, 0
%112 = zext i1 %111 to i64
%113 = select i1 %111, i32 78, i32 46
%114 = trunc i32 %113 to i8
%115 = load i32, i32* @stdout
%116 = call i32 @putc_unlocked(i8 signext %114, i32 %115)
%117 = load i32, i32* %20
%118 = and i32 %117, 64
%119 = icmp ne i32 %118, 0
%120 = zext i1 %119 to i64
%121 = select i1 %119, i32 86, i32 46
%122 = trunc i32 %121 to i8
%123 = load i32, i32* @stdout
%124 = call i32 @putc_unlocked(i8 signext %122, i32 %123)
%125 = load i32, i32* %20
%126 = and i32 %125, 8
%127 = icmp ne i32 %126, 0
%128 = zext i1 %127 to i64
%129 = select i1 %127, i32 68, i32 46
%130 = trunc i32 %129 to i8
%131 = load i32, i32* @stdout
%132 = call i32 @putc_unlocked(i8 signext %130, i32 %131)
%133 = load i32, i32* %20
%134 = and i32 %133, 4
%135 = icmp ne i32 %134, 0
%136 = zext i1 %135 to i64
%137 = select i1 %135, i32 73, i32 46
%138 = trunc i32 %137 to i8
%139 = load i32, i32* @stdout
%140 = call i32 @putc_unlocked(i8 signext %138, i32 %139)
%141 = load i32, i32* %20
%142 = and i32 %141, 2
%143 = icmp ne i32 %142, 0
%144 = zext i1 %143 to i64
%145 = select i1 %143, i32 90, i32 46
%146 = trunc i32 %145 to i8
%147 = load i32, i32* @stdout
%148 = call i32 @putc_unlocked(i8 signext %146, i32 %147)
%149 = load i32, i32* %20
%150 = and i32 %149, 1
%151 = icmp ne i32 %150, 0
%152 = zext i1 %151 to i64
%153 = select i1 %151, i32 67, i32 46
%154 = trunc i32 %153 to i8
%155 = load i32, i32* @stdout
%156 = call i32 @putc_unlocked(i8 signext %154, i32 %155)
%157 = load i32, i32* @stdout
%158 = call i32 @putc_unlocked(i8 signext 10, i32 %157)
br label %159
159: ; preds = %94, %91
br label %160
160: ; preds = %159, %89
%161 = load i32, i32* %11
store i32 %161, i32* %12
br label %53
162: ; preds = %53
br label %167
163: ; preds = %43
%164 = load i32, i32* @stderr
%165 = load i8*, i8** %3
%166 = call i32 @fprintf(i32 %164, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %165)
br label %167
167: ; preds = %163, %162
br label %172
168: ; preds = %40
%169 = load i32, i32* @stderr
%170 = load i8*, i8** %3
%171 = call i32 @fprintf(i32 %169, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %170)
br label %172
172: ; preds = %168, %167
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"6502NMOS\00"
@.str.1 = [9 x i8] c"6502CMOS\00"
@.str.2 = [18 x i8] c"%d/%m/%Y %H:%M:%S\00"
@.str.3 = [22 x i8] c"6502 trace starts %s\0A\00"
@EOF = global i32 0
@.str.4 = [15 x i8] c"call to OS ROM\00"
@.str.5 = [6 x i8] c"%02d \00"
@stdout = global i32 0
@.str.6 = [22 x i8] c" %02X %02X %02X %02X \00"
@stderr = global i32 0
@.str.7 = [41 x i8] c"disptrace: unexpected end of file on %s\0A\00"
@.str.8 = [37 x i8] c"disptrace: %s not a 6502 trace file\0A\00"
define void @display_trace(i8* %0, i32* nocapture %1) {
%3 = alloca [4 x i8]
%4 = alloca i8
%5 = alloca [20 x i8]
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%8 = call i32 @fread(i8* %6, i32 8, i32 1, i32* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %91
10: ; preds = %2
%11 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %91
16: ; preds = %10, %13
%17 = phi i32 [ 1, %13 ], [ 0, %10 ]
%18 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %1)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %91
20: ; preds = %16
%21 = call i32 @localtime(i8* %4)
%22 = call i32 @strftime(i8* %7, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%24 = call i32 @getc_unlocked(i32* %1)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %95, label %27
27: ; preds = %20, %87
%28 = phi i32 [ %88, %87 ], [ %24, %20 ]
%29 = phi i32 [ %34, %87 ], [ 0, %20 ]
%30 = call i32 @getc_unlocked(i32* %1)
%31 = call i32 @getc_unlocked(i32* %1)
%32 = shl i32 %31, 8
%33 = or i32 %32, %30
%34 = add nsw i32 %33, -1
%35 = call i32 @getc_unlocked(i32* %1)
%36 = call i32 @getc_unlocked(i32* %1)
%37 = call i32 @getc_unlocked(i32* %1)
%38 = call i32 @getc_unlocked(i32* %1)
%39 = call i32 @getc_unlocked(i32* %1)
%40 = call i32 @getc_unlocked(i32* %1)
%41 = call i32 @getc_unlocked(i32* %1)
%42 = call i32 @getc_unlocked(i32* %1)
%43 = icmp sgt i32 %33, 63488
%44 = icmp slt i32 %29, 63488
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %46, label %48
46: ; preds = %27
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %87
48: ; preds = %27
%49 = icmp slt i32 %33, 63489
br i1 %49, label %50, label %87
50: ; preds = %48
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%52 = load i32, i32* @stdout
%53 = call i32 @disassemble(i32 %17, i32 %34, i32 %35, i32 %36, i32 %37, i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %38, i32 %39, i32 %40, i32 %41)
%55 = and i32 %42, 128
%56 = icmp eq i32 %55, 0
%57 = select i1 %56, i8 46, i8 78
%58 = load i32, i32* @stdout
%59 = call i32 @putc_unlocked(i8 signext %57, i32 %58)
%60 = and i32 %42, 64
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8 46, i8 86
%63 = load i32, i32* @stdout
%64 = call i32 @putc_unlocked(i8 signext %62, i32 %63)
%65 = and i32 %42, 8
%66 = icmp eq i32 %65, 0
%67 = select i1 %66, i8 46, i8 68
%68 = load i32, i32* @stdout
%69 = call i32 @putc_unlocked(i8 signext %67, i32 %68)
%70 = and i32 %42, 4
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i8 46, i8 73
%73 = load i32, i32* @stdout
%74 = call i32 @putc_unlocked(i8 signext %72, i32 %73)
%75 = and i32 %42, 2
%76 = icmp eq i32 %75, 0
%77 = select i1 %76, i8 46, i8 90
%78 = load i32, i32* @stdout
%79 = call i32 @putc_unlocked(i8 signext %77, i32 %78)
%80 = and i32 %42, 1
%81 = icmp eq i32 %80, 0
%82 = select i1 %81, i8 46, i8 67
%83 = load i32, i32* @stdout
%84 = call i32 @putc_unlocked(i8 signext %82, i32 %83)
%85 = load i32, i32* @stdout
%86 = call i32 @putc_unlocked(i8 signext 10, i32 %85)
br label %87
87: ; preds = %48, %50, %46
%88 = call i32 @getc_unlocked(i32* %1)
%89 = load i32, i32* @EOF
%90 = icmp eq i32 %88, %89
br i1 %90, label %95, label %27
91: ; preds = %13, %2, %16
%92 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), %16 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), %2 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), %13 ]
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* %92, i8* %0)
br label %95
95: ; preds = %87, %91, %20
ret void
}