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

/* Variables and functions */
scalar_t__ DT_REG;
int MAXPATHLEN;
int S_IXOTH;
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*/ sprintf(char *, char *, char const *, char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int find_exes(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;
  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) {
      sprintf(fname, "%s/%s", dirname, dresult->d_name);
      if (!stat(fname, &sbuf)) {
        if (sbuf.st_mode & S_IXOTH)
          ++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) {
      sprintf(fname, "%s/%s", dirname, dresult->d_name);
      if (!stat(fname, &sbuf)) {
        if (sbuf.st_mode & S_IXOTH)
          strcpy(earray[i++], dresult->d_name);
      }
    }
  }
  closedir(dirp);
  return count;
}


x86 assembly (clang, -O0):
<find_exes>:
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    0x2e11(%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,-0x60(%rbp)
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,-0x58(%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    1259 <find_exes+0xb9>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdb6(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x58(%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    1286 <find_exes+0xe6>
jmp    130c <find_exes+0x16c>
cmpq   $0x0,-0x28(%rbp)
jne    1296 <find_exes+0xf6>
jmp    130c <find_exes+0x16c>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%rax
jne    1307 <find_exes+0x167>
mov    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd5f(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x60(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%eax
jne    1302 <find_exes+0x162>
mov    -0x48(%rbp),%eax
mov    0x2cff(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12fd <find_exes+0x15d>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1302 <find_exes+0x162>
jmp    1307 <find_exes+0x167>
jmp    1260 <find_exes+0xc0>
mov    -0x20(%rbp),%rdi
call   1060 <rewinddir@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <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    1382 <find_exes+0x1e2>
mov    0x2c89(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <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    1344 <find_exes+0x1a4>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
movl   $0x0,-0x50(%rbp)
mov    -0x58(%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    13bf <find_exes+0x21f>
jmp    145f <find_exes+0x2bf>
cmpq   $0x0,-0x28(%rbp)
jne    13cf <find_exes+0x22f>
jmp    145f <find_exes+0x2bf>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2bf3(%rip),%rcx
cmp    (%rcx),%rax
jne    145a <find_exes+0x2ba>
mov    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xc26(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x60(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%eax
jne    1455 <find_exes+0x2b5>
mov    -0x48(%rbp),%eax
mov    0x2bc6(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1450 <find_exes+0x2b0>
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    1455 <find_exes+0x2b5>
jmp    145a <find_exes+0x2ba>
jmp    1399 <find_exes+0x1f9>
mov    -0x20(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x4c(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_exes>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,-0x48(%rbp)
mov    %rdi,%r15
mov    %rsp,%r12
movq   $0x0,-0x30(%rbp)
mov    0x2e16(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
movslq (%rcx),%rax
mov    %rsp,%r13
add    $0x1f,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
call   1050 <opendir@plt>
test   %rax,%rax
je     140f <find_exes+0x26f>
mov    %rax,%r14
lea    -0x30(%rbp),%rdx
mov    %rax,%rdi
mov    %r13,-0x50(%rbp)
mov    %r13,%rsi
call   1040 <readdir_r@plt>
xor    %ecx,%ecx
mov    %rcx,-0x38(%rbp)
test   %eax,%eax
mov    %r12,-0x60(%rbp)
jne    12bc <find_exes+0x11c>
mov    -0x30(%rbp),%rax
test   %rax,%rax
je     12bc <find_exes+0x11c>
xor    %ecx,%ecx
mov    %rcx,-0x38(%rbp)
mov    0x2d8f(%rip),%r13
lea    -0x30(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rax),%rcx
cmp    0x0(%r13),%rcx
jne    12a0 <find_exes+0x100>
mov    0x8(%rax),%rcx
mov    %rbx,%rdi
lea    0xdbc(%rip),%rsi
mov    %r15,%rdx
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
lea    -0x40(%rbp),%rsi
call   1090 <stat@plt>
test   %eax,%eax
jne    12a0 <find_exes+0x100>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
and    -0x40(%rbp),%eax
cmp    $0x1,%eax
mov    -0x38(%rbp),%rax
sbb    $0xffffffff,%eax
mov    %rax,-0x38(%rbp)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    -0x50(%rbp),%rsi
mov    %r12,%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
jne    12bc <find_exes+0x11c>
mov    -0x30(%rbp),%rax
test   %rax,%rax
jne    1250 <find_exes+0xb0>
mov    %rbx,-0x58(%rbp)
mov    %r15,-0x68(%rbp)
mov    %r14,%rdi
call   1060 <rewinddir@plt>
mov    -0x38(%rbp),%rbx
lea    0x8(,%rbx,8),%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    -0x48(%rbp),%rax
mov    %r13,(%rax)
test   %ebx,%ebx
jle    1315 <find_exes+0x175>
mov    0x2cef(%rip),%rax
mov    (%rax),%ebx
mov    -0x38(%rbp),%r15d
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   10a0 <malloc@plt>
mov    %rax,0x0(%r13,%r12,8)
add    $0x1,%r12
cmp    %r12,%r15
jne    1300 <find_exes+0x160>
movslq -0x38(%rbp),%rax
movq   $0x0,0x0(%r13,%rax,8)
lea    -0x30(%rbp),%rdx
mov    %r14,%rdi
mov    -0x50(%rbp),%rsi
call   1040 <readdir_r@plt>
test   %eax,%eax
mov    -0x68(%rbp),%r15
mov    -0x58(%rbp),%rbx
jne    13f0 <find_exes+0x250>
mov    -0x30(%rbp),%rax
test   %rax,%rax
je     13f0 <find_exes+0x250>
movl   $0x0,-0x48(%rbp)
lea    -0x30(%rbp),%r12
nopw   0x0(%rax,%rax,1)
mov    (%rax),%rcx
mov    0x2c66(%rip),%rdx
cmp    (%rdx),%rcx
jne    13d0 <find_exes+0x230>
mov    0x8(%rax),%rcx
mov    %rbx,%rdi
lea    0xca6(%rip),%rsi
mov    %r15,%rdx
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
lea    -0x40(%rbp),%rsi
call   1090 <stat@plt>
test   %eax,%eax
jne    13d0 <find_exes+0x230>
mov    0x2c4c(%rip),%rax
mov    (%rax),%eax
test   %eax,-0x40(%rbp)
je     13d0 <find_exes+0x230>
mov    -0x48(%rbp),%ecx
movslq %ecx,%rax
add    $0x1,%ecx
mov    %ecx,-0x48(%rbp)
mov    0x0(%r13,%rax,8),%rdi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    -0x50(%rbp),%rsi
mov    %r12,%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
jne    13f0 <find_exes+0x250>
mov    -0x30(%rbp),%rax
test   %rax,%rax
jne    1360 <find_exes+0x1c0>
mov    %r14,%rdi
call   1070 <closedir@plt>
mov    -0x60(%rbp),%rsp
mov    -0x38(%rbp),%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
mov    %r15,%rdx
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
%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 = [6 x i8] c"%s/%s\00"
@S_IXOTH = global i32 0
define i32 @find_exes(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
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
%14 = load i32, i32* @MAXPATHLEN
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %8
%17 = alloca i8, i64 %15
store i64 %15, i64* %9
%18 = load i32, i32* @MAXPATHLEN
%19 = sext i32 %18 to i64
%20 = add i64 16, %19
%21 = alloca i8, i64 %20
store i64 %20, i64* %10
store i32 0, i32* %12
%22 = load i8*, i8** %3
%23 = call i32* @opendir(i8* %22)
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %31, label %26
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %3
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %2
store i32 0, i32* %12
br label %32
32: ; preds = %67, %31
%33 = load i32*, i32** %6
%34 = bitcast i8* %21 to %struct.dirent*
%35 = call i32 @readdir_r(i32* %33, %struct.dirent* %34, %struct.dirent** %7)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %68
38: ; preds = %32
%39 = load %struct.dirent*, %struct.dirent** %7
%40 = icmp ne %struct.dirent* %39, null
br i1 %40, label %42, label %41
41: ; preds = %38
br label %68
42: ; preds = %38
%43 = load %struct.dirent*, %struct.dirent** %7
%44 = getelementptr inbounds %struct.dirent, %struct.dirent* %43, i32 0, i32 0
%45 = load i64, i64* %44
%46 = load i64, i64* @DT_REG
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %67
48: ; preds = %42
%49 = load i8*, i8** %3
%50 = load %struct.dirent*, %struct.dirent** %7
%51 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i32 0, i32 1
%52 = load i8*, i8** %51
%53 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %49, i8* %52)
%54 = call i32 @stat(i8* %17, %struct.stat* %11)
%55 = icmp ne i32 %54, 0
br i1 %55, label %66, label %56
56: ; preds = %48
%57 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%58 = load i32, i32* %57
%59 = load i32, i32* @S_IXOTH
%60 = and i32 %58, %59
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %56
%63 = load i32, i32* %12
%64 = add nsw i32 %63, 1
store i32 %64, i32* %12
br label %65
65: ; preds = %62, %56
br label %66
66: ; preds = %65, %48
br label %67
67: ; preds = %66, %42
br label %32
68: ; preds = %41, %32
%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 = %146, %98
%104 = load i32*, i32** %6
%105 = bitcast i8* %21 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 %147
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 %147
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 %146
119: ; preds = %113
%120 = load i8*, i8** %3
%121 = load %struct.dirent*, %struct.dirent** %7
%122 = getelementptr inbounds %struct.dirent, %struct.dirent* %121, i32 0, i32 1
%123 = load i8*, i8** %122
%124 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %120, i8* %123)
%125 = call i32 @stat(i8* %17, %struct.stat* %11)
%126 = icmp ne i32 %125, 0
br i1 %126, label %145, label %127
127: ; preds = %119
%128 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%129 = load i32, i32* %128
%130 = load i32, i32* @S_IXOTH
%131 = and i32 %129, %130
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %144
133: ; preds = %127
%134 = load i8**, i8*** %5
%135 = load i32, i32* %13
%136 = add nsw i32 %135, 1
store i32 %136, i32* %13
%137 = sext i32 %135 to i64
%138 = getelementptr inbounds i8*, i8** %134, i64 %137
%139 = load i8*, i8** %138
%140 = load %struct.dirent*, %struct.dirent** %7
%141 = getelementptr inbounds %struct.dirent, %struct.dirent* %140, i32 0, i32 1
%142 = load i8*, i8** %141
%143 = call i32 @strcpy(i8* %139, i8* %142)
br label %144
144: ; preds = %133, %127
br label %145
145: ; preds = %144, %119
br label %146
146: ; preds = %145, %113
br label %103
147: ; preds = %112, %103
%148 = load i32*, i32** %6
%149 = call i32 @closedir(i32* %148)
%150 = load i32, i32* %12
%151 = load i8*, i8** %8
ret i32 %150
}

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