#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_SET;
int atol(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
unsigned long strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  unsigned long i = 0;
  unsigned int j;
  unsigned char data[17];
  FILE *in;
  size_t length;
  int pg = 0;
  char addr[10];
  int jet4 = 0;
  int pg_size = 2048;
  if (argc < 1) {
    fprintf(stderr, "Usage: mdb-dump <filename> [<page number>]\n\n");
    exit(1);
  }
  if (argc > 2) {
    if (!strncmp(argv[2], "0x", 2)) {
      for (i = 2; i < strlen(argv[2]); i++) {
        pg *= 16;
        printf("char %c\n", (int)argv[2][i]);
        pg += argv[2][i] > '9' ? argv[2][i] - 'a' + 10 : argv[2][i] - '0';
      }
    } else {
      pg = atol(argv[2]);
    }
  }
  printf("page num %d\n", pg);
  if ((in = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Couldn't open file %s\n", argv[1]);
    exit(1);
  }
  fseek(in, 0x14, SEEK_SET);
  fread(data, 1, 1, in);
  if (data[0] == 0x01) {
    jet4 = 1;
    pg_size = 4096;
  }
  fseek(in, (pg * pg_size), SEEK_SET);
  i = 0;
  while ((length = fread(data, 1, 16, in))) {
    sprintf(addr, "%06lx", i);
    if (!strcmp(&addr[3], "000") || (!jet4 && !strcmp(&addr[3], "800"))) {
      fprintf(stdout, "-- Page 0x%04x (%d) --\n", pg, pg);
      pg++;
    }
    fprintf(stdout, "%s  ", addr);
    i += length;
    for (j = 0; j < length; j++) {
      fprintf(stdout, "%02x ", data[j]);
    }
    fprintf(stdout, "  |");
    for (j = 0; j < length; j++) {
      fprintf(stdout, "%c", (isprint(data[j])) ? data[j] : '.');
    }
    fprintf(stdout, "|\n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x800,-0x58(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    121e <main+0x5e>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    131d <main+0x15d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf6(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1308 <main+0x148>
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
jae    1303 <main+0x143>
mov    -0x44(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd99(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    12d3 <main+0x113>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x64(%rbp)
jmp    12e9 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1252 <main+0x92>
jmp    1318 <main+0x158>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atol@plt>
mov    %eax,-0x44(%rbp)
jmp    131d <main+0x15d>
mov    -0x44(%rbp),%esi
lea    0xd12(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd0b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1377 <main+0x1b7>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xce2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    0x2c56(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1090 <fseek@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
movzbl -0x30(%rbp),%eax
cmp    $0x1,%eax
jne    13bd <main+0x1fd>
movl   $0x1,-0x54(%rbp)
movl   $0x1000,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%esi
imul   -0x58(%rbp),%esi
mov    0x2c09(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
movq   $0x0,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     1592 <main+0x3d2>
lea    -0x4e(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xc4d(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x4e(%rbp),%rdi
add    $0x3,%rdi
lea    0xc3f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     145b <main+0x29b>
cmpl   $0x0,-0x54(%rbp)
jne    1481 <main+0x2c1>
lea    -0x4e(%rbp),%rdi
add    $0x3,%rdi
lea    0xc1c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1481 <main+0x2c1>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
mov    -0x44(%rbp),%ecx
lea    0xbfc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    0x2b48(%rip),%rax
mov    (%rax),%edi
lea    -0x4e(%rbp),%rdx
lea    0xbf0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x40(%rbp),%rax
jae    14e9 <main+0x329>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%eax
movzbl -0x30(%rbp,%rax,1),%edx
lea    0xbb6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14af <main+0x2ef>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
lea    0xb97(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x40(%rbp),%rax
jae    1576 <main+0x3b6>
mov    0x2ab5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x1c(%rbp),%eax
movzbl -0x30(%rbp,%rax,1),%edi
call   10a0 <isprint@plt>
cmp    $0x0,%rax
je     1547 <main+0x387>
mov    -0x1c(%rbp),%eax
movzbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0x6c(%rbp)
jmp    1554 <main+0x394>
mov    $0x2e,%eax
mov    %eax,-0x6c(%rbp)
jmp    1554 <main+0x394>
mov    -0x68(%rbp),%edi
mov    -0x6c(%rbp),%edx
lea    0xb33(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1507 <main+0x347>
mov    0x2a53(%rip),%rax
mov    (%rax),%edi
lea    0xb11(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13de <main+0x21e>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %edi,%edi
jg     11e3 <main+0x33>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %rsi,%r14
cmp    $0x3,%edi
jb     126a <main+0xba>
mov    0x10(%r14),%rdi
lea    0xe37(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    0x10(%r14),%r12
test   %eax,%eax
jne    126e <main+0xbe>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0x3,%rax
mov    $0x0,%ebp
jb     1278 <main+0xc8>
mov    $0x2,%ebx
xor    %ebp,%ebp
lea    0xe07(%rip),%r15
nopl   0x0(%rax)
shl    $0x4,%ebp
movsbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
call   1060 <printf@plt>
mov    0x10(%r14),%r12
movsbl (%r12,%rbx,1),%eax
cmp    $0x3a,%eax
lea    -0x57(%rbp,%rax,1),%ecx
lea    -0x30(%rbp,%rax,1),%ebp
cmovge %ecx,%ebp
add    $0x1,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbx
jb     1230 <main+0x80>
jmp    1278 <main+0xc8>
xor    %ebp,%ebp
jmp    1278 <main+0xc8>
mov    %r12,%rdi
call   10a0 <atol@plt>
mov    %eax,%ebp
lea    0xdba(%rip),%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
mov    0x8(%r14),%rdi
lea    0xdb5(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
jne    12c0 <main+0x110>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xd99(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %rax,%rbx
mov    0x2d0e(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x14,%esi
call   1080 <fseek@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    0x20(%rsp),%al
xor    %esi,%esi
mov    %al,0xd(%rsp)
cmp    $0x1,%al
sete   %sil
shl    $0xb,%esi
add    $0x800,%esi
mov    %rbp,0x18(%rsp)
imul   %ebp,%esi
mov    (%r14),%edx
mov    %rbx,%rdi
call   1080 <fseek@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     149d <main+0x2ed>
mov    %rax,%r13
lea    0xe(%rsp),%r12
mov    0x2c83(%rip),%r14
lea    0xd36(%rip),%rbp
lea    0xd39(%rip),%r15
mov    %rbx,0x38(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
lea    0xce5(%rip),%rsi
mov    %rbx,%rdx
call   10c0 <sprintf@plt>
cmpl   $0x303030,0x11(%rsp)
mov    %rbx,0x40(%rsp)
je     13a2 <main+0x1f2>
cmpb   $0x1,0xd(%rsp)
je     13c4 <main+0x214>
cmpl   $0x303038,0x11(%rsp)
jne    13c4 <main+0x214>
mov    (%r14),%edi
lea    0xcc1(%rip),%rsi
mov    0x18(%rsp),%rbx
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebx
mov    %rbx,0x18(%rsp)
mov    (%r14),%edi
lea    0xcb7(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
movzbl 0x20(%rsp,%rbx,1),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebx
cmp    %rbx,%r13
ja     13e0 <main+0x230>
mov    (%r14),%edi
lea    0xc8c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13,%rbp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%r12d
movzbl 0x20(%rsp,%r13,1),%ebx
mov    %ebx,%edi
call   1090 <isprint@plt>
test   %rax,%rax
mov    $0x2e,%eax
cmove  %eax,%ebx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r13d
cmp    %r13,%rbp
ja     1420 <main+0x270>
mov    0x40(%rsp),%rbx
add    %rbp,%rbx
mov    (%r14),%edi
lea    0xc32(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    0x38(%rsp),%rcx
call   1040 <fread@plt>
mov    %rax,%r13
test   %rax,%rax
lea    0xe(%rsp),%r12
lea    0xbf3(%rip),%rbp
jne    1370 <main+0x1c0>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"Usage: mdb-dump <filename> [<page number>]\0A\0A\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [9 x i8] c"char %c\0A\00"
@.str.3 = [13 x i8] c"page num %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [23 x i8] c"Couldn't open file %s\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [6 x i8] c"%06lx\00"
@.str.7 = [4 x i8] c"000\00"
@.str.8 = [4 x i8] c"800\00"
@stdout = global i32 0
@.str.9 = [24 x i8] c"-- Page 0x%04x (%d) --\0A\00"
@.str.10 = [5 x i8] c"%s \00"
@.str.11 = [6 x i8] c"%02x \00"
@.str.12 = [4 x i8] c" |\00"
@.str.13 = [3 x i8] c"%c\00"
@.str.14 = [3 x i8] c"|\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca [17 x i8]
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32
%12 = alloca [10 x i8]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i32 0, i32* %11
store i32 0, i32* %13
store i32 2048, i32* %14
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 2
br i1 %23, label %24, label %90
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @strncmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%29 = icmp ne i32 %28, 0
br i1 %29, label %84, label %30
30: ; preds = %24
store i64 2, i64* %6
br label %31
31: ; preds = %80, %30
%32 = load i64, i64* %6
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i64 @strlen(i8* %35)
%37 = icmp ult i64 %32, %36
br i1 %37, label %38, label %83
38: ; preds = %31
%39 = load i32, i32* %11
%40 = mul nsw i32 %39, 16
store i32 %40, i32* %11
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = load i64, i64* %6
%45 = getelementptr inbounds i8, i8* %43, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = load i64, i64* %6
%53 = getelementptr inbounds i8, i8* %51, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp sgt i32 %55, 57
br i1 %56, label %57, label %67
57: ; preds = %38
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = load i64, i64* %6
%62 = getelementptr inbounds i8, i8* %60, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = sub nsw i32 %64, 97
%66 = add nsw i32 %65, 10
br label %76
67: ; preds = %38
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = load i64, i64* %6
%72 = getelementptr inbounds i8, i8* %70, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = sub nsw i32 %74, 48
br label %76
76: ; preds = %67, %57
%77 = phi i32 [ %66, %57 ], [ %75, %67 ]
%78 = load i32, i32* %11
%79 = add nsw i32 %78, %77
store i32 %79, i32* %11
br label %80
80: ; preds = %76
%81 = load i64, i64* %6
%82 = add i64 %81, 1
store i64 %82, i64* %6
br label %31
83: ; preds = %31
br label %89
84: ; preds = %24
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 2
%87 = load i8*, i8** %86
%88 = call i32 @atol(i8* %87)
store i32 %88, i32* %11
br label %89
89: ; preds = %84, %83
br label %90
90: ; preds = %89, %21
%91 = load i32, i32* %11
%92 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i32* @fopen(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %96, i32** %9
%97 = icmp eq i32* %96, null
br i1 %97, label %98, label %105
98: ; preds = %90
%99 = load i32, i32* @stderr
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %102)
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %90
%106 = load i32*, i32** %9
%107 = load i32, i32* @SEEK_SET
%108 = call i32 @fseek(i32* %106, i32 20, i32 %107)
%109 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%110 = load i32*, i32** %9
%111 = call i64 @fread(i8* %109, i32 1, i32 1, i32* %110)
%112 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = icmp eq i32 %114, 1
br i1 %115, label %116, label %117
116: ; preds = %105
store i32 1, i32* %13
store i32 4096, i32* %14
br label %117
117: ; preds = %116, %105
%118 = load i32*, i32** %9
%119 = load i32, i32* %11
%120 = load i32, i32* %14
%121 = mul nsw i32 %119, %120
%122 = load i32, i32* @SEEK_SET
%123 = call i32 @fseek(i32* %118, i32 %121, i32 %122)
store i64 0, i64* %6
br label %124
124: ; preds = %202, %117
%125 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%126 = load i32*, i32** %9
%127 = call i64 @fread(i8* %125, i32 1, i32 16, i32* %126)
store i64 %127, i64* %10
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %205
129: ; preds = %124
%130 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%131 = load i64, i64* %6
%132 = call i32 @sprintf(i8* %130, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %131)
%133 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 3
%134 = call i32 @strcmp(i8* %133, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %143
136: ; preds = %129
%137 = load i32, i32* %13
%138 = icmp ne i32 %137, 0
br i1 %138, label %150, label %139
139: ; preds = %136
%140 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 3
%141 = call i32 @strcmp(i8* %140, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%142 = icmp ne i32 %141, 0
br i1 %142, label %150, label %143
143: ; preds = %139, %129
%144 = load i32, i32* @stdout
%145 = load i32, i32* %11
%146 = load i32, i32* %11
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %145, i32 %146)
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %11
br label %150
150: ; preds = %143, %139, %136
%151 = load i32, i32* @stdout
%152 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* %152)
%154 = load i64, i64* %10
%155 = load i64, i64* %6
%156 = add i64 %155, %154
store i64 %156, i64* %6
store i32 0, i32* %7
br label %157
157: ; preds = %170, %150
%158 = load i32, i32* %7
%159 = zext i32 %158 to i64
%160 = load i64, i64* %10
%161 = icmp ult i64 %159, %160
br i1 %161, label %162, label %173
162: ; preds = %157
%163 = load i32, i32* @stdout
%164 = load i32, i32* %7
%165 = zext i32 %164 to i64
%166 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %165
%167 = load i8, i8* %166
%168 = zext i8 %167 to i32
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %168)
br label %170
170: ; preds = %162
%171 = load i32, i32* %7
%172 = add i32 %171, 1
store i32 %172, i32* %7
br label %157
173: ; preds = %157
%174 = load i32, i32* @stdout
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %7
br label %176
176: ; preds = %199, %173
%177 = load i32, i32* %7
%178 = zext i32 %177 to i64
%179 = load i64, i64* %10
%180 = icmp ult i64 %178, %179
br i1 %180, label %181, label %202
181: ; preds = %176
%182 = load i32, i32* @stdout
%183 = load i32, i32* %7
%184 = zext i32 %183 to i64
%185 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %184
%186 = load i8, i8* %185
%187 = call i64 @isprint(i8 zeroext %186)
%188 = icmp ne i64 %187, 0
br i1 %188, label %189, label %195
189: ; preds = %181
%190 = load i32, i32* %7
%191 = zext i32 %190 to i64
%192 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %191
%193 = load i8, i8* %192
%194 = zext i8 %193 to i32
br label %196
195: ; preds = %181
br label %196
196: ; preds = %195, %189
%197 = phi i32 [ %194, %189 ], [ 46, %195 ]
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %182, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32 %197)
br label %199
199: ; preds = %196
%200 = load i32, i32* %7
%201 = add i32 %200, 1
store i32 %201, i32* %7
br label %176
202: ; preds = %176
%203 = load i32, i32* @stdout
%204 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %124
205: ; preds = %124
%206 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"Usage: mdb-dump <filename> [<page number>]\0A\0A\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [9 x i8] c"char %c\0A\00"
@.str.3 = [13 x i8] c"page num %d\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [23 x i8] c"Couldn't open file %s\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [6 x i8] c"%06lx\00"
@.str.7 = [4 x i8] c"000\00"
@.str.8 = [4 x i8] c"800\00"
@stdout = global i32 0
@.str.9 = [24 x i8] c"-- Page 0x%04x (%d) --\0A\00"
@.str.10 = [5 x i8] c"%s \00"
@.str.11 = [6 x i8] c"%02x \00"
@.str.12 = [4 x i8] c" |\00"
@.str.13 = [3 x i8] c"%c\00"
@.str.14 = [3 x i8] c"|\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [17 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = icmp ugt i32 %0, 2
br i1 %13, label %14, label %45
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%18 = icmp eq i32 %17, 0
%19 = load i8*, i8** %15
br i1 %18, label %20, label %43
20: ; preds = %14
%21 = tail call i64 @strlen(i8* dereferenceable(1) %19)
%22 = icmp ugt i64 %21, 2
br i1 %22, label %23, label %45
23: ; preds = %20, %23
%24 = phi i8* [ %32, %23 ], [ %19, %20 ]
%25 = phi i32 [ %39, %23 ], [ 0, %20 ]
%26 = phi i64 [ %40, %23 ], [ 2, %20 ]
%27 = shl nsw i32 %25, 4
%28 = getelementptr inbounds i8, i8* %24, i64 %26
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %15
%33 = getelementptr inbounds i8, i8* %32, i64 %26
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sgt i8 %34, 57
%37 = select i1 %36, i32 -87, i32 -48
%38 = add i32 %27, %35
%39 = add i32 %38, %37
%40 = add nuw i64 %26, 1
%41 = tail call i64 @strlen(i8* dereferenceable(1) %32)
%42 = icmp ult i64 %40, %41
br i1 %42, label %23, label %45
43: ; preds = %14
%44 = tail call i32 @atol(i8* %19)
br label %45
45: ; preds = %23, %20, %43, %12
%46 = phi i32 [ %44, %43 ], [ 0, %12 ], [ 0, %20 ], [ %39, %23 ]
%47 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = tail call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %57
52: ; preds = %45
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %48
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = tail call i32 @exit(i32 1)
unreachable
57: ; preds = %45
%58 = load i32, i32* @SEEK_SET
%59 = tail call i32 @fseek(i32* %50, i32 20, i32 %58)
%60 = call i64 @fread(i8* %5, i32 1, i32 1, i32* %50)
%61 = load i8, i8* %5
%62 = icmp eq i8 %61, 1
%63 = select i1 %62, i32 4096, i32 2048
%64 = mul nsw i32 %63, %46
%65 = load i32, i32* @SEEK_SET
%66 = tail call i32 @fseek(i32* %50, i32 %64, i32 %65)
%67 = call i64 @fread(i8* %5, i32 1, i32 16, i32* %50)
%68 = icmp eq i64 %67, 0
br i1 %68, label %122, label %69
69: ; preds = %57
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 3
br label %71
71: ; preds = %69, %116
%72 = phi i64 [ %67, %69 ], [ %120, %116 ]
%73 = phi i32 [ %46, %69 ], [ %87, %116 ]
%74 = phi i64 [ 0, %69 ], [ %117, %116 ]
%75 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %74)
%76 = call i32 @bcmp(i8* dereferenceable(4) %70, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 4)
%77 = icmp eq i32 %76, 0
br i1 %77, label %82, label %78
78: ; preds = %71
br i1 %62, label %86, label %79
79: ; preds = %78
%80 = call i32 @bcmp(i8* dereferenceable(4) %70, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i64 4)
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %79, %71
%83 = load i32, i32* @stdout
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %73, i32 %73)
%85 = add nsw i32 %73, 1
br label %86
86: ; preds = %82, %79, %78
%87 = phi i32 [ %73, %78 ], [ %73, %79 ], [ %85, %82 ]
%88 = load i32, i32* @stdout
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* %6)
br label %90
90: ; preds = %86, %90
%91 = phi i64 [ 0, %86 ], [ %98, %90 ]
%92 = load i32, i32* @stdout
%93 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %91
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %95)
%97 = add nuw nsw i64 %91, 1
%98 = and i64 %97, 4294967295
%99 = icmp ugt i64 %72, %98
br i1 %99, label %90, label %100
100: ; preds = %90
%101 = load i32, i32* @stdout
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
br label %103
103: ; preds = %100, %103
%104 = phi i64 [ 0, %100 ], [ %114, %103 ]
%105 = load i32, i32* @stdout
%106 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %104
%107 = load i8, i8* %106
%108 = call i64 @isprint(i8 zeroext %107)
%109 = icmp eq i64 %108, 0
%110 = zext i8 %107 to i32
%111 = select i1 %109, i32 46, i32 %110
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32 %111)
%113 = add nuw nsw i64 %104, 1
%114 = and i64 %113, 4294967295
%115 = icmp ugt i64 %72, %114
br i1 %115, label %103, label %116
116: ; preds = %103
%117 = add i64 %72, %74
%118 = load i32, i32* @stdout
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%120 = call i64 @fread(i8* %5, i32 1, i32 16, i32* %50)
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %71
122: ; preds = %116, %57
%123 = call i32 @exit(i32 0)
unreachable
}