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

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_REG;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
char *malloc(scalar_t__);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int gather_files(char *files[], char *paths[], char *root, char *path_root,
                 int offset, int count) {
  DIR *dir;
  struct dirent *dent;
  dir = opendir(root);
  int additional_files = 0;
  if (dir != NULL) {
    while ((dent = readdir(dir))) {
      if (offset == count) {
        break;
      }
      if (strcmp(".", dent->d_name) == 0 || strcmp("..", dent->d_name) == 0) {
        continue;
      }
      if (dent->d_type == DT_DIR) {
        char *new_path_root =
            malloc(strlen(path_root) + strlen(dent->d_name) + 2);
        strcpy(new_path_root, path_root);
        strcat(new_path_root, dent->d_name);
        strcat(new_path_root, "/");
        char *new_root = malloc(strlen(root) + strlen(dent->d_name) + 2);
        strcpy(new_root, root);
        strcat(new_root, "/");
        strcat(new_root, dent->d_name);
        additional_files += gather_files(files, paths, new_root, new_path_root,
                                         offset + additional_files, count);
      } else if (dent->d_type == DT_REG) {
        char *new_path_root =
            malloc(strlen(path_root) + strlen(dent->d_name) + 2);
        strcpy(new_path_root, path_root);
        strcat(new_path_root, dent->d_name);
        char *new_root = malloc(strlen(root) + strlen(dent->d_name) + 2);
        strcpy(new_root, root);
        strcat(new_root, "/");
        strcat(new_root, dent->d_name);
        files[offset + additional_files] = new_root;
        paths[offset + additional_files] = new_path_root;
        additional_files++;
      }
    }
    closedir(dir);
  }
  return additional_files;
}


x86 assembly (clang, -O0):
<gather_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1438 <gather_files+0x2a8>
jmp    11d7 <gather_files+0x47>
mov    -0x30(%rbp),%rdi
call   1080 <readdir@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     142f <gather_files+0x29f>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    11ff <gather_files+0x6f>
jmp    142f <gather_files+0x29f>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf4(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1239 <gather_files+0xa9>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd6(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    123e <gather_files+0xae>
jmp    11d7 <gather_files+0x47>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2d8b(%rip),%rcx
cmp    (%rcx),%rax
jne    1336 <gather_files+0x1a6>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x70(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   10a0 <strcat@plt>
mov    -0x48(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   10a0 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x24(%rbp),%r8d
add    -0x3c(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   10b0 <gather_files@plt>
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    142a <gather_files+0x29a>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c9b(%rip),%rcx
cmp    (%rcx),%rax
jne    1425 <gather_files+0x295>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x80(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x78(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x60(%rbp),%rdi
lea    0xc26(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   10a0 <strcat@plt>
mov    -0x60(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x58(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    142a <gather_files+0x29a>
jmp    11d7 <gather_files+0x47>
mov    -0x30(%rbp),%rdi
call   1060 <closedir@plt>
mov    -0x3c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gather_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r13d
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,0x40(%rsp)
mov    %rdx,%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     1205 <gather_files+0x75>
mov    %rax,%rbx
mov    %r12,0x38(%rsp)
mov    %rax,%rdi
call   1080 <readdir@plt>
cmp    %r13d,%r15d
je     1209 <gather_files+0x79>
mov    %rax,%r12
mov    %rbp,0x28(%rsp)
mov    %r14,0x18(%rsp)
mov    %r15,0x30(%rsp)
test   %rax,%rax
mov    $0x0,%ebp
je     120b <gather_files+0x7b>
xor    %ebp,%ebp
lea    0xe08(%rip),%r15
lea    0xe00(%rip),%r14
jmp    1324 <gather_files+0x194>
xor    %ebp,%ebp
jmp    1213 <gather_files+0x83>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1060 <closedir@plt>
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,0x10(%rsp)
mov    0x18(%rsp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    (%r12),%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rax,0x20(%rsp)
mov    0x18(%rsp),%rsi
call   1030 <strcpy@plt>
mov    (%r12),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    %rbp,%rdi
lea    0xd8c(%rip),%rsi
call   10a0 <strcat@plt>
mov    0x28(%rsp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    (%r12),%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %r13d,0xc(%rsp)
mov    %rax,%rbp
mov    %rax,%rdi
mov    0x28(%rsp),%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
lea    0xd45(%rip),%rsi
call   10a0 <strcat@plt>
mov    (%r12),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    0x30(%rsp),%rax
mov    0x10(%rsp),%r12
lea    (%r12,%rax,1),%r8d
mov    0x40(%rsp),%rdi
mov    0x38(%rsp),%rsi
mov    %rbp,%rdx
mov    0xc(%rsp),%r13d
mov    0x20(%rsp),%rcx
mov    %r13d,%r9d
call   10b0 <gather_files@plt>
add    %r12d,%eax
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     120b <gather_files+0x7b>
mov    (%r12),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1310 <gather_files+0x180>
mov    (%r12),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1310 <gather_files+0x180>
mov    0x8(%r12),%rax
mov    0x2c86(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <gather_files+0x94>
mov    0x2c7e(%rip),%rcx
cmp    (%rcx),%rax
jne    1310 <gather_files+0x180>
mov    %rbp,0x10(%rsp)
mov    0x18(%rsp),%rdi
call   1050 <strlen@plt>
mov    %r13d,0xc(%rsp)
mov    %rax,%r13
mov    (%r12),%rdi
call   1050 <strlen@plt>
lea    (%rax,%r13,1),%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,0x20(%rsp)
mov    %rax,%rdi
mov    0x18(%rsp),%rsi
call   1030 <strcpy@plt>
mov    (%r12),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    0x28(%rsp),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    (%r12),%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
lea    0xc10(%rip),%rsi
call   10a0 <strcat@plt>
mov    (%r12),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    0x30(%rsp),%rax
mov    0x10(%rsp),%rcx
add    %ecx,%eax
cltq
mov    0x40(%rsp),%rcx
mov    %rbp,(%rcx,%rax,8)
mov    0x10(%rsp),%rbp
mov    0xc(%rsp),%r13d
mov    0x38(%rsp),%rcx
mov    0x20(%rsp),%rdx
mov    %rdx,(%rcx,%rax,8)
add    $0x1,%ebp
jmp    1310 <gather_files+0x180>

LLVM IR (-O0):
%struct.dirent = type { i8*, i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@DT_DIR = global i64 0
@.str.2 = [2 x i8] c"/\00"
@DT_REG = global i64 0
define i32 @gather_files(i8** %0, i8** %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca %struct.dirent*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
store i8** %0, i8*** %7
store i8** %1, i8*** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%20 = load i8*, i8** %9
%21 = call i32* @opendir(i8* %20)
store i32* %21, i32** %13
store i32 0, i32* %15
%22 = load i32*, i32** %13
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %167
24: ; preds = %6
br label %25
25: ; preds = %163, %46, %24
%26 = load i32*, i32** %13
%27 = call %struct.dirent* @readdir(i32* %26)
store %struct.dirent* %27, %struct.dirent** %14
%28 = icmp ne %struct.dirent* %27, null
br i1 %28, label %29, label %164
29: ; preds = %25
%30 = load i32, i32* %11
%31 = load i32, i32* %12
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %164
34: ; preds = %29
%35 = load %struct.dirent*, %struct.dirent** %14
%36 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i32 0, i32 0
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %34
%41 = load %struct.dirent*, %struct.dirent** %14
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %40, %34
br label %25
47: ; preds = %40
%48 = load %struct.dirent*, %struct.dirent** %14
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = load i64, i64* @DT_DIR
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %103
53: ; preds = %47
%54 = load i8*, i8** %10
%55 = call i64 @strlen(i8* %54)
%56 = load %struct.dirent*, %struct.dirent** %14
%57 = getelementptr inbounds %struct.dirent, %struct.dirent* %56, i32 0, i32 0
%58 = load i8*, i8** %57
%59 = call i64 @strlen(i8* %58)
%60 = add nsw i64 %55, %59
%61 = add nsw i64 %60, 2
%62 = call i8* @malloc(i64 %61)
store i8* %62, i8** %16
%63 = load i8*, i8** %16
%64 = load i8*, i8** %10
%65 = call i32 @strcpy(i8* %63, i8* %64)
%66 = load i8*, i8** %16
%67 = load %struct.dirent*, %struct.dirent** %14
%68 = getelementptr inbounds %struct.dirent, %struct.dirent* %67, i32 0, i32 0
%69 = load i8*, i8** %68
%70 = call i32 @strcat(i8* %66, i8* %69)
%71 = load i8*, i8** %16
%72 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%73 = load i8*, i8** %9
%74 = call i64 @strlen(i8* %73)
%75 = load %struct.dirent*, %struct.dirent** %14
%76 = getelementptr inbounds %struct.dirent, %struct.dirent* %75, i32 0, i32 0
%77 = load i8*, i8** %76
%78 = call i64 @strlen(i8* %77)
%79 = add nsw i64 %74, %78
%80 = add nsw i64 %79, 2
%81 = call i8* @malloc(i64 %80)
store i8* %81, i8** %17
%82 = load i8*, i8** %17
%83 = load i8*, i8** %9
%84 = call i32 @strcpy(i8* %82, i8* %83)
%85 = load i8*, i8** %17
%86 = call i32 @strcat(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%87 = load i8*, i8** %17
%88 = load %struct.dirent*, %struct.dirent** %14
%89 = getelementptr inbounds %struct.dirent, %struct.dirent* %88, i32 0, i32 0
%90 = load i8*, i8** %89
%91 = call i32 @strcat(i8* %87, i8* %90)
%92 = load i8**, i8*** %7
%93 = load i8**, i8*** %8
%94 = load i8*, i8** %17
%95 = load i8*, i8** %16
%96 = load i32, i32* %11
%97 = load i32, i32* %15
%98 = add nsw i32 %96, %97
%99 = load i32, i32* %12
%100 = call i32 @gather_files(i8** %92, i8** %93, i8* %94, i8* %95, i32 %98, i32 %99)
%101 = load i32, i32* %15
%102 = add nsw i32 %101, %100
store i32 %102, i32* %15
br label %163
103: ; preds = %47
%104 = load %struct.dirent*, %struct.dirent** %14
%105 = getelementptr inbounds %struct.dirent, %struct.dirent* %104, i32 0, i32 1
%106 = load i64, i64* %105
%107 = load i64, i64* @DT_REG
%108 = icmp eq i64 %106, %107
br i1 %108, label %109, label %162
109: ; preds = %103
%110 = load i8*, i8** %10
%111 = call i64 @strlen(i8* %110)
%112 = load %struct.dirent*, %struct.dirent** %14
%113 = getelementptr inbounds %struct.dirent, %struct.dirent* %112, i32 0, i32 0
%114 = load i8*, i8** %113
%115 = call i64 @strlen(i8* %114)
%116 = add nsw i64 %111, %115
%117 = add nsw i64 %116, 2
%118 = call i8* @malloc(i64 %117)
store i8* %118, i8** %18
%119 = load i8*, i8** %18
%120 = load i8*, i8** %10
%121 = call i32 @strcpy(i8* %119, i8* %120)
%122 = load i8*, i8** %18
%123 = load %struct.dirent*, %struct.dirent** %14
%124 = getelementptr inbounds %struct.dirent, %struct.dirent* %123, i32 0, i32 0
%125 = load i8*, i8** %124
%126 = call i32 @strcat(i8* %122, i8* %125)
%127 = load i8*, i8** %9
%128 = call i64 @strlen(i8* %127)
%129 = load %struct.dirent*, %struct.dirent** %14
%130 = getelementptr inbounds %struct.dirent, %struct.dirent* %129, i32 0, i32 0
%131 = load i8*, i8** %130
%132 = call i64 @strlen(i8* %131)
%133 = add nsw i64 %128, %132
%134 = add nsw i64 %133, 2
%135 = call i8* @malloc(i64 %134)
store i8* %135, i8** %19
%136 = load i8*, i8** %19
%137 = load i8*, i8** %9
%138 = call i32 @strcpy(i8* %136, i8* %137)
%139 = load i8*, i8** %19
%140 = call i32 @strcat(i8* %139, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%141 = load i8*, i8** %19
%142 = load %struct.dirent*, %struct.dirent** %14
%143 = getelementptr inbounds %struct.dirent, %struct.dirent* %142, i32 0, i32 0
%144 = load i8*, i8** %143
%145 = call i32 @strcat(i8* %141, i8* %144)
%146 = load i8*, i8** %19
%147 = load i8**, i8*** %7
%148 = load i32, i32* %11
%149 = load i32, i32* %15
%150 = add nsw i32 %148, %149
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8*, i8** %147, i64 %151
store i8* %146, i8** %152
%153 = load i8*, i8** %18
%154 = load i8**, i8*** %8
%155 = load i32, i32* %11
%156 = load i32, i32* %15
%157 = add nsw i32 %155, %156
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8*, i8** %154, i64 %158
store i8* %153, i8** %159
%160 = load i32, i32* %15
%161 = add nsw i32 %160, 1
store i32 %161, i32* %15
br label %162
162: ; preds = %109, %103
br label %163
163: ; preds = %162, %53
br label %25
164: ; preds = %33, %25
%165 = load i32*, i32** %13
%166 = call i32 @closedir(i32* %165)
br label %167
167: ; preds = %164, %6
%168 = load i32, i32* %15
ret i32 %168
}

LLVM IR (-O2):
%struct.dirent = type { i8*, i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@DT_DIR = global i64 0
@.str.2 = [2 x i8] c"/\00"
@DT_REG = global i64 0
define i32 @gather_files(i8** nocapture writeonly %0, i8** nocapture writeonly %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = tail call i32* @opendir(i8* %2)
%8 = icmp eq i32* %7, null
br i1 %8, label %94, label %9
9: ; preds = %6
%10 = tail call %struct.dirent* @readdir(i32* %7)
%11 = icmp eq %struct.dirent* %10, null
%12 = icmp eq i32 %4, %5
%13 = or i1 %12, %11
br i1 %13, label %91, label %14
14: ; preds = %9, %87
%15 = phi %struct.dirent* [ %89, %87 ], [ %10, %9 ]
%16 = phi i32 [ %88, %87 ], [ 0, %9 ]
br label %17
17: ; preds = %14, %27
%18 = phi %struct.dirent* [ %15, %14 ], [ %28, %27 ]
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i64 0, i32 0
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %17
%24 = load i8*, i8** %19
%25 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23, %17
%28 = tail call %struct.dirent* @readdir(i32* %7)
%29 = icmp eq %struct.dirent* %28, null
br i1 %29, label %91, label %17
30: ; preds = %23
%31 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i64 0, i32 1
%32 = load i64, i64* %31
%33 = load i64, i64* @DT_DIR
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %59
35: ; preds = %30
%36 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%37 = load i8*, i8** %19
%38 = tail call i64 @strlen(i8* dereferenceable(1) %37)
%39 = add i64 %36, 2
%40 = add i64 %39, %38
%41 = tail call i8* @malloc(i64 %40)
%42 = tail call i32 @strcpy(i8* %41, i8* %3)
%43 = load i8*, i8** %19
%44 = tail call i32 @strcat(i8* %41, i8* %43)
%45 = tail call i32 @strcat(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%47 = load i8*, i8** %19
%48 = tail call i64 @strlen(i8* dereferenceable(1) %47)
%49 = add i64 %46, 2
%50 = add i64 %49, %48
%51 = tail call i8* @malloc(i64 %50)
%52 = tail call i32 @strcpy(i8* %51, i8* %2)
%53 = tail call i32 @strcat(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%54 = load i8*, i8** %19
%55 = tail call i32 @strcat(i8* %51, i8* %54)
%56 = add nsw i32 %16, %4
%57 = tail call i32 @gather_files(i8** %0, i8** %1, i8* %51, i8* %41, i32 %56, i32 %5)
%58 = add nsw i32 %57, %16
br label %87
59: ; preds = %30
%60 = load i64, i64* @DT_REG
%61 = icmp eq i64 %32, %60
br i1 %61, label %62, label %87
62: ; preds = %59
%63 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%64 = load i8*, i8** %19
%65 = tail call i64 @strlen(i8* dereferenceable(1) %64)
%66 = add i64 %63, 2
%67 = add i64 %66, %65
%68 = tail call i8* @malloc(i64 %67)
%69 = tail call i32 @strcpy(i8* %68, i8* %3)
%70 = load i8*, i8** %19
%71 = tail call i32 @strcat(i8* %68, i8* %70)
%72 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%73 = load i8*, i8** %19
%74 = tail call i64 @strlen(i8* dereferenceable(1) %73)
%75 = add i64 %72, 2
%76 = add i64 %75, %74
%77 = tail call i8* @malloc(i64 %76)
%78 = tail call i32 @strcpy(i8* %77, i8* %2)
%79 = tail call i32 @strcat(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%80 = load i8*, i8** %19
%81 = tail call i32 @strcat(i8* %77, i8* %80)
%82 = add nsw i32 %16, %4
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %0, i64 %83
store i8* %77, i8** %84
%85 = getelementptr inbounds i8*, i8** %1, i64 %83
store i8* %68, i8** %85
%86 = add nsw i32 %16, 1
br label %87
87: ; preds = %59, %62, %35
%88 = phi i32 [ %58, %35 ], [ %86, %62 ], [ %16, %59 ]
%89 = tail call %struct.dirent* @readdir(i32* %7)
%90 = icmp eq %struct.dirent* %89, null
br i1 %90, label %91, label %14
91: ; preds = %87, %27, %9
%92 = phi i32 [ 0, %9 ], [ %16, %27 ], [ %88, %87 ]
%93 = tail call i32 @closedir(i32* %7)
br label %94
94: ; preds = %91, %6
%95 = phi i32 [ %92, %91 ], [ 0, %6 ]
ret i32 %95
}