#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*/ filename;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int snprintf(char *, int, char *, char const *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char **get_filenames(const char *directory, int *num_of_files) {
  int i = 0;
  DIR *pDIR;
  struct dirent *pDirEnt;
  struct stat dirEntStat;
  char filename[256];
  pDIR = opendir(directory);
  if (pDIR == NULL) {
    fprintf(stderr, "%s %d: opendir() failed (%s)\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/"
            "http-aggregation/src/modules/analysis/fpsigmatcher/Utils.c",
            103, strerror(errno));
    exit(-1);
  }
  int filecounter = 0;
  pDirEnt = readdir(pDIR);
  while (pDirEnt != NULL) {
    if (pDirEnt->d_name[0] != '.') {
      if ((snprintf(filename, sizeof(filename), "%s/%s", directory,
                    pDirEnt->d_name) < sizeof(filename)) &&
          (stat(filename, &dirEntStat) == 0) && (S_ISREG(dirEntStat.st_mode))) {
        filecounter++;
      }
    }
    pDirEnt = readdir(pDIR);
  }
  *num_of_files = filecounter;
  char **filenames;
  filenames = (char **)malloc(sizeof(char *) * filecounter);
  for (i = 0; i < filecounter; ++i)
    filenames[i] = (char *)malloc(sizeof(char) * 256);
  rewinddir(pDIR);
  i = 0;
  pDirEnt = readdir(pDIR);
  while (pDirEnt != NULL) {
    if (pDirEnt->d_name[0] != '.') {
      if ((snprintf(filename, sizeof(filename), "%s/%s", directory,
                    pDirEnt->d_name) < sizeof(filename)) &&
          (stat(filename, &dirEntStat) == 0) && (S_ISREG(dirEntStat.st_mode))) {
        snprintf(filenames[i], 256 - 1, "%s", pDirEnt->d_name);
        i++;
      }
    }
    pDirEnt = readdir(pDIR);
  }
  closedir(pDIR);
  return filenames;
}


x86 assembly (clang, -O0):
<get_filenames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122a <get_filenames+0x7a>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x144(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x144(%rbp),%edi
mov    %rax,%r8
lea    0xdf1(%rip),%rsi
lea    0xe08(%rip),%rdx
mov    $0x67,%ecx
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x134(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12e4 <get_filenames+0x134>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     12d2 <get_filenames+0x122>
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    (%rax),%r8
mov    $0x100,%esi
lea    0xe54(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
cltq
cmp    $0x100,%rax
jae    12cd <get_filenames+0x11d>
lea    -0x130(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    12cd <get_filenames+0x11d>
mov    -0x30(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     12cd <get_filenames+0x11d>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    12d2 <get_filenames+0x122>
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
jmp    1241 <get_filenames+0x91>
mov    -0x134(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movslq -0x134(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x140(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x134(%rbp),%eax
jge    1349 <get_filenames+0x199>
mov    $0x100,%edi
call   10b0 <malloc@plt>
mov    %rax,%rdx
mov    -0x140(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1310 <get_filenames+0x160>
mov    -0x20(%rbp),%rdi
call   1050 <rewinddir@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     142c <get_filenames+0x27c>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     141a <get_filenames+0x26a>
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    (%rax),%r8
mov    $0x100,%esi
lea    0xd2f(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
cltq
cmp    $0x100,%rax
jae    1415 <get_filenames+0x265>
lea    -0x130(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    1415 <get_filenames+0x265>
mov    -0x30(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     1415 <get_filenames+0x265>
mov    -0x140(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    $0xff,%esi
lea    0xccf(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    141a <get_filenames+0x26a>
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
jmp    1366 <get_filenames+0x1b6>
mov    -0x20(%rbp),%rdi
call   1060 <closedir@plt>
mov    -0x140(%rbp),%rax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filenames>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <opendir@plt>
test   %rax,%rax
je     1357 <get_filenames+0x1a7>
mov    %rax,%r12
mov    %rbx,0x8(%rsp)
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1254 <get_filenames+0xa4>
lea    0xee0(%rip),%rbx
lea    0x10(%rsp),%rbp
mov    %rsp,%r15
xor    %r13d,%r13d
jmp    120d <get_filenames+0x5d>
xchg   %ax,%ax
mov    %r12,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1257 <get_filenames+0xa7>
mov    (%rax),%r8
cmpb   $0x2e,(%r8)
je     1200 <get_filenames+0x50>
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
cmp    $0xff,%eax
ja     1200 <get_filenames+0x50>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    1200 <get_filenames+0x50>
mov    (%rsp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r13d
jmp    1200 <get_filenames+0x50>
xor    %r13d,%r13d
mov    0x8(%rsp),%rax
mov    %r13d,(%rax)
lea    0x0(,%r13,8),%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
test   %r13d,%r13d
jle    1297 <get_filenames+0xe7>
mov    %r13d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x100,%edi
call   10b0 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1280 <get_filenames+0xd0>
mov    %r12,%rdi
call   1050 <rewinddir@plt>
mov    %r12,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     133a <get_filenames+0x18a>
mov    %rax,%rbp
lea    0x10(%rsp),%r13
xor    %ebx,%ebx
jmp    12d0 <get_filenames+0x120>
nopl   0x0(%rax)
mov    %r12,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     133a <get_filenames+0x18a>
mov    0x0(%rbp),%r8
cmpb   $0x2e,(%r8)
je     12c0 <get_filenames+0x110>
mov    %r13,%rdi
mov    $0x100,%esi
lea    0xde8(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
cmp    $0xff,%eax
ja     12c0 <get_filenames+0x110>
mov    %r13,%rdi
mov    %rsp,%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    12c0 <get_filenames+0x110>
mov    (%rsp),%edi
call   1090 <S_ISREG@plt>
test   %rax,%rax
je     12c0 <get_filenames+0x110>
movslq %ebx,%rbx
mov    (%r15,%rbx,8),%rdi
mov    0x0(%rbp),%rcx
mov    $0xff,%esi
lea    0xda6(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
add    $0x1,%ebx
jmp    12c0 <get_filenames+0x110>
mov    %r12,%rdi
call   1060 <closedir@plt>
mov    %r15,%rax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c82(%rip),%rax
mov    (%rax),%ebx
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc8b(%rip),%rsi
lea    0xca2(%rip),%rdx
mov    %ebx,%edi
mov    $0x67,%ecx
mov    %rax,%r8
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"%s %d: opendir() failed (%s)\0A\00"
@.str.1 = [179 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/http-aggregation/src/modules/analysis/fpsigmatcher/Utils.c\00"
@errno = global i32 0
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [3 x i8] c"%s\00"
define i8** @get_filenames(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca %struct.stat
%9 = alloca [256 x i8]
%10 = alloca i32
%11 = alloca i8**
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%12 = load i8*, i8** %3
%13 = call i32* @opendir(i8* %12)
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 103, i8* %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
store i32 0, i32* %10
%23 = load i32*, i32** %6
%24 = call %struct.dirent* @readdir(i32* %23)
store %struct.dirent* %24, %struct.dirent** %7
br label %25
25: ; preds = %58, %22
%26 = load %struct.dirent*, %struct.dirent** %7
%27 = icmp ne %struct.dirent* %26, null
br i1 %27, label %28, label %61
28: ; preds = %25
%29 = load %struct.dirent*, %struct.dirent** %7
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 46
br i1 %35, label %36, label %58
36: ; preds = %28
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%38 = load i8*, i8** %3
%39 = load %struct.dirent*, %struct.dirent** %7
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %37, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %38, i8* %41)
%43 = sext i32 %42 to i64
%44 = icmp ult i64 %43, 256
br i1 %44, label %45, label %57
45: ; preds = %36
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%47 = call i64 @stat(i8* %46, %struct.stat* %8)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %57
49: ; preds = %45
%50 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i64 @S_ISREG(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %57
57: ; preds = %54, %49, %45, %36
br label %58
58: ; preds = %57, %28
%59 = load i32*, i32** %6
%60 = call %struct.dirent* @readdir(i32* %59)
store %struct.dirent* %60, %struct.dirent** %7
br label %25
61: ; preds = %25
%62 = load i32, i32* %10
%63 = load i32*, i32** %4
store i32 %62, i32* %63
%64 = load i32, i32* %10
%65 = sext i32 %64 to i64
%66 = mul i64 8, %65
%67 = trunc i64 %66 to i32
%68 = call i64 @malloc(i32 %67)
%69 = inttoptr i64 %68 to i8**
store i8** %69, i8*** %11
store i32 0, i32* %5
br label %70
70: ; preds = %81, %61
%71 = load i32, i32* %5
%72 = load i32, i32* %10
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %84
74: ; preds = %70
%75 = call i64 @malloc(i32 256)
%76 = inttoptr i64 %75 to i8*
%77 = load i8**, i8*** %11
%78 = load i32, i32* %5
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
store i8* %76, i8** %80
br label %81
81: ; preds = %74
%82 = load i32, i32* %5
%83 = add nsw i32 %82, 1
store i32 %83, i32* %5
br label %70
84: ; preds = %70
%85 = load i32*, i32** %6
%86 = call i32 @rewinddir(i32* %85)
store i32 0, i32* %5
%87 = load i32*, i32** %6
%88 = call %struct.dirent* @readdir(i32* %87)
store %struct.dirent* %88, %struct.dirent** %7
br label %89
89: ; preds = %131, %84
%90 = load %struct.dirent*, %struct.dirent** %7
%91 = icmp ne %struct.dirent* %90, null
br i1 %91, label %92, label %134
92: ; preds = %89
%93 = load %struct.dirent*, %struct.dirent** %7
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = getelementptr inbounds i8, i8* %95, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp ne i32 %98, 46
br i1 %99, label %100, label %131
100: ; preds = %92
%101 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%102 = load i8*, i8** %3
%103 = load %struct.dirent*, %struct.dirent** %7
%104 = getelementptr inbounds %struct.dirent, %struct.dirent* %103, i32 0, i32 0
%105 = load i8*, i8** %104
%106 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %101, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %102, i8* %105)
%107 = sext i32 %106 to i64
%108 = icmp ult i64 %107, 256
br i1 %108, label %109, label %130
109: ; preds = %100
%110 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%111 = call i64 @stat(i8* %110, %struct.stat* %8)
%112 = icmp eq i64 %111, 0
br i1 %112, label %113, label %130
113: ; preds = %109
%114 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%115 = load i32, i32* %114
%116 = call i64 @S_ISREG(i32 %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %130
118: ; preds = %113
%119 = load i8**, i8*** %11
%120 = load i32, i32* %5
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8*, i8** %119, i64 %121
%123 = load i8*, i8** %122
%124 = load %struct.dirent*, %struct.dirent** %7
%125 = getelementptr inbounds %struct.dirent, %struct.dirent* %124, i32 0, i32 0
%126 = load i8*, i8** %125
%127 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %123, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %126)
%128 = load i32, i32* %5
%129 = add nsw i32 %128, 1
store i32 %129, i32* %5
br label %130
130: ; preds = %118, %113, %109, %100
br label %131
131: ; preds = %130, %92
%132 = load i32*, i32** %6
%133 = call %struct.dirent* @readdir(i32* %132)
store %struct.dirent* %133, %struct.dirent** %7
br label %89
134: ; preds = %89
%135 = load i32*, i32** %6
%136 = call i32 @closedir(i32* %135)
%137 = load i8**, i8*** %11
ret i8** %137
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@stderr = global i32 0
@.str = [30 x i8] c"%s %d: opendir() failed (%s)\0A\00"
@.str.1 = [179 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/http-aggregation/src/modules/analysis/fpsigmatcher/Utils.c\00"
@errno = global i32 0
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [3 x i8] c"%s\00"
define i8** @get_filenames(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.stat
%4 = alloca [256 x i8]
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = tail call i32* @opendir(i8* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 103, i8* %12)
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = tail call %struct.dirent* @readdir(i32* %7)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %43, label %18
18: ; preds = %15
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %20
20: ; preds = %18, %39
%21 = phi i32 [ 0, %18 ], [ %40, %39 ]
%22 = phi %struct.dirent* [ %16, %18 ], [ %41, %39 ]
%23 = getelementptr inbounds %struct.dirent, %struct.dirent* %22, i64 0, i32 0
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 46
br i1 %26, label %39, label %27
27: ; preds = %20
%28 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %24)
%29 = icmp ult i32 %28, 256
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = call i64 @stat(i8* %6, %struct.stat* %3)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %19
%35 = call i64 @S_ISREG(i32 %34)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
%38 = add nsw i32 %21, %37
br label %39
39: ; preds = %33, %27, %30, %20
%40 = phi i32 [ %21, %30 ], [ %21, %27 ], [ %21, %20 ], [ %38, %33 ]
%41 = call %struct.dirent* @readdir(i32* %7)
%42 = icmp eq %struct.dirent* %41, null
br i1 %42, label %43, label %20
43: ; preds = %39, %15
%44 = phi i32 [ 0, %15 ], [ %40, %39 ]
store i32 %44, i32* %1
%45 = shl i32 %44, 3
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i8**
%48 = icmp sgt i32 %44, 0
br i1 %48, label %49, label %58
49: ; preds = %43
%50 = zext i32 %44 to i64
br label %51
51: ; preds = %49, %51
%52 = phi i64 [ 0, %49 ], [ %56, %51 ]
%53 = call i64 @malloc(i32 256)
%54 = inttoptr i64 %53 to i8*
%55 = getelementptr inbounds i8*, i8** %47, i64 %52
store i8* %54, i8** %55
%56 = add nuw nsw i64 %52, 1
%57 = icmp eq i64 %56, %50
br i1 %57, label %58, label %51
58: ; preds = %51, %43
%59 = call i32 @rewinddir(i32* %7)
%60 = call %struct.dirent* @readdir(i32* %7)
%61 = icmp eq %struct.dirent* %60, null
br i1 %61, label %92, label %62
62: ; preds = %58
%63 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %64
64: ; preds = %62, %88
%65 = phi i32 [ 0, %62 ], [ %89, %88 ]
%66 = phi %struct.dirent* [ %60, %62 ], [ %90, %88 ]
%67 = getelementptr inbounds %struct.dirent, %struct.dirent* %66, i64 0, i32 0
%68 = load i8*, i8** %67
%69 = load i8, i8* %68
%70 = icmp eq i8 %69, 46
br i1 %70, label %88, label %71
71: ; preds = %64
%72 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %68)
%73 = icmp ult i32 %72, 256
br i1 %73, label %74, label %88
74: ; preds = %71
%75 = call i64 @stat(i8* %6, %struct.stat* %3)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %88
77: ; preds = %74
%78 = load i32, i32* %63
%79 = call i64 @S_ISREG(i32 %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %88, label %81
81: ; preds = %77
%82 = sext i32 %65 to i64
%83 = getelementptr inbounds i8*, i8** %47, i64 %82
%84 = load i8*, i8** %83
%85 = load i8*, i8** %67
%86 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %84, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %85)
%87 = add nsw i32 %65, 1
br label %88
88: ; preds = %71, %74, %77, %81, %64
%89 = phi i32 [ %87, %81 ], [ %65, %77 ], [ %65, %74 ], [ %65, %71 ], [ %65, %64 ]
%90 = call %struct.dirent* @readdir(i32* %7)
%91 = icmp eq %struct.dirent* %90, null
br i1 %91, label %92, label %64
92: ; preds = %88, %58
%93 = call i32 @closedir(i32* %7)
ret i8** %47
}