#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 */
char *parseAttributes(char *, int, unsigned char *);
char *parseDate(char *, int, unsigned char *);
char *parseTime(char *, int, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
char *size(char *, unsigned char *, int);
char *toDOSName(char *, unsigned char *, int);
void parseDirectory(int iDirOff, int iEntries, unsigned char buffer[]) {
  int i = 0;
  char string[13];
  printf("Filename\tAttrib\tTime\t\tDate\t\tSize\n");
  for (i = 0; i < (iEntries); i = i + 32) {
    if ((buffer[i] != 0x00) && (buffer[i] != 0xe5)) {
      printf("%s\t", toDOSName(string, buffer, i));
      printf("%s\t", parseAttributes(string, (i + 0x0b), buffer));
      printf("%s\t", parseTime(string, (i + 0x16), buffer));
      printf("%s\t", parseDate(string, (i + 0x18), buffer));
      printf("%s\n", size(string, buffer, (i + 0x1c)));
    }
  }
  printf("(R)ead Only (H)idden (S)ystem (A)rchive\n");
}


x86 assembly (clang, -O0):
<parseDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128a <parseDirectory+0x12a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1277 <parseDirectory+0x117>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xe5,%eax
je     1277 <parseDirectory+0x117>
lea    -0x21(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <toDOSName@plt>
mov    %rax,%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0xb,%esi
mov    -0x10(%rbp),%rdx
call   1080 <parseAttributes@plt>
mov    %rax,%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x16,%esi
mov    -0x10(%rbp),%rdx
call   1060 <parseTime@plt>
mov    %rax,%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x18,%esi
mov    -0x10(%rbp),%rdx
call   1070 <parseDate@plt>
mov    %rax,%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1c,%edx
call   1030 <size@plt>
mov    %rax,%rsi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127c <parseDirectory+0x11c>
mov    -0x14(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <parseDirectory+0x2e>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDirectory>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %esi,%r12d
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
test   %r12d,%r12d
jle    124f <parseDirectory+0xdf>
lea    0x3(%rsp),%r14
lea    0xe5d(%rip),%r15
xor    %ebp,%ebp
jmp    11bd <parseDirectory+0x4d>
nopw   0x0(%rax,%rax,1)
add    $0x20,%rbp
cmp    %r12d,%ebp
jge    124f <parseDirectory+0xdf>
movzbl (%rbx,%rbp,1),%eax
cmp    $0xe5,%al
je     11b0 <parseDirectory+0x40>
test   %al,%al
je     11b0 <parseDirectory+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <toDOSName@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xb(%rbp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1090 <parseAttributes@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x16(%rbp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <parseTime@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rbp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1080 <parseDate@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1c(%rbp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <size@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
jmp    11b0 <parseDirectory+0x40>
lea    0xdcf(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Filename\09Attrib\09Time\09\09Date\09\09Size\0A\00"
@.str.1 = [4 x i8] c"%s\09\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [41 x i8] c"(R)ead Only (H)idden (S)ystem (A)rchive\0A\00"
define void @parseDirectory(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [13 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %10
10: ; preds = %61, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %64
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %60
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %28, 229
br i1 %29, label %30, label %60
30: ; preds = %22
%31 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = call i8* @toDOSName(i8* %31, i8* %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 11
%39 = load i8*, i8** %6
%40 = call i8* @parseAttributes(i8* %36, i32 %38, i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 22
%45 = load i8*, i8** %6
%46 = call i8* @parseTime(i8* %42, i32 %44, i8* %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 24
%51 = load i8*, i8** %6
%52 = call i8* @parseDate(i8* %48, i32 %50, i8* %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%55 = load i8*, i8** %6
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 28
%58 = call i8* @size(i8* %54, i8* %55, i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %30, %22, %14
br label %61
61: ; preds = %60
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 32
store i32 %63, i32* %7
br label %10
64: ; preds = %10
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%s\09\00"
@str = [33 x i8] c"Filename\09Attrib\09Time\09\09Date\09\09Size\00"
@str.4 = [40 x i8] c"(R)ead Only (H)idden (S)ystem (A)rchive\00"
define void @parseDirectory(i32 %0, i32 %1, i8* %2) {
%4 = alloca [13 x i8]
%5 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %36
8: ; preds = %3, %32
%9 = phi i64 [ %33, %32 ], [ 0, %3 ]
%10 = getelementptr inbounds i8, i8* %2, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %12 [
i8 0, label %32
i8 -27, label %32
]
12: ; preds = %8
%13 = trunc i64 %9 to i32
%14 = call i8* @toDOSName(i8* %5, i8* %2, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = trunc i64 %9 to i32
%17 = or i32 %16, 11
%18 = call i8* @parseAttributes(i8* %5, i32 %17, i8* %2)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = trunc i64 %9 to i32
%21 = or i32 %20, 22
%22 = call i8* @parseTime(i8* %5, i32 %21, i8* %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = trunc i64 %9 to i32
%25 = or i32 %24, 24
%26 = call i8* @parseDate(i8* %5, i32 %25, i8* %2)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = trunc i64 %9 to i32
%29 = or i32 %28, 28
%30 = call i8* @size(i8* %5, i8* %2, i32 %29)
%31 = call i32 @puts(i8* dereferenceable(1) %30)
br label %32
32: ; preds = %8, %8, %12
%33 = add nuw i64 %9, 32
%34 = trunc i64 %33 to i32
%35 = icmp slt i32 %34, %1
br i1 %35, label %8, label %36
36: ; preds = %32, %3
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.4, i64 0, i64 0))
ret void
}