#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*/ free(char *);
char *getNextDirectory(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strlen(char *);
void listRootFolder(int fileDescriptor) {
  char *next = getNextDirectory(fileDescriptor);
  while (next != NULL) {
    if (strlen(next) > 0) {
      printf("%s\n", next);
      free(next);
    }
    next = getNextDirectory(fileDescriptor);
  }
}


x86 assembly (clang, -O0):
<listRootFolder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <getNextDirectory@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119f <listRootFolder+0x5f>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    118e <listRootFolder+0x4e>
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%edi
call   1050 <getNextDirectory@plt>
mov    %rax,-0x10(%rbp)
jmp    1157 <listRootFolder+0x17>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<listRootFolder>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
call   1050 <getNextDirectory@plt>
test   %rax,%rax
je     1191 <listRootFolder+0x51>
mov    %rax,%rbx
lea    0xea6(%rip),%r14
jmp    116f <listRootFolder+0x2f>
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <getNextDirectory@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1191 <listRootFolder+0x51>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    1160 <listRootFolder+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1160 <listRootFolder+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @listRootFolder(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i8* @getNextDirectory(i32 %4)
store i8* %5, i8** %3
br label %6
6: ; preds = %18, %1
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
br label %18
18: ; preds = %13, %9
%19 = load i32, i32* %2
%20 = call i8* @getNextDirectory(i32 %19)
store i8* %20, i8** %3
br label %6
21: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @listRootFolder(i32 %0) {
%2 = tail call i8* @getNextDirectory(i32 %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %14, label %4
4: ; preds = %1, %11
%5 = phi i8* [ %12, %11 ], [ %2, %1 ]
%6 = tail call i64 @strlen(i8* %5)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = tail call i32 @free(i8* %5)
br label %11
11: ; preds = %8, %4
%12 = tail call i8* @getNextDirectory(i32 %0)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %4
14: ; preds = %11, %1
ret void
}