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

/* Variables and functions */
scalar_t__ DT_REG;
int MAXPATHLEN;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
void *malloc(int);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ readdir_r(int /*<<< orphan*/ *, struct dirent *,
                             struct dirent **);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/ *);
int strlen(int /*<<< orphan*/ *);
int find_gz(const char *dirname, char ***aptr) {
  char **earray = NULL;
  DIR *dirp = NULL;
  struct dirent *dresult = NULL;
  char fname[MAXPATHLEN];
  char buf[sizeof(struct dirent) + MAXPATHLEN];
  struct stat sbuf;
  int count = 0;
  int i;
  int len;
  dirp = opendir(dirname);
  if (!dirp) {
    fprintf(stderr, "Error: Cannot open directory [%s]\n", dirname);
    exit(-1);
  }
  count = 0;
  while (!readdir_r(dirp, (struct dirent *)buf, &dresult)) {
    if (!dresult)
      break;
    if (dresult->d_type == DT_REG) {
      len = strlen(dresult->d_name);
      if (strcmp(&dresult->d_name[len - 3], ".gz"))
        continue;
      ++count;
    }
  }
  rewinddir(dirp);
  *aptr = malloc((sizeof(char *) * (count + 1)));
  earray = *aptr;
  for (i = 0; i < count; ++i)
    earray[i] = malloc(sizeof(char) * MAXPATHLEN);
  earray[count] = NULL;
  i = 0;
  while (!readdir_r(dirp, (struct dirent *)buf, &dresult)) {
    if (!dresult)
      break;
    if (dresult->d_type == DT_REG) {
      len = strlen(dresult->d_name);
      if (strcmp(&dresult->d_name[len - 3], ".gz"))
        continue;
      strcpy(earray[i++], dresult->d_name);
    }
  }
  closedir(dirp);
  return count;
}


x86 assembly (clang, -O0):
<find_gz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
movslq (%rax),%rdx
mov    %rdx,%rax
add    $0x10,%rax
add    $0x1f,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1255 <find_gz+0xb5>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdba(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x60(%rbp),%rsi
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rdx
call   1040 <readdir_r@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1282 <find_gz+0xe2>
jmp    12f9 <find_gz+0x159>
cmpq   $0x0,-0x28(%rbp)
jne    1292 <find_gz+0xf2>
jmp    12f9 <find_gz+0x159>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2d38(%rip),%rcx
cmp    (%rcx),%rax
jne    12f4 <find_gz+0x154>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x54(%rbp),%eax
sub    $0x3,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    0xd4c(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     12eb <find_gz+0x14b>
jmp    125c <find_gz+0xbc>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    125c <find_gz+0xbc>
mov    -0x20(%rbp),%rdi
call   1070 <rewinddir@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    136f <find_gz+0x1cf>
mov    0x2ca4(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1331 <find_gz+0x191>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
movl   $0x0,-0x50(%rbp)
mov    -0x60(%rbp),%rsi
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rdx
call   1040 <readdir_r@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13ac <find_gz+0x20c>
jmp    143d <find_gz+0x29d>
cmpq   $0x0,-0x28(%rbp)
jne    13bc <find_gz+0x21c>
jmp    143d <find_gz+0x29d>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2c0e(%rip),%rcx
cmp    (%rcx),%rax
jne    1438 <find_gz+0x298>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x54(%rbp),%eax
sub    $0x3,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    0xc22(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1415 <find_gz+0x275>
jmp    1386 <find_gz+0x1e6>
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x50(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    1386 <find_gz+0x1e6>
mov    -0x20(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x4c(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_gz>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,-0x48(%rbp)
mov    %rdi,%r15
mov    %rsp,-0x50(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2e1d(%rip),%rax
movslq (%rax),%rax
mov    %rsp,%r14
add    $0x1f,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
call   1050 <opendir@plt>
test   %rax,%rax
je     137d <find_gz+0x1dd>
mov    %rax,%r13
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%r15
lea    0xe22(%rip),%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
jne    126f <find_gz+0xcf>
mov    -0x30(%rbp),%rax
test   %rax,%rax
je     126f <find_gz+0xcf>
mov    (%rax),%rcx
mov    0x2da3(%rip),%rdx
cmp    (%rdx),%rcx
jne    1210 <find_gz+0x70>
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    0x8(%rcx),%rcx
cltq
lea    (%rcx,%rax,4),%rdi
add    $0xfffffffffffffff4,%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1210 <find_gz+0x70>
add    $0x1,%r12
mov    %r12d,%eax
mov    %rax,-0x38(%rbp)
jmp    1210 <find_gz+0x70>
mov    %r13,%rdi
call   1070 <rewinddir@plt>
mov    -0x38(%rbp),%rbx
lea    0x8(,%rbx,8),%edi
call   10b0 <malloc@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,-0x40(%rbp)
mov    %rcx,(%rax)
test   %ebx,%ebx
je     12c5 <find_gz+0x125>
mov    0x2d48(%rip),%rax
mov    (%rax),%r15d
mov    -0x40(%rbp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   10b0 <malloc@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
add    $0xffffffffffffffff,%r12
jne    12b0 <find_gz+0x110>
mov    -0x38(%rbp),%eax
mov    -0x40(%rbp),%rcx
movq   $0x0,(%rcx,%rax,8)
xor    %ebx,%ebx
lea    -0x30(%rbp),%r12
lea    0xd42(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
jne    135e <find_gz+0x1be>
mov    -0x30(%rbp),%rax
test   %rax,%rax
je     135e <find_gz+0x1be>
mov    (%rax),%rcx
mov    0x2cc3(%rip),%rdx
cmp    (%rdx),%rcx
jne    12f0 <find_gz+0x150>
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    0x8(%rcx),%rcx
cltq
lea    (%rcx,%rax,4),%rdi
add    $0xfffffffffffffff4,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    12f0 <find_gz+0x150>
mov    %ebx,%eax
add    $0x1,%ebx
mov    -0x40(%rbp),%rcx
mov    (%rcx,%rax,8),%rdi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    12f0 <find_gz+0x150>
mov    %r13,%rdi
call   1080 <closedir@plt>
mov    -0x50(%rbp),%rsp
mov    -0x38(%rbp),%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
mov    %r15,%rdx
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

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

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