#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 */
scalar_t__ addEntryName(char *, char *);
scalar_t__ addSectorCount(char *, char *);
int /*<<< orphan*/ interrupt(int, int, char *, int, int /*<<< orphan*/);
void dirCommand(char *args[]) {
  char directory[512];
  char output[512];
  int pos, entry, q, sectorCount;
  interrupt(0x21, 0x2, directory, 2, 0);
  pos = 0;
  for (entry = 0; entry < 16; entry++) {
    if (directory[entry * 32] != 0x00) {
      pos += addEntryName(output + pos, directory + entry * 32);
      output[pos] = ' ';
      pos++;
      output[pos] = ' ';
      pos++;
      pos += addSectorCount(output + pos, directory + entry * 32 + 6);
      output[pos] = '\r';
      pos++;
      output[pos] = '\n';
      pos++;
    }
  }
  output[pos] = '\0';
  interrupt(0x21, 0x0, output, 0, 0);
  return;
}


x86 assembly (clang, -O0):
<dirCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x210(%rbp),%rdx
mov    $0x21,%edi
mov    $0x2,%ecx
xor    %r8d,%r8d
mov    %ecx,%esi
call   1030 <interrupt@plt>
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
cmpl   $0x10,-0x418(%rbp)
jge    12a8 <dirCommand+0x178>
mov    -0x418(%rbp),%eax
shl    $0x5,%eax
cltq
movsbl -0x210(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     128f <dirCommand+0x15f>
lea    -0x410(%rbp),%rdi
movslq -0x414(%rbp),%rax
add    %rax,%rdi
lea    -0x210(%rbp),%rsi
mov    -0x418(%rbp),%eax
shl    $0x5,%eax
cltq
add    %rax,%rsi
call   1040 <addEntryName@plt>
mov    %rax,%rcx
movslq -0x414(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0x20,-0x410(%rbp,%rax,1)
20
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0x20,-0x410(%rbp,%rax,1)
20
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
movslq -0x414(%rbp),%rax
add    %rax,%rdi
lea    -0x210(%rbp),%rsi
mov    -0x418(%rbp),%eax
shl    $0x5,%eax
cltq
add    %rax,%rsi
add    $0x6,%rsi
call   1050 <addSectorCount@plt>
mov    %rax,%rcx
movslq -0x414(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0xd,-0x410(%rbp,%rax,1)
0d
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0xa,-0x410(%rbp,%rax,1)
0a
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1294 <dirCommand+0x164>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    116e <dirCommand+0x3e>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdx
mov    $0x21,%edi
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%ecx
call   1030 <interrupt@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirCommand>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0x200(%rsp),%rbx
xor    %ebp,%ebp
mov    $0x21,%edi
mov    $0x2,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <interrupt@plt>
mov    $0x10,%r14d
jmp    117a <dirCommand+0x4a>
nopw   0x0(%rax,%rax,1)
add    $0x20,%rbx
add    $0xffffffffffffffff,%r14
je     11c0 <dirCommand+0x90>
cmpb   $0x0,(%rbx)
je     1170 <dirCommand+0x40>
movslq %ebp,%rbp
lea    (%rsp,%rbp,1),%rdi
mov    %rbx,%rsi
call   1040 <addEntryName@plt>
add    %eax,%ebp
movslq %ebp,%rbp
movw   $0x2020,(%rsp,%rbp,1)
lea    (%rsp,%rbp,1),%rdi
add    $0x2,%rdi
lea    0x6(%rbx),%rsi
call   1050 <addSectorCount@plt>
lea    (%rax,%rbp,1),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movw   $0xa0d,(%rsp,%rcx,1)
add    %eax,%ebp
add    $0x4,%ebp
jmp    1170 <dirCommand+0x40>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdx
mov    $0x21,%edi
xor    %esi,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <interrupt@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @dirCommand(i8** %0) {
%2 = alloca i8**
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %2
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = call i32 @interrupt(i32 33, i32 2, i8* %9, i32 2, i32 0)
store i32 0, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %73, %1
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %76
14: ; preds = %11
%15 = load i32, i32* %6
%16 = mul nsw i32 %15, 32
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %72
22: ; preds = %14
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 32
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = call i64 @addEntryName(i8* %26, i8* %31)
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %38
store i8 32, i8* %39
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %43
store i8 32, i8* %44
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
%47 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%52 = load i32, i32* %6
%53 = mul nsw i32 %52, 32
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = call i64 @addSectorCount(i8* %50, i8* %56)
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = add nsw i64 %59, %57
%61 = trunc i64 %60 to i32
store i32 %61, i32* %5
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %63
store i8 13, i8* %64
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %68
store i8 10, i8* %69
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %72
72: ; preds = %22, %14
br label %73
73: ; preds = %72
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %11
76: ; preds = %11
%77 = load i32, i32* %5
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %78
store i8 0, i8* %79
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%81 = call i32 @interrupt(i32 33, i32 0, i8* %80, i32 0, i32 0)
ret void
}

LLVM IR (-O2):
define void @dirCommand(i8** nocapture readnone %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = call i32 @interrupt(i32 33, i32 2, i8* %4, i32 2, i32 0)
br label %7
7: ; preds = %1, %38
%8 = phi i64 [ 0, %1 ], [ %40, %38 ]
%9 = phi i32 [ 0, %1 ], [ %39, %38 ]
%10 = shl nuw nsw i64 %8, 5
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %38, label %14
14: ; preds = %7
%15 = sext i32 %9 to i64
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %15
%17 = call i64 @addEntryName(i8* %16, i8* %11)
%18 = trunc i64 %17 to i32
%19 = add i32 %9, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %20
store i8 32, i8* %21
%22 = add nsw i32 %19, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %23
store i8 32, i8* %24
%25 = add nsw i32 %19, 2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %26
%28 = getelementptr inbounds i8, i8* %11, i64 6
%29 = call i64 @addSectorCount(i8* %27, i8* %28)
%30 = trunc i64 %29 to i32
%31 = add i32 %25, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %32
store i8 13, i8* %33
%34 = add nsw i32 %31, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %35
store i8 10, i8* %36
%37 = add nsw i32 %31, 2
br label %38
38: ; preds = %7, %14
%39 = phi i32 [ %37, %14 ], [ %9, %7 ]
%40 = add nuw nsw i64 %8, 1
%41 = icmp eq i64 %40, 16
br i1 %41, label %42, label %7
42: ; preds = %38
%43 = sext i32 %39 to i64
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %43
store i8 0, i8* %44
%45 = call i32 @interrupt(i32 33, i32 0, i8* %5, i32 0, i32 0)
ret void
}