#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*/ printString(char *);
int /*<<< orphan*/ readSector(char *, char);
scalar_t__ strncmp(char *, char *, int);
int readFile(char *fileName, char *buffer) {
  char directory[512];
  unsigned int i, j, k;
  char notFound[17];
  readSector(directory, 2);
  for (i = 0; i < 512; i += 32) {
    if (directory[i] == 0) {
      continue;
    } else if (strncmp(fileName, directory + i, 6)) {
      for (j = 6, k = 0; j < 32; j++, k += 512) {
        if (directory[i + j] == 0) {
          return 0;
        } else {
          readSector(buffer + k, directory[i + j]);
        }
      }
      return 0;
    }
  }
  notFound[0] = 'F';
  notFound[1] = 'i';
  notFound[2] = 'l';
  notFound[3] = 'e';
  notFound[4] = ' ';
  notFound[5] = 'n';
  notFound[6] = 'o';
  notFound[7] = 't';
  notFound[8] = ' ';
  notFound[9] = 'F';
  notFound[10] = 'o';
  notFound[11] = 'u';
  notFound[12] = 'n';
  notFound[13] = 'd';
  notFound[14] = '\r';
  notFound[15] = '\n';
  notFound[16] = '\0';
  printString(notFound);
  return -1;
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    $0x2,%esi
call   1050 <readSector@plt>
movl   $0x0,-0x224(%rbp)
cmpl   $0x200,-0x224(%rbp)
jae    127a <readFile+0x14a>
mov    -0x224(%rbp),%eax
movsbl -0x220(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    118a <readFile+0x5a>
jmp    1266 <readFile+0x136>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    -0x224(%rbp),%eax
add    %rax,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     125c <readFile+0x12c>
movl   $0x6,-0x228(%rbp)
movl   $0x0,-0x22c(%rbp)
cmpl   $0x20,-0x228(%rbp)
jae    1250 <readFile+0x120>
mov    -0x224(%rbp),%eax
add    -0x228(%rbp),%eax
mov    %eax,%eax
movsbl -0x220(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    11fe <readFile+0xce>
movl   $0x0,-0x4(%rbp)
jmp    1304 <readFile+0x1d4>
mov    -0x18(%rbp),%rdi
mov    -0x22c(%rbp),%eax
add    %rax,%rdi
mov    -0x224(%rbp),%eax
add    -0x228(%rbp),%eax
mov    %eax,%eax
movsbl -0x220(%rbp,%rax,1),%esi
ff
call   1050 <readSector@plt>
jmp    122b <readFile+0xfb>
mov    -0x228(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x228(%rbp)
mov    -0x22c(%rbp),%eax
add    $0x200,%eax
mov    %eax,-0x22c(%rbp)
jmp    11c6 <readFile+0x96>
movl   $0x0,-0x4(%rbp)
jmp    1304 <readFile+0x1d4>
jmp    1261 <readFile+0x131>
jmp    1266 <readFile+0x136>
mov    -0x224(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x224(%rbp)
jmp    115e <readFile+0x2e>
movb   $0x46,-0x240(%rbp)
movb   $0x69,-0x23f(%rbp)
movb   $0x6c,-0x23e(%rbp)
movb   $0x65,-0x23d(%rbp)
movb   $0x20,-0x23c(%rbp)
movb   $0x6e,-0x23b(%rbp)
movb   $0x6f,-0x23a(%rbp)
movb   $0x74,-0x239(%rbp)
movb   $0x20,-0x238(%rbp)
movb   $0x46,-0x237(%rbp)
movb   $0x6f,-0x236(%rbp)
movb   $0x75,-0x235(%rbp)
movb   $0x6e,-0x234(%rbp)
movb   $0x64,-0x233(%rbp)
movb   $0xd,-0x232(%rbp)
movb   $0xa,-0x231(%rbp)
movb   $0x0,-0x230(%rbp)
lea    -0x240(%rbp),%rdi
call   1040 <printString@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x2,%esi
call   1050 <readSector@plt>
mov    $0xffffffffffffffe0,%rbx
jmp    1171 <readFile+0x41>
nop
add    $0x20,%r12
add    $0x20,%rbx
cmp    $0x1e0,%rbx
jae    11cb <readFile+0x9b>
cmpb   $0x0,(%r12)
je     1160 <readFile+0x30>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1160 <readFile+0x30>
add    $0x6,%r12
xor    %r15d,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r12),%eax
test   %al,%al
je     11e9 <readFile+0xb9>
lea    (%r14,%rbx,1),%rdi
movsbl %al,%esi
call   1050 <readSector@plt>
add    $0x200,%rbx
add    $0x1,%r12
cmp    $0x3400,%rbx
jne    11a0 <readFile+0x70>
jmp    11e9 <readFile+0xb9>
movaps 0xe2e(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1040 <printString@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @readFile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [17 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = call i32 @readSector(i8* %11, i8 signext 2)
store i32 0, i32* %7
br label %13
13: ; preds = %67, %2
%14 = load i32, i32* %7
%15 = icmp ult i32 %14, 512
br i1 %15, label %16, label %70
16: ; preds = %13
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %67
24: ; preds = %16
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%27 = load i32, i32* %7
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i64 @strncmp(i8* %25, i8* %29, i32 6)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %65
32: ; preds = %24
store i32 6, i32* %8
store i32 0, i32* %9
br label %33
33: ; preds = %59, %32
%34 = load i32, i32* %8
%35 = icmp ult i32 %34, 32
br i1 %35, label %36, label %64
36: ; preds = %33
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = add i32 %37, %38
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %36
store i32 0, i32* %3
br label %90
46: ; preds = %36
%47 = load i8*, i8** %5
%48 = load i32, i32* %9
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = add i32 %51, %52
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = call i32 @readSector(i8* %50, i8 signext %56)
br label %58
58: ; preds = %46
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add i32 %60, 1
store i32 %61, i32* %8
%62 = load i32, i32* %9
%63 = add i32 %62, 512
store i32 %63, i32* %9
br label %33
64: ; preds = %33
store i32 0, i32* %3
br label %90
65: ; preds = %24
br label %66
66: ; preds = %65
br label %67
67: ; preds = %66, %23
%68 = load i32, i32* %7
%69 = add i32 %68, 32
store i32 %69, i32* %7
br label %13
70: ; preds = %13
%71 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
store i8 70, i8* %71
%72 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 1
store i8 105, i8* %72
%73 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 2
store i8 108, i8* %73
%74 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 3
store i8 101, i8* %74
%75 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 4
store i8 32, i8* %75
%76 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 5
store i8 110, i8* %76
%77 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 6
store i8 111, i8* %77
%78 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 7
store i8 116, i8* %78
%79 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 8
store i8 32, i8* %79
%80 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 9
store i8 70, i8* %80
%81 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 10
store i8 111, i8* %81
%82 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 11
store i8 117, i8* %82
%83 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 12
store i8 110, i8* %83
%84 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 13
store i8 100, i8* %84
%85 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 14
store i8 13, i8* %85
%86 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 15
store i8 10, i8* %86
%87 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 16
store i8 0, i8* %87
%88 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%89 = call i32 @printString(i8* %88)
store i32 -1, i32* %3
br label %90
90: ; preds = %70, %64, %45
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
define i32 @readFile(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%7 = call i32 @readSector(i8* %5, i8 signext 2)
br label %8
8: ; preds = %2, %31
%9 = phi i64 [ 0, %2 ], [ %32, %31 ]
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = call i64 @strncmp(i8* %0, i8* %10, i32 6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %13
%17 = and i64 %9, 4294967264
br label %18
18: ; preds = %16, %25
%19 = phi i64 [ 6, %16 ], [ %28, %25 ]
%20 = phi i64 [ 0, %16 ], [ %29, %25 ]
%21 = add nuw nsw i64 %19, %17
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %38, label %25
25: ; preds = %18
%26 = getelementptr inbounds i8, i8* %1, i64 %20
%27 = call i32 @readSector(i8* %26, i8 signext %23)
%28 = add nuw nsw i64 %19, 1
%29 = add nuw nsw i64 %20, 512
%30 = icmp eq i64 %28, 32
br i1 %30, label %38, label %18
31: ; preds = %13, %8
%32 = add nuw nsw i64 %9, 32
%33 = icmp ult i64 %9, 480
br i1 %33, label %8, label %34
34: ; preds = %31
%35 = bitcast [17 x i8]* %4 to <16 x i8>*
store <16 x i8> <i8 70, i8 105, i8 108, i8 101, i8 32, i8 110, i8 111, i8 116, i8 32, i8 70, i8 111, i8 117, i8 110, i8 100, i8 13, i8 10>, <16 x i8>* %35
%36 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 16
store i8 0, i8* %36
%37 = call i32 @printString(i8* %6)
br label %38
38: ; preds = %25, %18, %34
%39 = phi i32 [ -1, %34 ], [ 0, %18 ], [ 0, %25 ]
ret i32 %39
}