#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
void *malloc(int);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strdup(char *);
int strlen(char const *);
void get_file_list(const char *dir_name, char ***file_names_ptr,
                   int *num_files_ptr, char ***directories_ptr,
                   int *num_directories_ptr) {
  DIR *dir = opendir(dir_name);
  if (dir == NULL) {
    fprintf(stderr, "ERROR: Could not open current directory\n");
    exit(EXIT_FAILURE);
  }
  int num_files = 0;
  int num_directories = 0;
  struct dirent *de;
  struct stat statbuf;
  while ((de = readdir(dir)) != NULL) {
    char *file_name = de->d_name;
    char *file_path = malloc(strlen(dir_name) + 1 + strlen(file_name) + 1);
    strcpy(file_path, dir_name);
    strcat(file_path, "/");
    strcat(file_path, file_name);
    if (stat(file_path, &statbuf) == -1) {
      fprintf(stderr, "ERROR: Could not stat %s\n", file_name);
      exit(EXIT_FAILURE);
    }
    if (!S_ISDIR(statbuf.st_mode) && file_name[0] != '_' &&
        file_name[0] != '.') {
      num_files++;
    } else if (S_ISDIR(statbuf.st_mode) && file_name[0] != '_' &&
               file_name[0] != '.') {
      num_directories++;
    }
    free(file_path);
  }
  *num_files_ptr = num_files;
  *num_directories_ptr = num_directories;
  rewinddir(dir);
  char **file_names = malloc(sizeof(char *) * num_files);
  char **directory_names = malloc(sizeof(char *) * num_directories);
  int index = 0;
  int dir_index = 0;
  while ((de = readdir(dir)) != NULL) {
    char *file_name = de->d_name;
    char *file_path = malloc(strlen(dir_name) + 1 + strlen(file_name) + 1);
    strcpy(file_path, dir_name);
    strcat(file_path, "/");
    strcat(file_path, file_name);
    if (stat(file_path, &statbuf) == -1) {
      fprintf(stderr, "ERROR: Could not stat %s\n", file_name);
      exit(EXIT_FAILURE);
    }
    if (!S_ISDIR(statbuf.st_mode) && file_name[0] != '_' &&
        file_name[0] != '.') {
      file_names[index] = strdup(file_path);
      index++;
    } else if (S_ISDIR(statbuf.st_mode) && file_name[0] != '_' &&
               file_name[0] != '.') {
      directory_names[dir_index] = strdup(file_name);
      dir_index++;
    }
    free(file_path);
  }
  closedir(dir);
  *file_names_ptr = file_names;
  *directories_ptr = directory_names;
}


x86 assembly (clang, -O0):
<get_file_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    123c <get_file_list+0x5c>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     1392 <get_file_list+0x1b2>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x84(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x58(%rbp),%rdi
lea    0xd76(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1304 <get_file_list+0x124>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x48(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    1344 <get_file_list+0x164>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1344 <get_file_list+0x164>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1344 <get_file_list+0x164>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1384 <get_file_list+0x1a4>
mov    -0x48(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     137f <get_file_list+0x19f>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     137f <get_file_list+0x19f>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     137f <get_file_list+0x19f>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1384 <get_file_list+0x1a4>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
jmp    124a <get_file_list+0x6a>
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1080 <rewinddir@plt>
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x60(%rbp)
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x30(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     1559 <get_file_list+0x379>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x88(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x80(%rbp),%rdi
lea    0xbdf(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x80(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    149b <get_file_list+0x2bb>
mov    0x2b67(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%rdx
lea    0xba5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x48(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    14f3 <get_file_list+0x313>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     14f3 <get_file_list+0x313>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     14f3 <get_file_list+0x313>
mov    -0x80(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,%rdx
mov    -0x60(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    154b <get_file_list+0x36b>
mov    -0x48(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1546 <get_file_list+0x366>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1546 <get_file_list+0x366>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1546 <get_file_list+0x366>
mov    -0x78(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,%rdx
mov    -0x68(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    154b <get_file_list+0x36b>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
jmp    13e1 <get_file_list+0x201>
mov    -0x30(%rbp),%rdi
call   1090 <closedir@plt>
mov    -0x60(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x68(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1050 <opendir@plt>
test   %rax,%rax
je     150f <get_file_list+0x32f>
mov    %rax,%r12
mov    %r15,0x10(%rsp)
mov    %rbp,0x28(%rsp)
mov    %r14,0x30(%rsp)
mov    %rax,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1322 <get_file_list+0x142>
movl   $0x0,0x8(%rsp)
xor    %r14d,%r14d
jmp    1269 <get_file_list+0x89>
addl   $0x1,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     132d <get_file_list+0x14d>
mov    (%rax),%r13
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   10d0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xd88(%rip),%rsi
call   10e0 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   10e0 <strcat@plt>
mov    %r15,%rdi
mov    %rsp,%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     14d2 <get_file_list+0x2f2>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
test   %rax,%rax
je     1310 <get_file_list+0x130>
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
test   %rax,%rax
je     1250 <get_file_list+0x70>
movzbl 0x0(%r13),%eax
cmp    $0x2e,%al
je     1250 <get_file_list+0x70>
cmp    $0x5f,%al
je     1250 <get_file_list+0x70>
add    $0x1,%r14d
jmp    1250 <get_file_list+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x0(%r13),%eax
cmp    $0x2e,%al
je     12d4 <get_file_list+0xf4>
cmp    $0x5f,%al
je     12d4 <get_file_list+0xf4>
jmp    123d <get_file_list+0x5d>
xor    %r14d,%r14d
movl   $0x0,0x8(%rsp)
mov    0x18(%rsp),%rax
mov    0x8(%rsp),%ebp
mov    %ebp,(%rax)
mov    0x10(%rsp),%rax
mov    %r14d,(%rax)
mov    %r12,%rdi
call   1080 <rewinddir@plt>
shl    $0x3,%ebp
mov    %ebp,%edi
call   10d0 <malloc@plt>
mov    %rax,0x20(%rsp)
shl    $0x3,%r14d
mov    %r14d,%edi
call   10d0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %r12,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     14a1 <get_file_list+0x2c1>
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x10(%rsp)
jmp    13c9 <get_file_list+0x1e9>
mov    %r13,%rdi
call   1100 <strdup@plt>
mov    0x10(%rsp),%rdx
movslq %edx,%rdx
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
add    $0x1,%edx
mov    %rdx,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     14a1 <get_file_list+0x2c1>
mov    (%rax),%r14
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   10d0 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
lea    0xc28(%rip),%rsi
call   10e0 <strcat@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   10e0 <strcat@plt>
mov    %r13,%rdi
mov    %rsp,%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     14e7 <get_file_list+0x307>
mov    (%rsp),%r15d
mov    %r15d,%edi
call   1070 <S_ISDIR@plt>
test   %rax,%rax
je     1490 <get_file_list+0x2b0>
mov    %r15d,%edi
call   1070 <S_ISDIR@plt>
test   %rax,%rax
je     13b0 <get_file_list+0x1d0>
movzbl (%r14),%eax
cmp    $0x2e,%al
je     13b0 <get_file_list+0x1d0>
cmp    $0x5f,%al
je     13b0 <get_file_list+0x1d0>
mov    %r14,%rdi
call   1100 <strdup@plt>
mov    0x8(%rsp),%rdx
movslq %edx,%rdx
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
add    $0x1,%edx
mov    %rdx,0x8(%rsp)
jmp    13b0 <get_file_list+0x1d0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r14),%eax
cmp    $0x2e,%al
je     1436 <get_file_list+0x256>
cmp    $0x5f,%al
je     1436 <get_file_list+0x256>
jmp    1389 <get_file_list+0x1a9>
mov    %r12,%rdi
call   1090 <closedir@plt>
mov    0x28(%rsp),%rax
mov    0x20(%rsp),%rcx
mov    %rcx,(%rax)
mov    0x30(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    %rcx,(%rax)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
lea    0xb49(%rip),%rsi
mov    %r13,%rdx
jmp    14fa <get_file_list+0x31a>
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
lea    0xb34(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2ad0(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    0x2aca(%rip),%rax
mov    (%rax),%edi
lea    0xae1(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1501 <get_file_list+0x321>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [41 x i8] c"ERROR: Could not open current directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [26 x i8] c"ERROR: Could not stat %s\0A\00"
define void @get_file_list(i8* %0, i8*** %1, i32* %2, i8*** %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8***
%8 = alloca i32*
%9 = alloca i8***
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.dirent*
%15 = alloca %struct.stat
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8**
%19 = alloca i8**
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8*
%23 = alloca i8*
store i8* %0, i8** %6
store i8*** %1, i8**** %7
store i32* %2, i32** %8
store i8*** %3, i8**** %9
store i32* %4, i32** %10
%24 = load i8*, i8** %6
%25 = call i32* @opendir(i8* %24)
store i32* %25, i32** %11
%26 = load i32*, i32** %11
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %5
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %5
store i32 0, i32* %12
store i32 0, i32* %13
br label %34
34: ; preds = %108, %33
%35 = load i32*, i32** %11
%36 = call %struct.dirent* @readdir(i32* %35)
store %struct.dirent* %36, %struct.dirent** %14
%37 = icmp ne %struct.dirent* %36, null
br i1 %37, label %38, label %111
38: ; preds = %34
%39 = load %struct.dirent*, %struct.dirent** %14
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
store i8* %41, i8** %16
%42 = load i8*, i8** %6
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %43, 1
%45 = load i8*, i8** %16
%46 = call i32 @strlen(i8* %45)
%47 = add nsw i32 %44, %46
%48 = add nsw i32 %47, 1
%49 = call i8* @malloc(i32 %48)
store i8* %49, i8** %17
%50 = load i8*, i8** %17
%51 = load i8*, i8** %6
%52 = call i32 @strcpy(i8* %50, i8* %51)
%53 = load i8*, i8** %17
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = load i8*, i8** %17
%56 = load i8*, i8** %16
%57 = call i32 @strcat(i8* %55, i8* %56)
%58 = load i8*, i8** %17
%59 = call i32 @stat(i8* %58, %struct.stat* %15)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %67
61: ; preds = %38
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %16
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %38
%68 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i64 @S_ISDIR(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %87, label %72
72: ; preds = %67
%73 = load i8*, i8** %16
%74 = getelementptr inbounds i8, i8* %73, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 95
br i1 %77, label %78, label %87
78: ; preds = %72
%79 = load i8*, i8** %16
%80 = getelementptr inbounds i8, i8* %79, i64 0
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 46
br i1 %83, label %84, label %87
84: ; preds = %78
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
store i32 %86, i32* %12
br label %108
87: ; preds = %78, %72, %67
%88 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%89 = load i32, i32* %88
%90 = call i64 @S_ISDIR(i32 %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %107
92: ; preds = %87
%93 = load i8*, i8** %16
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 95
br i1 %97, label %98, label %107
98: ; preds = %92
%99 = load i8*, i8** %16
%100 = getelementptr inbounds i8, i8* %99, i64 0
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp ne i32 %102, 46
br i1 %103, label %104, label %107
104: ; preds = %98
%105 = load i32, i32* %13
%106 = add nsw i32 %105, 1
store i32 %106, i32* %13
br label %107
107: ; preds = %104, %98, %92, %87
br label %108
108: ; preds = %107, %84
%109 = load i8*, i8** %17
%110 = call i32 @free(i8* %109)
br label %34
111: ; preds = %34
%112 = load i32, i32* %12
%113 = load i32*, i32** %8
store i32 %112, i32* %113
%114 = load i32, i32* %13
%115 = load i32*, i32** %10
store i32 %114, i32* %115
%116 = load i32*, i32** %11
%117 = call i32 @rewinddir(i32* %116)
%118 = load i32, i32* %12
%119 = sext i32 %118 to i64
%120 = mul i64 8, %119
%121 = trunc i64 %120 to i32
%122 = call i8* @malloc(i32 %121)
%123 = bitcast i8* %122 to i8**
store i8** %123, i8*** %18
%124 = load i32, i32* %13
%125 = sext i32 %124 to i64
%126 = mul i64 8, %125
%127 = trunc i64 %126 to i32
%128 = call i8* @malloc(i32 %127)
%129 = bitcast i8* %128 to i8**
store i8** %129, i8*** %19
store i32 0, i32* %20
store i32 0, i32* %21
br label %130
130: ; preds = %216, %111
%131 = load i32*, i32** %11
%132 = call %struct.dirent* @readdir(i32* %131)
store %struct.dirent* %132, %struct.dirent** %14
%133 = icmp ne %struct.dirent* %132, null
br i1 %133, label %134, label %219
134: ; preds = %130
%135 = load %struct.dirent*, %struct.dirent** %14
%136 = getelementptr inbounds %struct.dirent, %struct.dirent* %135, i32 0, i32 0
%137 = load i8*, i8** %136
store i8* %137, i8** %22
%138 = load i8*, i8** %6
%139 = call i32 @strlen(i8* %138)
%140 = add nsw i32 %139, 1
%141 = load i8*, i8** %22
%142 = call i32 @strlen(i8* %141)
%143 = add nsw i32 %140, %142
%144 = add nsw i32 %143, 1
%145 = call i8* @malloc(i32 %144)
store i8* %145, i8** %23
%146 = load i8*, i8** %23
%147 = load i8*, i8** %6
%148 = call i32 @strcpy(i8* %146, i8* %147)
%149 = load i8*, i8** %23
%150 = call i32 @strcat(i8* %149, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%151 = load i8*, i8** %23
%152 = load i8*, i8** %22
%153 = call i32 @strcat(i8* %151, i8* %152)
%154 = load i8*, i8** %23
%155 = call i32 @stat(i8* %154, %struct.stat* %15)
%156 = icmp eq i32 %155, -1
br i1 %156, label %157, label %163
157: ; preds = %134
%158 = load i32, i32* @stderr
%159 = load i8*, i8** %22
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %159)
%161 = load i32, i32* @EXIT_FAILURE
%162 = call i32 @exit(i32 %161)
unreachable
163: ; preds = %134
%164 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%165 = load i32, i32* %164
%166 = call i64 @S_ISDIR(i32 %165)
%167 = icmp ne i64 %166, 0
br i1 %167, label %189, label %168
168: ; preds = %163
%169 = load i8*, i8** %22
%170 = getelementptr inbounds i8, i8* %169, i64 0
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp ne i32 %172, 95
br i1 %173, label %174, label %189
174: ; preds = %168
%175 = load i8*, i8** %22
%176 = getelementptr inbounds i8, i8* %175, i64 0
%177 = load i8, i8* %176
%178 = sext i8 %177 to i32
%179 = icmp ne i32 %178, 46
br i1 %179, label %180, label %189
180: ; preds = %174
%181 = load i8*, i8** %23
%182 = call i8* @strdup(i8* %181)
%183 = load i8**, i8*** %18
%184 = load i32, i32* %20
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds i8*, i8** %183, i64 %185
store i8* %182, i8** %186
%187 = load i32, i32* %20
%188 = add nsw i32 %187, 1
store i32 %188, i32* %20
br label %216
189: ; preds = %174, %168, %163
%190 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%191 = load i32, i32* %190
%192 = call i64 @S_ISDIR(i32 %191)
%193 = icmp ne i64 %192, 0
br i1 %193, label %194, label %215
194: ; preds = %189
%195 = load i8*, i8** %22
%196 = getelementptr inbounds i8, i8* %195, i64 0
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = icmp ne i32 %198, 95
br i1 %199, label %200, label %215
200: ; preds = %194
%201 = load i8*, i8** %22
%202 = getelementptr inbounds i8, i8* %201, i64 0
%203 = load i8, i8* %202
%204 = sext i8 %203 to i32
%205 = icmp ne i32 %204, 46
br i1 %205, label %206, label %215
206: ; preds = %200
%207 = load i8*, i8** %22
%208 = call i8* @strdup(i8* %207)
%209 = load i8**, i8*** %19
%210 = load i32, i32* %21
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds i8*, i8** %209, i64 %211
store i8* %208, i8** %212
%213 = load i32, i32* %21
%214 = add nsw i32 %213, 1
store i32 %214, i32* %21
br label %215
215: ; preds = %206, %200, %194, %189
br label %216
216: ; preds = %215, %180
%217 = load i8*, i8** %23
%218 = call i32 @free(i8* %217)
br label %130
219: ; preds = %130
%220 = load i32*, i32** %11
%221 = call i32 @closedir(i32* %220)
%222 = load i8**, i8*** %18
%223 = load i8***, i8**** %7
store i8** %222, i8*** %223
%224 = load i8**, i8*** %19
%225 = load i8***, i8**** %9
store i8** %224, i8*** %225
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@stderr = global i32 0
@.str = [41 x i8] c"ERROR: Could not open current directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [26 x i8] c"ERROR: Could not stat %s\0A\00"
define void @get_file_list(i8* %0, i8*** nocapture writeonly %1, i32* nocapture writeonly %2, i8*** nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca %struct.stat
%7 = tail call i32* @opendir(i8* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %5
%15 = bitcast %struct.stat* %6 to i8*
%16 = tail call %struct.dirent* @readdir(i32* %7)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %62, label %18
18: ; preds = %14
%19 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
br label %20
20: ; preds = %18, %56
%21 = phi %struct.dirent* [ %16, %18 ], [ %60, %56 ]
%22 = phi i32 [ 0, %18 ], [ %58, %56 ]
%23 = phi i32 [ 0, %18 ], [ %57, %56 ]
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = tail call i32 @strlen(i8* %0)
%27 = tail call i32 @strlen(i8* %25)
%28 = add i32 %26, 2
%29 = add i32 %28, %27
%30 = tail call i8* @malloc(i32 %29)
%31 = tail call i32 @strcpy(i8* %30, i8* %0)
%32 = tail call i32 @strcat(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call i32 @strcat(i8* %30, i8* %25)
%34 = call i32 @stat(i8* %30, %struct.stat* %6)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %20
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%39 = load i32, i32* @EXIT_FAILURE
%40 = tail call i32 @exit(i32 %39)
unreachable
41: ; preds = %20
%42 = load i32, i32* %19
%43 = tail call i64 @S_ISDIR(i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i8, i8* %25
switch i8 %46, label %47 [
i8 95, label %49
i8 46, label %49
]
47: ; preds = %45
%48 = add nsw i32 %22, 1
br label %56
49: ; preds = %45, %45, %41
%50 = tail call i64 @S_ISDIR(i32 %42)
%51 = icmp eq i64 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %49
%53 = load i8, i8* %25
switch i8 %53, label %54 [
i8 95, label %56
i8 46, label %56
]
54: ; preds = %52
%55 = add nsw i32 %23, 1
br label %56
56: ; preds = %52, %52, %49, %54, %47
%57 = phi i32 [ %55, %54 ], [ %23, %52 ], [ %23, %49 ], [ %23, %47 ], [ %23, %52 ]
%58 = phi i32 [ %22, %54 ], [ %22, %52 ], [ %22, %49 ], [ %48, %47 ], [ %22, %52 ]
%59 = tail call i32 @free(i8* %30)
%60 = tail call %struct.dirent* @readdir(i32* %7)
%61 = icmp eq %struct.dirent* %60, null
br i1 %61, label %62, label %20
62: ; preds = %56, %14
%63 = phi i32 [ 0, %14 ], [ %57, %56 ]
%64 = phi i32 [ 0, %14 ], [ %58, %56 ]
store i32 %64, i32* %2
store i32 %63, i32* %4
%65 = tail call i32 @rewinddir(i32* %7)
%66 = shl i32 %64, 3
%67 = tail call i8* @malloc(i32 %66)
%68 = bitcast i8* %67 to i8**
%69 = shl i32 %63, 3
%70 = tail call i8* @malloc(i32 %69)
%71 = bitcast i8* %70 to i8**
%72 = tail call %struct.dirent* @readdir(i32* %7)
%73 = icmp eq %struct.dirent* %72, null
br i1 %73, label %124, label %74
74: ; preds = %62
%75 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
br label %76
76: ; preds = %74, %118
%77 = phi %struct.dirent* [ %72, %74 ], [ %122, %118 ]
%78 = phi i32 [ 0, %74 ], [ %120, %118 ]
%79 = phi i32 [ 0, %74 ], [ %119, %118 ]
%80 = getelementptr inbounds %struct.dirent, %struct.dirent* %77, i64 0, i32 0
%81 = load i8*, i8** %80
%82 = tail call i32 @strlen(i8* %0)
%83 = tail call i32 @strlen(i8* %81)
%84 = add i32 %82, 2
%85 = add i32 %84, %83
%86 = tail call i8* @malloc(i32 %85)
%87 = tail call i32 @strcpy(i8* %86, i8* %0)
%88 = tail call i32 @strcat(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%89 = tail call i32 @strcat(i8* %86, i8* %81)
%90 = call i32 @stat(i8* %86, %struct.stat* %6)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %97
92: ; preds = %76
%93 = load i32, i32* @stderr
%94 = tail call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %81)
%95 = load i32, i32* @EXIT_FAILURE
%96 = tail call i32 @exit(i32 %95)
unreachable
97: ; preds = %76
%98 = load i32, i32* %75
%99 = tail call i64 @S_ISDIR(i32 %98)
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %108
101: ; preds = %97
%102 = load i8, i8* %81
switch i8 %102, label %103 [
i8 95, label %108
i8 46, label %108
]
103: ; preds = %101
%104 = tail call i8* @strdup(i8* %86)
%105 = sext i32 %79 to i64
%106 = getelementptr inbounds i8*, i8** %68, i64 %105
store i8* %104, i8** %106
%107 = add nsw i32 %79, 1
br label %118
108: ; preds = %101, %101, %97
%109 = tail call i64 @S_ISDIR(i32 %98)
%110 = icmp eq i64 %109, 0
br i1 %110, label %118, label %111
111: ; preds = %108
%112 = load i8, i8* %81
switch i8 %112, label %113 [
i8 95, label %118
i8 46, label %118
]
113: ; preds = %111
%114 = tail call i8* @strdup(i8* %81)
%115 = sext i32 %78 to i64
%116 = getelementptr inbounds i8*, i8** %71, i64 %115
store i8* %114, i8** %116
%117 = add nsw i32 %78, 1
br label %118
118: ; preds = %111, %111, %108, %113, %103
%119 = phi i32 [ %79, %113 ], [ %79, %111 ], [ %79, %108 ], [ %107, %103 ], [ %79, %111 ]
%120 = phi i32 [ %117, %113 ], [ %78, %111 ], [ %78, %108 ], [ %78, %103 ], [ %78, %111 ]
%121 = tail call i32 @free(i8* %86)
%122 = tail call %struct.dirent* @readdir(i32* %7)
%123 = icmp eq %struct.dirent* %122, null
br i1 %123, label %124, label %76
124: ; preds = %118, %62
%125 = tail call i32 @closedir(i32* %7)
%126 = bitcast i8*** %1 to i8**
store i8* %67, i8** %126
%127 = bitcast i8*** %3 to i8**
store i8* %70, i8** %127
ret void
}