#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 EOF;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp = NULL;
  FILE *output = NULL;
  unsigned char oracle = 0;
  unsigned char sum = 0;
  int c, c1;
  unsigned int n;
  unsigned char num_page = 0;
  if (argc < 2) {
    print_usage(argv[0]);
    return 1;
  }
  fp = fopen(argv[1], "r");
  if (!fp) {
    fprintf(stderr, "unable to open file %s for reading\n", argv[1]);
    return 1;
  }
  printf("input file: %s\n", argv[1]);
  if (argc > 2) {
    output = fopen(argv[2], "w");
    if (!output) {
      fprintf(stderr, "ERROR unable to open file %s for writing\n", argv[2]);
      fclose(fp);
      return 2;
    }
    printf("output file: %s\n", argv[2]);
  }
  while (1) {
    sum = 0;
    oracle = 0;
    c1 = 0;
    c = fgetc(fp);
    if (c == EOF) {
      if (output)
        fclose(output);
      fclose(fp);
      printf("dump analysis compete\n");
      return 0;
    }
    if ('A' <= c && c <= 'F')
      oracle |= c - 'A' + 10;
    else
      oracle |= c - '0';
    oracle = oracle << 4;
    c = fgetc(fp);
    if ('A' <= c && c <= 'F')
      oracle |= c - 'A' + 10;
    else
      oracle |= c - '0';
    for (n = 0; n < (32 * 1024); n++) {
      c = fgetc(fp);
      assert(c != EOF);
      if (c == 0x10) {
        if (c1 == 0x10)
          c1 = 0x00;
        else
          c1 = 0x10;
      } else if (c == 0x03) {
        if (c1 == 0x10) {
          if (output)
            c1 = fputc(c1, output);
          assert(c1 != EOF);
          c1 = 0x00;
        }
      }
      if (c1 == 0x00) {
        sum ^= c;
        if (output)
          c = fputc(c, output);
        assert(c != EOF);
      }
    }
    if (oracle != sum) {
      fprintf(stderr,
              "WARNING page %d: checksum expected is 0x%02X, but checksum "
              "calculated is 0x%02X\n",
              num_page, oracle, sum);
    }
    num_page++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movb   $0x0,-0x22(%rbp)
movb   $0x0,-0x31(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d4 <main+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1504 <main+0x384>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1222 <main+0xa2>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1504 <main+0x384>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jle    12af <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde5(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1299 <main+0x119>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1504 <main+0x384>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b4 <main+0x134>
movb   $0x0,-0x22(%rbp)
movb   $0x0,-0x21(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2d0f(%rip),%rcx
cmp    (%rcx),%eax
jne    1318 <main+0x198>
cmpq   $0x0,-0x20(%rbp)
je     12f5 <main+0x175>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1504 <main+0x384>
mov    $0x41,%eax
cmp    -0x28(%rbp),%eax
jg     1347 <main+0x1c7>
cmpl   $0x46,-0x28(%rbp)
jg     1347 <main+0x1c7>
mov    -0x28(%rbp),%ecx
sub    $0x41,%ecx
add    $0xa,%ecx
movzbl -0x21(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x21(%rbp)
jmp    1356 <main+0x1d6>
mov    -0x28(%rbp),%ecx
sub    $0x30,%ecx
movzbl -0x21(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
shl    $0x4,%eax
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    $0x41,%eax
cmp    -0x28(%rbp),%eax
jg     139b <main+0x21b>
cmpl   $0x46,-0x28(%rbp)
jg     139b <main+0x21b>
mov    -0x28(%rbp),%ecx
sub    $0x41,%ecx
add    $0xa,%ecx
movzbl -0x21(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x21(%rbp)
jmp    13aa <main+0x22a>
mov    -0x28(%rbp),%ecx
sub    $0x30,%ecx
movzbl -0x21(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x21(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x8000,-0x30(%rbp)
jae    14c3 <main+0x343>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2c14(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x10,-0x28(%rbp)
jne    140f <main+0x28f>
cmpl   $0x10,-0x2c(%rbp)
jne    1403 <main+0x283>
movl   $0x0,-0x2c(%rbp)
jmp    140a <main+0x28a>
movl   $0x10,-0x2c(%rbp)
jmp    1467 <main+0x2e7>
cmpl   $0x3,-0x28(%rbp)
jne    1462 <main+0x2e2>
cmpl   $0x10,-0x2c(%rbp)
jne    145d <main+0x2dd>
cmpq   $0x0,-0x20(%rbp)
je     143d <main+0x2bd>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <fputc@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2ba1(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x0,-0x2c(%rbp)
jmp    1462 <main+0x2e2>
jmp    1467 <main+0x2e7>
cmpl   $0x0,-0x2c(%rbp)
jne    14b0 <main+0x330>
mov    -0x28(%rbp),%ecx
movzbl -0x22(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x22(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1497 <main+0x317>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <fputc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2b47(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
jmp    14b5 <main+0x335>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13b1 <main+0x231>
movzbl -0x21(%rbp),%eax
movzbl -0x22(%rbp),%ecx
cmp    %ecx,%eax
je     14f7 <main+0x377>
mov    0x2afe(%rip),%rax
mov    (%rax),%edi
movzbl -0x31(%rbp),%edx
movzbl -0x21(%rbp),%ecx
movzbl -0x22(%rbp),%r8d
lea    0xb9a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x31(%rbp),%al
add    $0x1,%al
mov    %al,-0x31(%rbp)
jmp    12b4 <main+0x134>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
cmp    $0x1,%edi
jg     11b8 <main+0x28>
mov    (%r15),%rdi
call   10b0 <print_usage@plt>
mov    $0x1,%eax
jmp    127e <main+0xee>
mov    %edi,%ebp
mov    0x8(%r15),%rdi
lea    0xe3b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1220 <main+0x90>
mov    0x8(%r15),%rsi
lea    0xe48(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x3,%ebp
jb     1242 <main+0xb2>
mov    0x10(%r15),%rdi
lea    0xe3f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
mov    (%rsp),%rbp
je     13f2 <main+0x262>
mov    %rax,%rbx
mov    0x10(%r15),%rsi
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1246 <main+0xb6>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xdce(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    127e <main+0xee>
mov    (%rsp),%rbp
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    0x2d93(%rip),%r12
cmp    (%r12),%eax
jne    128d <main+0xfd>
test   %rbx,%rbx
je     1268 <main+0xd8>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
jmp    12b2 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14b
mov    %rbp,%rdi
call   1060 <fgetc@plt>
cmp    (%r12),%eax
je     125b <main+0xcb>
mov    %r14d,0x14(%rsp)
lea    -0x41(%rax),%ecx
xor    %edx,%edx
cmp    $0x6,%ecx
setb   %dl
lea    (%rdx,%rdx,8),%ecx
add    %eax,%ecx
mov    %ecx,0x10(%rsp)
mov    %rbp,%rdi
call   1060 <fgetc@plt>
lea    -0x41(%rax),%ecx
cmp    $0x6,%ecx
mov    $0xd0,%edx
mov    $0xc9,%ecx
cmovb  %ecx,%edx
add    %al,%dl
mov    %edx,0xc(%rsp)
mov    $0x8000,%r15d
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    1314 <main+0x184>
nopw   0x0(%rax,%rax,1)
mov    $0x10,%r14d
mov    (%rsp),%rbp
add    $0xffffffff,%r15d
je     13b0 <main+0x220>
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    (%r12),%eax
setne  %dil
call   1080 <assert@plt>
cmp    $0x10,%ebp
jne    1340 <main+0x1b0>
cmp    $0x10,%r14d
jne    1300 <main+0x170>
jmp    137b <main+0x1eb>
nopw   0x0(%rax,%rax,1)
cmp    $0x3,%ebp
jne    1360 <main+0x1d0>
cmp    $0x10,%r14d
jne    1360 <main+0x1d0>
test   %rbx,%rbx
je     1367 <main+0x1d7>
mov    $0x10,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
jmp    136c <main+0x1dc>
nop
test   %r14d,%r14d
jne    1306 <main+0x176>
jmp    137b <main+0x1eb>
mov    $0x10,%eax
xor    %edi,%edi
cmp    (%r12),%eax
setne  %dil
call   1080 <assert@plt>
mov    %ebp,%eax
test   %rbx,%rbx
je     138c <main+0x1fc>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
xor    %bpl,%r13b
xor    %edi,%edi
cmp    (%r12),%eax
setne  %dil
call   1080 <assert@plt>
xor    %r14d,%r14d
jmp    1306 <main+0x176>
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
shl    $0x4,%al
mov    0xc(%rsp),%ecx
or     %al,%cl
cmp    %r13b,%cl
mov    0x14(%rsp),%r14d
je     12a0 <main+0x110>
movzbl %r13b,%r8d
movzbl %cl,%ecx
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
movzbl %r14b,%edx
lea    0xc8d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12a0 <main+0x110>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r15),%rdx
lea    0xc32(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    $0x2,%eax
jmp    127e <main+0xee>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"unable to open file %s for reading\0A\00"
@.str.2 = [16 x i8] c"input file: %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [42 x i8] c"ERROR unable to open file %s for writing\0A\00"
@.str.5 = [17 x i8] c"output file: %s\0A\00"
@EOF = global i32 0
@.str.6 = [23 x i8] c"dump analysis compete\0A\00"
@.str.7 = [81 x i8] c"WARNING page %d: checksum expected is 0x%02X, but checksum calculated is 0x%02X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i8 0, i8* %8
store i8 0, i8* %9
store i8 0, i8* %13
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @print_usage(i8* %19)
store i32 1, i32* %3
br label %210
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp ne i32* %26, null
br i1 %27, label %34, label %28
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 1, i32* %3
br label %210
34: ; preds = %21
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 2
br i1 %40, label %41, label %61
41: ; preds = %34
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %7
%46 = load i32*, i32** %7
%47 = icmp ne i32* %46, null
br i1 %47, label %56, label %48
48: ; preds = %41
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%54 = load i32*, i32** %6
%55 = call i32 @fclose(i32* %54)
store i32 2, i32* %3
br label %210
56: ; preds = %41
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %56, %34
br label %62
62: ; preds = %61, %207
store i8 0, i8* %9
store i8 0, i8* %8
store i32 0, i32* %11
%63 = load i32*, i32** %6
%64 = call i32 @fgetc(i32* %63)
store i32 %64, i32* %10
%65 = load i32, i32* %10
%66 = load i32, i32* @EOF
%67 = icmp eq i32 %65, %66
br i1 %67, label %68, label %78
68: ; preds = %62
%69 = load i32*, i32** %7
%70 = icmp ne i32* %69, null
br i1 %70, label %71, label %74
71: ; preds = %68
%72 = load i32*, i32** %7
%73 = call i32 @fclose(i32* %72)
br label %74
74: ; preds = %71, %68
%75 = load i32*, i32** %6
%76 = call i32 @fclose(i32* %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %210
78: ; preds = %62
%79 = load i32, i32* %10
%80 = icmp sle i32 65, %79
br i1 %80, label %81, label %92
81: ; preds = %78
%82 = load i32, i32* %10
%83 = icmp sle i32 %82, 70
br i1 %83, label %84, label %92
84: ; preds = %81
%85 = load i32, i32* %10
%86 = sub nsw i32 %85, 65
%87 = add nsw i32 %86, 10
%88 = load i8, i8* %8
%89 = zext i8 %88 to i32
%90 = or i32 %89, %87
%91 = trunc i32 %90 to i8
store i8 %91, i8* %8
br label %99
92: ; preds = %81, %78
%93 = load i32, i32* %10
%94 = sub nsw i32 %93, 48
%95 = load i8, i8* %8
%96 = zext i8 %95 to i32
%97 = or i32 %96, %94
%98 = trunc i32 %97 to i8
store i8 %98, i8* %8
br label %99
99: ; preds = %92, %84
%100 = load i8, i8* %8
%101 = zext i8 %100 to i32
%102 = shl i32 %101, 4
%103 = trunc i32 %102 to i8
store i8 %103, i8* %8
%104 = load i32*, i32** %6
%105 = call i32 @fgetc(i32* %104)
store i32 %105, i32* %10
%106 = load i32, i32* %10
%107 = icmp sle i32 65, %106
br i1 %107, label %108, label %119
108: ; preds = %99
%109 = load i32, i32* %10
%110 = icmp sle i32 %109, 70
br i1 %110, label %111, label %119
111: ; preds = %108
%112 = load i32, i32* %10
%113 = sub nsw i32 %112, 65
%114 = add nsw i32 %113, 10
%115 = load i8, i8* %8
%116 = zext i8 %115 to i32
%117 = or i32 %116, %114
%118 = trunc i32 %117 to i8
store i8 %118, i8* %8
br label %126
119: ; preds = %108, %99
%120 = load i32, i32* %10
%121 = sub nsw i32 %120, 48
%122 = load i8, i8* %8
%123 = zext i8 %122 to i32
%124 = or i32 %123, %121
%125 = trunc i32 %124 to i8
store i8 %125, i8* %8
br label %126
126: ; preds = %119, %111
store i32 0, i32* %12
br label %127
127: ; preds = %189, %126
%128 = load i32, i32* %12
%129 = icmp ult i32 %128, 32768
br i1 %129, label %130, label %192
130: ; preds = %127
%131 = load i32*, i32** %6
%132 = call i32 @fgetc(i32* %131)
store i32 %132, i32* %10
%133 = load i32, i32* %10
%134 = load i32, i32* @EOF
%135 = icmp ne i32 %133, %134
%136 = zext i1 %135 to i32
%137 = call i32 @assert(i32 %136)
%138 = load i32, i32* %10
%139 = icmp eq i32 %138, 16
br i1 %139, label %140, label %146
140: ; preds = %130
%141 = load i32, i32* %11
%142 = icmp eq i32 %141, 16
br i1 %142, label %143, label %144
143: ; preds = %140
store i32 0, i32* %11
br label %145
144: ; preds = %140
store i32 16, i32* %11
br label %145
145: ; preds = %144, %143
br label %167
146: ; preds = %130
%147 = load i32, i32* %10
%148 = icmp eq i32 %147, 3
br i1 %148, label %149, label %166
149: ; preds = %146
%150 = load i32, i32* %11
%151 = icmp eq i32 %150, 16
br i1 %151, label %152, label %165
152: ; preds = %149
%153 = load i32*, i32** %7
%154 = icmp ne i32* %153, null
br i1 %154, label %155, label %159
155: ; preds = %152
%156 = load i32, i32* %11
%157 = load i32*, i32** %7
%158 = call i32 @fputc(i32 %156, i32* %157)
store i32 %158, i32* %11
br label %159
159: ; preds = %155, %152
%160 = load i32, i32* %11
%161 = load i32, i32* @EOF
%162 = icmp ne i32 %160, %161
%163 = zext i1 %162 to i32
%164 = call i32 @assert(i32 %163)
store i32 0, i32* %11
br label %165
165: ; preds = %159, %149
br label %166
166: ; preds = %165, %146
br label %167
167: ; preds = %166, %145
%168 = load i32, i32* %11
%169 = icmp eq i32 %168, 0
br i1 %169, label %170, label %188
170: ; preds = %167
%171 = load i32, i32* %10
%172 = load i8, i8* %9
%173 = zext i8 %172 to i32
%174 = xor i32 %173, %171
%175 = trunc i32 %174 to i8
store i8 %175, i8* %9
%176 = load i32*, i32** %7
%177 = icmp ne i32* %176, null
br i1 %177, label %178, label %182
178: ; preds = %170
%179 = load i32, i32* %10
%180 = load i32*, i32** %7
%181 = call i32 @fputc(i32 %179, i32* %180)
store i32 %181, i32* %10
br label %182
182: ; preds = %178, %170
%183 = load i32, i32* %10
%184 = load i32, i32* @EOF
%185 = icmp ne i32 %183, %184
%186 = zext i1 %185 to i32
%187 = call i32 @assert(i32 %186)
br label %188
188: ; preds = %182, %167
br label %189
189: ; preds = %188
%190 = load i32, i32* %12
%191 = add i32 %190, 1
store i32 %191, i32* %12
br label %127
192: ; preds = %127
%193 = load i8, i8* %8
%194 = zext i8 %193 to i32
%195 = load i8, i8* %9
%196 = zext i8 %195 to i32
%197 = icmp ne i32 %194, %196
br i1 %197, label %198, label %207
198: ; preds = %192
%199 = load i32, i32* @stderr
%200 = load i8, i8* %13
%201 = zext i8 %200 to i32
%202 = load i8, i8* %8
%203 = zext i8 %202 to i32
%204 = load i8, i8* %9
%205 = zext i8 %204 to i32
%206 = call i32 (i32, i8*, ...) @fprintf(i32 %199, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.7, i64 0, i64 0), i32 %201, i32 %203, i32 %205)
br label %207
207: ; preds = %198, %192
%208 = load i8, i8* %13
%209 = add i8 %208, 1
store i8 %209, i8* %13
br label %62
210: ; preds = %74, %48, %28, %16
%211 = load i32, i32* %3
ret i32 %211
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"unable to open file %s for reading\0A\00"
@.str.2 = [16 x i8] c"input file: %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [42 x i8] c"ERROR unable to open file %s for writing\0A\00"
@.str.5 = [17 x i8] c"output file: %s\0A\00"
@EOF = global i32 0
@.str.7 = [81 x i8] c"WARNING page %d: checksum expected is 0x%02X, but checksum calculated is 0x%02X\0A\00"
@str = [22 x i8] c"dump analysis compete\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @print_usage(i8* %5)
br label %119
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %119
16: ; preds = %7
%17 = load i8*, i8** %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = icmp ugt i32 %0, 2
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %21
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = tail call i32 @fclose(i32* %10)
br label %119
30: ; preds = %20
%31 = load i8*, i8** %21
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %16
%34 = phi i32* [ %23, %30 ], [ null, %16 ]
%35 = tail call i32 @fgetc(i32* %10)
%36 = load i32, i32* @EOF
%37 = icmp eq i32 %35, %36
br i1 %37, label %40, label %38
38: ; preds = %33
%39 = icmp eq i32* %34, null
br label %47
40: ; preds = %114, %33
%41 = icmp eq i32* %34, null
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i32 @fclose(i32* %34)
br label %44
44: ; preds = %42, %40
%45 = tail call i32 @fclose(i32* %10)
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %119
47: ; preds = %38, %114
%48 = phi i32 [ %35, %38 ], [ %116, %114 ]
%49 = phi i8 [ 0, %38 ], [ %115, %114 ]
%50 = add i32 %48, -65
%51 = icmp ult i32 %50, 6
%52 = select i1 %51, i32 9, i32 0
%53 = add i32 %52, %48
%54 = trunc i32 %53 to i8
%55 = tail call i32 @fgetc(i32* %10)
%56 = add i32 %55, -65
%57 = icmp ult i32 %56, 6
%58 = trunc i32 %55 to i8
%59 = select i1 %57, i8 -55, i8 -48
%60 = add i8 %59, %58
br label %61
61: ; preds = %47, %99
%62 = phi i32 [ 0, %47 ], [ %102, %99 ]
%63 = phi i32 [ 0, %47 ], [ %100, %99 ]
%64 = phi i8 [ 0, %47 ], [ %101, %99 ]
%65 = tail call i32 @fgetc(i32* %10)
%66 = load i32, i32* @EOF
%67 = icmp ne i32 %65, %66
%68 = zext i1 %67 to i32
%69 = tail call i32 @assert(i32 %68)
%70 = icmp eq i32 %65, 16
br i1 %70, label %71, label %73
71: ; preds = %61
%72 = icmp eq i32 %63, 16
br i1 %72, label %88, label %99
73: ; preds = %61
%74 = icmp eq i32 %65, 3
%75 = icmp eq i32 %63, 16
%76 = select i1 %74, i1 %75, i1 false
br i1 %76, label %77, label %86
77: ; preds = %73
br i1 %39, label %80, label %78
78: ; preds = %77
%79 = tail call i32 @fputc(i32 16, i32* %34)
br label %80
80: ; preds = %78, %77
%81 = phi i32 [ %79, %78 ], [ 16, %77 ]
%82 = load i32, i32* @EOF
%83 = icmp ne i32 %81, %82
%84 = zext i1 %83 to i32
%85 = tail call i32 @assert(i32 %84)
br label %88
86: ; preds = %73
%87 = icmp eq i32 %63, 0
br i1 %87, label %88, label %99
88: ; preds = %71, %80, %86
%89 = trunc i32 %65 to i8
%90 = xor i8 %64, %89
br i1 %39, label %93, label %91
91: ; preds = %88
%92 = tail call i32 @fputc(i32 %65, i32* %34)
br label %93
93: ; preds = %91, %88
%94 = phi i32 [ %92, %91 ], [ %65, %88 ]
%95 = load i32, i32* @EOF
%96 = icmp ne i32 %94, %95
%97 = zext i1 %96 to i32
%98 = tail call i32 @assert(i32 %97)
br label %99
99: ; preds = %71, %86, %93
%100 = phi i32 [ 0, %93 ], [ %63, %86 ], [ 16, %71 ]
%101 = phi i8 [ %90, %93 ], [ %64, %86 ], [ %64, %71 ]
%102 = add nuw nsw i32 %62, 1
%103 = icmp eq i32 %102, 32768
br i1 %103, label %104, label %61
104: ; preds = %99
%105 = shl i8 %54, 4
%106 = or i8 %60, %105
%107 = icmp eq i8 %106, %101
br i1 %107, label %114, label %108
108: ; preds = %104
%109 = zext i8 %101 to i32
%110 = zext i8 %106 to i32
%111 = load i32, i32* @stderr
%112 = zext i8 %49 to i32
%113 = tail call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.7, i64 0, i64 0), i32 %112, i32 %110, i32 %109)
br label %114
114: ; preds = %108, %104
%115 = add i8 %49, 1
%116 = tail call i32 @fgetc(i32* %10)
%117 = load i32, i32* @EOF
%118 = icmp eq i32 %116, %117
br i1 %118, label %40, label %47
119: ; preds = %44, %25, %12, %4
%120 = phi i32 [ 1, %4 ], [ 0, %44 ], [ 2, %25 ], [ 1, %12 ]
ret i32 %120
}