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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(int *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int le16toh(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <disk>\n", argv[0]);
    return 1;
  }
  FILE *image = fopen(argv[1], "r");
  if (image == NULL) {
    perror("fopen");
    return 1;
  }
  if (fseek(image, 0, SEEK_END)) {
    perror("fseek");
    fclose(image);
    return 1;
  }
  if (ftell(image) < 0x1E) {
    fprintf(stderr, "Disk %s is too small to contain a boot sector.\n",
            argv[1]);
    fclose(image);
    return 1;
  }
  if (fseek(image, 0, SEEK_SET)) {
    perror("fseek");
    fclose(image);
    return 1;
  }
  uint8_t boot_sector[30];
  size_t result = fread(boot_sector, 1, 30, image);
  if (result < 30) {
    fprintf(stderr, "Failed to read boot sector for %s ", argv[1]);
    if (feof(image)) {
      fprintf(stderr, "(unexpected EOF)\n");
    } else {
      perror("fread");
    }
    fclose(image);
    return 1;
  }
  printf("| Offset\t| Length\t|\tContents\t\t|\tValue\t|\n");
  printf("---------------------------------------------------------------------"
         "------------\n");
  printf("| 0x00\t\t| 3\t\t| Binary offset of boot loader\t| %2X %2X %2X\t|\n",
         boot_sector[0x0], boot_sector[1], boot_sector[2]);
  printf("| 0x03\t\t| 8\t\t| Volume label\t\t\t| %-8s\t|\n", &boot_sector[0x3]);
  printf("| 0x0B\t\t| 2\t\t| Bytes per Sector\t\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0xB])));
  printf("| 0x0D\t\t| 1\t\t| Sectors per Cluster\t\t| %-8d\t|\n",
         boot_sector[0xD]);
  printf("| 0x0E\t\t| 2\t\t| Reserved Sectors\t\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0xE])));
  printf("| 0x10\t\t| 1\t\t| Number of FATs\t\t| %-8d\t|\n", boot_sector[0x10]);
  printf("| 0x11\t\t| 2\t\t| Number of root dir entries\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x11])));
  printf("| 0x13\t\t| 2\t\t| Number of logical sectors\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x13])));
  printf("| 0x15\t\t| 1\t\t| Medium descriptor\t\t| 0x%02X\t\t|\n",
         boot_sector[0x15]);
  printf("| 0x16\t\t| 2\t\t| Sectors per FAT\t\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x16])));
  printf("| 0x18\t\t| 2\t\t| Sectors per track\t\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x18])));
  printf("| 0x1A\t\t| 2\t\t| Number of heads\t\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x1A])));
  printf("| 0x1C\t\t| 2\t\t| Number of hidden sectors\t| %-8d\t|\n",
         le16toh(*((uint16_t *)&boot_sector[0x1C])));
  fclose(image);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ed <main+0x4d>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1228 <main+0x88>
lea    0xdfd(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
mov    -0x18(%rbp),%rdi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     1267 <main+0xc7>
lea    0xdcd(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
cmp    $0x1e,%eax
jge    12ad <main+0x10d>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
mov    -0x18(%rbp),%rdi
mov    0x2d18(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     12ec <main+0x14c>
lea    0xd48(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1e,%edx
call   1030 <fread@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x1e,-0x98(%rbp)
1e
jae    138a <main+0x1ea>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1369 <main+0x1c9>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1375 <main+0x1d5>
lea    0xd15(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e2 <main+0x342>
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x90(%rbp),%esi
mov    -0x8c(%rbp),%edx
mov    -0x88(%rbp),%ecx
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rsi
add    $0xc,%rsi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x64(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%esi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4c(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%edi
call   10a0 <le16toh@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    1228 <main+0x78>
mov    0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1437 <main+0x287>
mov    %rax,%rbx
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    1410 <main+0x260>
mov    %rbx,%rdi
call   1080 <ftell@plt>
cmp    $0x1d,%eax
jg     1248 <main+0x98>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xe04(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    141c <main+0x26c>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xdc4(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1424 <main+0x274>
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    1410 <main+0x260>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1e,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1d,%rax
ja     12c2 <main+0x112>
mov    0x2d52(%rip),%r14
mov    (%r14),%edi
mov    0x8(%rbp),%rdx
lea    0xdbc(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1445 <main+0x295>
mov    (%r14),%edi
lea    0xdbd(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    141c <main+0x26c>
lea    0x101c(%rip),%rdi
call   1030 <puts@plt>
lea    0x1038(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xd9f(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc(%rsp),%rsi
lea    0xdc7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x34(%rsp),%esi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x38(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xe06(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x40(%rsp),%esi
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x44(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4c(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xe4a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x54(%rsp),%esi
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x58(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x60(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xe92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x68(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xea5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x70(%rsp),%edi
call   10b0 <le16toh@plt>
lea    0xeb6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1429 <main+0x279>
lea    0xc03(%rip),%rdi
call   10d0 <perror@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xbd6(%rip),%rdi
call   10d0 <perror@plt>
jmp    1424 <main+0x274>
lea    0xc39(%rip),%rdi
jmp    1417 <main+0x267>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s <disk>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.3 = [6 x i8] c"fseek\00"
@.str.4 = [48 x i8] c"Disk %s is too small to contain a boot sector.\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [35 x i8] c"Failed to read boot sector for %s \00"
@.str.6 = [18 x i8] c"(unexpected EOF)\0A\00"
@.str.7 = [6 x i8] c"fread\00"
@.str.8 = [41 x i8] c"| Offset\09| Length\09|\09Contents\09\09|\09Value\09|\0A\00"
@.str.9 = [83 x i8] c"---------------------------------------------------------------------------------\0A\00"
@.str.10 = [61 x i8] c"| 0x00\09\09| 3\09\09| Binary offset of boot loader\09| %2X %2X %2X\09|\0A\00"
@.str.11 = [40 x i8] c"| 0x03\09\09| 8\09\09| Volume label\09\09\09| %-8s\09|\0A\00"
@.str.12 = [43 x i8] c"| 0x0B\09\09| 2\09\09| Bytes per Sector\09\09| %-8d\09|\0A\00"
@.str.13 = [46 x i8] c"| 0x0D\09\09| 1\09\09| Sectors per Cluster\09\09| %-8d\09|\0A\00"
@.str.14 = [43 x i8] c"| 0x0E\09\09| 2\09\09| Reserved Sectors\09\09| %-8d\09|\0A\00"
@.str.15 = [41 x i8] c"| 0x10\09\09| 1\09\09| Number of FATs\09\09| %-8d\09|\0A\00"
@.str.16 = [52 x i8] c"| 0x11\09\09| 2\09\09| Number of root dir entries\09| %-8d\09|\0A\00"
@.str.17 = [51 x i8] c"| 0x13\09\09| 2\09\09| Number of logical sectors\09| %-8d\09|\0A\00"
@.str.18 = [47 x i8] c"| 0x15\09\09| 1\09\09| Medium descriptor\09\09| 0x%02X\09\09|\0A\00"
@.str.19 = [42 x i8] c"| 0x16\09\09| 2\09\09| Sectors per FAT\09\09| %-8d\09|\0A\00"
@.str.20 = [44 x i8] c"| 0x18\09\09| 2\09\09| Sectors per track\09\09| %-8d\09|\0A\00"
@.str.21 = [42 x i8] c"| 0x1A\09\09| 2\09\09| Number of heads\09\09| %-8d\09|\0A\00"
@.str.22 = [50 x i8] c"| 0x1C\09\09| 2\09\09| Number of hidden sectors\09| %-8d\09|\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [30 x i32]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %134
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %134
26: ; preds = %17
%27 = load i32*, i32** %6
%28 = load i32, i32* @SEEK_END
%29 = call i64 @fseek(i32* %27, i32 0, i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
store i32 1, i32* %3
br label %134
35: ; preds = %26
%36 = load i32*, i32** %6
%37 = call i32 @ftell(i32* %36)
%38 = icmp slt i32 %37, 30
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
store i32 1, i32* %3
br label %134
47: ; preds = %35
%48 = load i32*, i32** %6
%49 = load i32, i32* @SEEK_SET
%50 = call i64 @fseek(i32* %48, i32 0, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %47
%53 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32*, i32** %6
%55 = call i32 @fclose(i32* %54)
store i32 1, i32* %3
br label %134
56: ; preds = %47
%57 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 0
%58 = load i32*, i32** %6
%59 = call i64 @fread(i32* %57, i32 1, i32 30, i32* %58)
store i64 %59, i64* %8
%60 = load i64, i64* %8
%61 = icmp ult i64 %60, 30
br i1 %61, label %62, label %79
62: ; preds = %56
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %66)
%68 = load i32*, i32** %6
%69 = call i64 @feof(i32* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %62
%72 = load i32, i32* @stderr
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %76
74: ; preds = %62
%75 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %76
76: ; preds = %74, %71
%77 = load i32*, i32** %6
%78 = call i32 @fclose(i32* %77)
store i32 1, i32* %3
br label %134
79: ; preds = %56
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.9, i64 0, i64 0))
%82 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 0
%83 = load i32, i32* %82
%84 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 1
%85 = load i32, i32* %84
%86 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 2
%87 = load i32, i32* %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.10, i64 0, i64 0), i32 %83, i32 %85, i32 %87)
%89 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 3
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i32* %89)
%91 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 11
%92 = load i32, i32* %91
%93 = call i32 @le16toh(i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 %93)
%95 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 13
%96 = load i32, i32* %95
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0), i32 %96)
%98 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 14
%99 = load i32, i32* %98
%100 = call i32 @le16toh(i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i32 %100)
%102 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 16
%103 = load i32, i32* %102
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i32 %103)
%105 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 17
%106 = load i32, i32* %105
%107 = call i32 @le16toh(i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.16, i64 0, i64 0), i32 %107)
%109 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 19
%110 = load i32, i32* %109
%111 = call i32 @le16toh(i32 %110)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.17, i64 0, i64 0), i32 %111)
%113 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 21
%114 = load i32, i32* %113
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.18, i64 0, i64 0), i32 %114)
%116 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 22
%117 = load i32, i32* %116
%118 = call i32 @le16toh(i32 %117)
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.19, i64 0, i64 0), i32 %118)
%120 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 24
%121 = load i32, i32* %120
%122 = call i32 @le16toh(i32 %121)
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i32 %122)
%124 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 26
%125 = load i32, i32* %124
%126 = call i32 @le16toh(i32 %125)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.21, i64 0, i64 0), i32 %126)
%128 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 28
%129 = load i32, i32* %128
%130 = call i32 @le16toh(i32 %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.22, i64 0, i64 0), i32 %130)
%132 = load i32*, i32** %6
%133 = call i32 @fclose(i32* %132)
store i32 0, i32* %3
br label %134
134: ; preds = %79, %76, %52, %39, %31, %24, %11
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s <disk>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.3 = [6 x i8] c"fseek\00"
@.str.4 = [48 x i8] c"Disk %s is too small to contain a boot sector.\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [35 x i8] c"Failed to read boot sector for %s \00"
@.str.6 = [18 x i8] c"(unexpected EOF)\0A\00"
@.str.7 = [6 x i8] c"fread\00"
@.str.10 = [61 x i8] c"| 0x00\09\09| 3\09\09| Binary offset of boot loader\09| %2X %2X %2X\09|\0A\00"
@.str.11 = [40 x i8] c"| 0x03\09\09| 8\09\09| Volume label\09\09\09| %-8s\09|\0A\00"
@.str.12 = [43 x i8] c"| 0x0B\09\09| 2\09\09| Bytes per Sector\09\09| %-8d\09|\0A\00"
@.str.13 = [46 x i8] c"| 0x0D\09\09| 1\09\09| Sectors per Cluster\09\09| %-8d\09|\0A\00"
@.str.14 = [43 x i8] c"| 0x0E\09\09| 2\09\09| Reserved Sectors\09\09| %-8d\09|\0A\00"
@.str.15 = [41 x i8] c"| 0x10\09\09| 1\09\09| Number of FATs\09\09| %-8d\09|\0A\00"
@.str.16 = [52 x i8] c"| 0x11\09\09| 2\09\09| Number of root dir entries\09| %-8d\09|\0A\00"
@.str.17 = [51 x i8] c"| 0x13\09\09| 2\09\09| Number of logical sectors\09| %-8d\09|\0A\00"
@.str.18 = [47 x i8] c"| 0x15\09\09| 1\09\09| Medium descriptor\09\09| 0x%02X\09\09|\0A\00"
@.str.19 = [42 x i8] c"| 0x16\09\09| 2\09\09| Sectors per FAT\09\09| %-8d\09|\0A\00"
@.str.20 = [44 x i8] c"| 0x18\09\09| 2\09\09| Sectors per track\09\09| %-8d\09|\0A\00"
@.str.21 = [42 x i8] c"| 0x1A\09\09| 2\09\09| Number of heads\09\09| %-8d\09|\0A\00"
@.str.22 = [50 x i8] c"| 0x1C\09\09| 2\09\09| Number of hidden sectors\09| %-8d\09|\0A\00"
@str = [40 x i8] c"| Offset\09| Length\09|\09Contents\09\09|\09Value\09|\00"
@str.23 = [82 x i8] c"---------------------------------------------------------------------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [30 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %111
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %111
16: ; preds = %9
%17 = load i32, i32* @SEEK_END
%18 = tail call i64 @fseek(i32* %12, i32 0, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @fclose(i32* %12)
br label %111
23: ; preds = %16
%24 = tail call i32 @ftell(i32* %12)
%25 = icmp slt i32 %24, 30
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %10
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = tail call i32 @fclose(i32* %12)
br label %111
31: ; preds = %23
%32 = load i32, i32* @SEEK_SET
%33 = tail call i64 @fseek(i32* %12, i32 0, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @fclose(i32* %12)
br label %111
38: ; preds = %31
%39 = bitcast [30 x i32]* %3 to i8*
%40 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%41 = call i64 @fread(i32* %40, i32 1, i32 30, i32* %12)
%42 = icmp ult i64 %41, 30
br i1 %42, label %43, label %56
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %10
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %45)
%47 = tail call i64 @feof(i32* %12)
%48 = icmp eq i64 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %54
52: ; preds = %43
%53 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = tail call i32 @fclose(i32* %12)
br label %109
56: ; preds = %38
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.23, i64 0, i64 0))
%59 = load i32, i32* %40
%60 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 1
%61 = load i32, i32* %60
%62 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 2
%63 = load i32, i32* %62
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.10, i64 0, i64 0), i32 %59, i32 %61, i32 %63)
%65 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 3
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i32* %65)
%67 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 11
%68 = load i32, i32* %67
%69 = call i32 @le16toh(i32 %68)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 %69)
%71 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 13
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0), i32 %72)
%74 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 14
%75 = load i32, i32* %74
%76 = call i32 @le16toh(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i32 %76)
%78 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 16
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 17
%82 = load i32, i32* %81
%83 = call i32 @le16toh(i32 %82)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.16, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 19
%86 = load i32, i32* %85
%87 = call i32 @le16toh(i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.17, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 21
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.18, i64 0, i64 0), i32 %90)
%92 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 22
%93 = load i32, i32* %92
%94 = call i32 @le16toh(i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.19, i64 0, i64 0), i32 %94)
%96 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 24
%97 = load i32, i32* %96
%98 = call i32 @le16toh(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 26
%101 = load i32, i32* %100
%102 = call i32 @le16toh(i32 %101)
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.21, i64 0, i64 0), i32 %102)
%104 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 28
%105 = load i32, i32* %104
%106 = call i32 @le16toh(i32 %105)
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.22, i64 0, i64 0), i32 %106)
%108 = call i32 @fclose(i32* %12)
br label %109
109: ; preds = %56, %54
%110 = phi i32 [ 1, %54 ], [ 0, %56 ]
br label %111
111: ; preds = %14, %20, %26, %35, %109, %5
%112 = phi i32 [ 1, %5 ], [ 1, %14 ], [ 1, %20 ], [ 1, %26 ], [ 1, %35 ], [ %110, %109 ]
ret i32 %112
}