#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int clusterSize(int, int);
int hiddenSectors(char, char);
int numberOfDirs(char, char);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ read(int, char *, int);
int reservedSectors(char, char);
int sectorSize(char, char);
int sectorsPerCluster(char);
int sectorsPerFAT(char, char);
int main(int argsc, char *argv[]) {
  int fh;
  char buffer[256];
  int gotten;
  fh = open(argv[1], O_RDONLY);
  if (read(fh, buffer, 256 * sizeof(char))) {
    int ss = sectorSize(buffer[11], buffer[12]);
    int spc = sectorsPerCluster(buffer[13]);
    int cs = clusterSize(ss, spc);
    int dirs = numberOfDirs(buffer[17], buffer[18]);
    int spfat = sectorsPerFAT(buffer[22], buffer[23]);
    int rs = reservedSectors(buffer[14], buffer[15]);
    int hs = hiddenSectors(buffer[28], buffer[29]);
    printf("Sector Size: %i\n", ss);
    printf("Sectors per cluster: %i\n", spc);
    printf("Cluster Size: %i\n", cs);
    printf("Number of Dirs in root: %i\n", dirs);
    printf("Sectors Per FAT: %i\n", spfat);
    printf("Reserved Sectors: %i\n", rs);
    printf("Hidden Sectors: %i\n", hs);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1070 <read@plt>
cmp    $0x0,%rax
je     131e <main+0x17e>
mov    -0x115(%rbp),%al
movsbl %al,%edi
movsbl -0x114(%rbp),%esi
call   1040 <sectorSize@plt>
mov    %eax,-0x128(%rbp)
movsbl -0x113(%rbp),%edi
call   1090 <sectorsPerCluster@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x128(%rbp),%edi
mov    -0x12c(%rbp),%esi
call   1080 <clusterSize@plt>
mov    %eax,-0x130(%rbp)
mov    -0x10f(%rbp),%al
movsbl %al,%edi
movsbl -0x10e(%rbp),%esi
call   1030 <numberOfDirs@plt>
mov    %eax,-0x134(%rbp)
mov    -0x10a(%rbp),%al
movsbl %al,%edi
movsbl -0x109(%rbp),%esi
call   1050 <sectorsPerFAT@plt>
mov    %eax,-0x138(%rbp)
mov    -0x112(%rbp),%al
movsbl %al,%edi
movsbl -0x111(%rbp),%esi
call   10c0 <reservedSectors@plt>
mov    %eax,-0x13c(%rbp)
mov    -0x104(%rbp),%al
movsbl %al,%edi
movsbl -0x103(%rbp),%esi
call   10a0 <hiddenSectors@plt>
mov    %eax,-0x140(%rbp)
mov    -0x128(%rbp),%esi
lea    0xd53(%rip),%rdi
call   1060 <printf@plt>
mov    -0x12c(%rbp),%esi
lea    0xd52(%rip),%rdi
call   1060 <printf@plt>
mov    -0x130(%rbp),%esi
lea    0xd59(%rip),%rdi
call   1060 <printf@plt>
mov    -0x134(%rbp),%esi
lea    0xd59(%rip),%rdi
call   1060 <printf@plt>
mov    -0x138(%rbp),%esi
lea    0xd63(%rip),%rdi
call   1060 <printf@plt>
mov    -0x13c(%rbp),%esi
lea    0xd66(%rip),%rdi
call   1060 <printf@plt>
mov    -0x140(%rbp),%esi
lea    0xd6a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    0x8(%rsi),%rdi
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x100,%edx
call   1070 <read@plt>
test   %rax,%rax
je     12b7 <main+0x117>
movsbl 0x1b(%rsp),%edi
movsbl 0x1c(%rsp),%esi
call   1040 <sectorSize@plt>
mov    %eax,%ebx
movsbl 0x1d(%rsp),%edi
call   1090 <sectorsPerCluster@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1080 <clusterSize@plt>
mov    %eax,0xc(%rsp)
movsbl 0x21(%rsp),%edi
movsbl 0x22(%rsp),%esi
call   1030 <numberOfDirs@plt>
mov    %eax,%r15d
movsbl 0x26(%rsp),%edi
movsbl 0x27(%rsp),%esi
call   1050 <sectorsPerFAT@plt>
mov    %eax,%r12d
movsbl 0x1e(%rsp),%edi
movsbl 0x1f(%rsp),%esi
call   10c0 <reservedSectors@plt>
mov    %eax,%r13d
movsbl 0x2c(%rsp),%edi
movsbl 0x2d(%rsp),%esi
call   10a0 <hiddenSectors@plt>
mov    %eax,%r14d
lea    0xdaa(%rip),%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
lea    0xdad(%rip),%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
lea    0xdb8(%rip),%rdi
mov    0xc(%rsp),%esi
call   1060 <printf@plt>
lea    0xdba(%rip),%rdi
mov    %r15d,%esi
call   1060 <printf@plt>
lea    0xdc7(%rip),%rdi
mov    %r12d,%esi
call   1060 <printf@plt>
lea    0xdcd(%rip),%rdi
mov    %r13d,%esi
call   1060 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    %r14d,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [17 x i8] c"Sector Size: %i\0A\00"
@.str.1 = [25 x i8] c"Sectors per cluster: %i\0A\00"
@.str.2 = [18 x i8] c"Cluster Size: %i\0A\00"
@.str.3 = [28 x i8] c"Number of Dirs in root: %i\0A\00"
@.str.4 = [21 x i8] c"Sectors Per FAT: %i\0A\00"
@.str.5 = [22 x i8] c"Reserved Sectors: %i\0A\00"
@.str.6 = [20 x i8] c"Hidden Sectors: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @O_RDONLY
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = call i64 @read(i32 %21, i8* %22, i32 256)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %71
25: ; preds = %2
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 11
%27 = load i8, i8* %26
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 12
%29 = load i8, i8* %28
%30 = call i32 @sectorSize(i8 signext %27, i8 signext %29)
store i32 %30, i32* %9
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 13
%32 = load i8, i8* %31
%33 = call i32 @sectorsPerCluster(i8 signext %32)
store i32 %33, i32* %10
%34 = load i32, i32* %9
%35 = load i32, i32* %10
%36 = call i32 @clusterSize(i32 %34, i32 %35)
store i32 %36, i32* %11
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 17
%38 = load i8, i8* %37
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 18
%40 = load i8, i8* %39
%41 = call i32 @numberOfDirs(i8 signext %38, i8 signext %40)
store i32 %41, i32* %12
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 22
%43 = load i8, i8* %42
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 23
%45 = load i8, i8* %44
%46 = call i32 @sectorsPerFAT(i8 signext %43, i8 signext %45)
store i32 %46, i32* %13
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 14
%48 = load i8, i8* %47
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 15
%50 = load i8, i8* %49
%51 = call i32 @reservedSectors(i8 signext %48, i8 signext %50)
store i32 %51, i32* %14
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 28
%53 = load i8, i8* %52
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 29
%55 = load i8, i8* %54
%56 = call i32 @hiddenSectors(i8 signext %53, i8 signext %55)
store i32 %56, i32* %15
%57 = load i32, i32* %9
%58 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %10
%60 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %11
%62 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %12
%64 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %13
%66 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %14
%68 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %15
%70 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %25, %2
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [17 x i8] c"Sector Size: %i\0A\00"
@.str.1 = [25 x i8] c"Sectors per cluster: %i\0A\00"
@.str.2 = [18 x i8] c"Cluster Size: %i\0A\00"
@.str.3 = [28 x i8] c"Number of Dirs in root: %i\0A\00"
@.str.4 = [21 x i8] c"Sectors Per FAT: %i\0A\00"
@.str.5 = [22 x i8] c"Reserved Sectors: %i\0A\00"
@.str.6 = [20 x i8] c"Hidden Sectors: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = call i64 @read(i32 %8, i8* %4, i32 256)
%10 = icmp eq i64 %9, 0
br i1 %10, label %48, label %11
11: ; preds = %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 11
%13 = load i8, i8* %12
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 12
%15 = load i8, i8* %14
%16 = tail call i32 @sectorSize(i8 signext %13, i8 signext %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 13
%18 = load i8, i8* %17
%19 = tail call i32 @sectorsPerCluster(i8 signext %18)
%20 = tail call i32 @clusterSize(i32 %16, i32 %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 17
%22 = load i8, i8* %21
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 18
%24 = load i8, i8* %23
%25 = tail call i32 @numberOfDirs(i8 signext %22, i8 signext %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 22
%27 = load i8, i8* %26
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 23
%29 = load i8, i8* %28
%30 = tail call i32 @sectorsPerFAT(i8 signext %27, i8 signext %29)
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 14
%32 = load i8, i8* %31
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 15
%34 = load i8, i8* %33
%35 = tail call i32 @reservedSectors(i8 signext %32, i8 signext %34)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 28
%37 = load i8, i8* %36
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 29
%39 = load i8, i8* %38
%40 = tail call i32 @hiddenSectors(i8 signext %37, i8 signext %39)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %16)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%43 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%45 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%47 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %40)
br label %48
48: ; preds = %11, %2
ret i32 0
}