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

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_REG;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int ls(char *base) {
  DIR *thingy = opendir(base);
  struct dirent *newfile;
  char buf[1024] = {0};
  while ((newfile = readdir(thingy)) != NULL) {
    int flag = 0;
    if (newfile->d_type == DT_REG) {
      if (!strcmp(base, "./")) {
        sprintf(buf, "%s%s", base, newfile->d_name);
      } else {
        sprintf(buf, "%s/%s", base, newfile->d_name);
      }
      printf(" %s", buf);
      int checkFD = open(buf, O_RDONLY);
      if (!checkFD) {
        return -1;
      }
      int len = lseek(checkFD, 0, SEEK_END);
      close(checkFD);
      printf("    %d\n", len);
    } else if (newfile->d_type == DT_DIR) {
      if (!strcmp(newfile->d_name, ".")) {
        flag = 1;
      }
      if (!strcmp(newfile->d_name, "..")) {
        flag = 1;
      }
      if (!strcmp(base, "./")) {
        sprintf(buf, "%s", newfile->d_name);
      } else {
        sprintf(buf, "%s/%s", base, newfile->d_name);
      }
      printf(" %s/\n", buf);
      if (flag != 1) {
        ls(buf);
      }
    } else {
      return 0;
    }
  }
  closedir(thingy);
  return 1;
}


x86 assembly (clang, -O0):
<ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     140a <ls+0x25a>
movl   $0x0,-0x424(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2dc2(%rip),%rcx
cmp    (%rcx),%rax
jne    1300 <ls+0x150>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1256 <ls+0xa6>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1277 <ls+0xc7>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
lea    -0x420(%rbp),%rsi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x428(%rbp)
cmpl   $0x0,-0x428(%rbp)
jne    12c0 <ls+0x110>
movl   $0xffffffff,-0x4(%rbp)
jmp    141a <ls+0x26a>
mov    -0x428(%rbp),%edi
mov    0x2d1b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x428(%rbp),%edi
call   1080 <close@plt>
mov    -0x42c(%rbp),%esi
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1405 <ls+0x255>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2cba(%rip),%rcx
cmp    (%rcx),%rax
jne    13f4 <ls+0x244>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcf5(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    133e <ls+0x18e>
movl   $0x1,-0x424(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xccd(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1365 <ls+0x1b5>
movl   $0x1,-0x424(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xc90(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    13a0 <ls+0x1f0>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc7b(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    13c1 <ls+0x211>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
lea    -0x420(%rbp),%rsi
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x424(%rbp)
je     13ef <ls+0x23f>
lea    -0x420(%rbp),%rdi
call   1070 <ls@plt>
jmp    1400 <ls+0x250>
movl   $0x0,-0x4(%rbp)
jmp    141a <ls+0x26a>
jmp    1405 <ls+0x255>
jmp    11df <ls+0x2f>
mov    -0x18(%rbp),%rdi
call   1090 <closedir@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r12
call   1040 <opendir@plt>
mov    %rax,%r13
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    %r13,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1386 <ls+0x1c6>
mov    %rax,%rbp
mov    0x2dc8(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %r12,0x8(%rsp)
jmp    1234 <ls+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1386 <ls+0x1c6>
mov    0x0(%rbp),%rax
cmp    (%r14),%rax
jne    12e0 <ls+0x120>
mov    %r12,%rdi
lea    0xdb5(%rip),%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
mov    0x8(%rbp),%rcx
lea    0xdab(%rip),%rsi
lea    0xd9f(%rip),%rax
cmove  %rax,%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10e0 <sprintf@plt>
lea    0xd92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10d0 <open@plt>
test   %eax,%eax
je     1395 <ls+0x1d5>
mov    %eax,%ebp
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xd4e(%rip),%rdi
mov    %r12d,%esi
mov    0x8(%rsp),%r12
lea    0x10(%rsp),%rbx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1220 <ls+0x60>
nopl   (%rax)
mov    0x2ce1(%rip),%rcx
cmp    (%rcx),%rax
jne    139c <ls+0x1dc>
mov    0x8(%rbp),%rbp
mov    %rbp,%rdi
lea    0xd1d(%rip),%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
sete   %r12b
mov    %rbp,%rdi
lea    0xd07(%rip),%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
sete   %r15b
or     %r12b,%r15b
mov    0x8(%rsp),%r12
mov    %r12,%rdi
lea    0xcd0(%rip),%rsi
call   10b0 <strcmp@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
test   %eax,%eax
je     1357 <ls+0x197>
lea    0xcc0(%rip),%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   10e0 <sprintf@plt>
jmp    135f <ls+0x19f>
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xcb7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15b,%r15b
jne    1220 <ls+0x60>
mov    %rbx,%rdi
call   1080 <ls@plt>
jmp    1220 <ls+0x60>
mov    %r13,%rdi
call   10a0 <closedir@plt>
mov    $0x1,%eax
jmp    139e <ls+0x1de>
mov    $0xffffffff,%eax
jmp    139e <ls+0x1de>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@DT_REG = global i64 0
@.str = [3 x i8] c"./\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [4 x i8] c" %s\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@.str.4 = [8 x i8] c" %d\0A\00"
@DT_DIR = global i64 0
@.str.5 = [2 x i8] c".\00"
@.str.6 = [3 x i8] c"..\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [6 x i8] c" %s/\0A\00"
define i32 @ls(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.dirent*
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i32* @opendir(i8* %10)
store i32* %11, i32** %4
%12 = bitcast [1024 x i8]* %6 to i8*
br label %13
13: ; preds = %106, %1
%14 = load i32*, i32** %4
%15 = call %struct.dirent* @readdir(i32* %14)
store %struct.dirent* %15, %struct.dirent** %5
%16 = icmp ne %struct.dirent* %15, null
br i1 %16, label %17, label %107
17: ; preds = %13
store i32 0, i32* %7
%18 = load %struct.dirent*, %struct.dirent** %5
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = load i64, i64* @DT_REG
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %58
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %23
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %3
%30 = load %struct.dirent*, %struct.dirent** %5
%31 = getelementptr inbounds %struct.dirent, %struct.dirent* %30, i32 0, i32 1
%32 = load i8*, i8** %31
%33 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %32)
br label %41
34: ; preds = %23
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%36 = load i8*, i8** %3
%37 = load %struct.dirent*, %struct.dirent** %5
%38 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i32 0, i32 1
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %39)
br label %41
41: ; preds = %34, %27
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%45 = load i32, i32* @O_RDONLY
%46 = call i32 @open(i8* %44, i32 %45)
store i32 %46, i32* %8
%47 = load i32, i32* %8
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %41
store i32 -1, i32* %2
br label %110
50: ; preds = %41
%51 = load i32, i32* %8
%52 = load i32, i32* @SEEK_END
%53 = call i32 @lseek(i32 %51, i32 0, i32 %52)
store i32 %53, i32* %9
%54 = load i32, i32* %8
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* %9
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %56)
br label %106
58: ; preds = %17
%59 = load %struct.dirent*, %struct.dirent** %5
%60 = getelementptr inbounds %struct.dirent, %struct.dirent* %59, i32 0, i32 0
%61 = load i64, i64* %60
%62 = load i64, i64* @DT_DIR
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %104
64: ; preds = %58
%65 = load %struct.dirent*, %struct.dirent** %5
%66 = getelementptr inbounds %struct.dirent, %struct.dirent* %65, i32 0, i32 1
%67 = load i8*, i8** %66
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %64
store i32 1, i32* %7
br label %71
71: ; preds = %70, %64
%72 = load %struct.dirent*, %struct.dirent** %5
%73 = getelementptr inbounds %struct.dirent, %struct.dirent* %72, i32 0, i32 1
%74 = load i8*, i8** %73
%75 = call i32 @strcmp(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %71
store i32 1, i32* %7
br label %78
78: ; preds = %77, %71
%79 = load i8*, i8** %3
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %88, label %82
82: ; preds = %78
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%84 = load %struct.dirent*, %struct.dirent** %5
%85 = getelementptr inbounds %struct.dirent, %struct.dirent* %84, i32 0, i32 1
%86 = load i8*, i8** %85
%87 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %86)
br label %95
88: ; preds = %78
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%90 = load i8*, i8** %3
%91 = load %struct.dirent*, %struct.dirent** %5
%92 = getelementptr inbounds %struct.dirent, %struct.dirent* %91, i32 0, i32 1
%93 = load i8*, i8** %92
%94 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %89, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %90, i8* %93)
br label %95
95: ; preds = %88, %82
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %96)
%98 = load i32, i32* %7
%99 = icmp ne i32 %98, 1
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%102 = call i32 @ls(i8* %101)
br label %103
103: ; preds = %100, %95
br label %105
104: ; preds = %58
store i32 0, i32* %2
br label %110
105: ; preds = %103
br label %106
106: ; preds = %105, %50
br label %13
107: ; preds = %13
%108 = load i32*, i32** %4
%109 = call i32 @closedir(i32* %108)
store i32 1, i32* %2
br label %110
110: ; preds = %107, %104, %49
%111 = load i32, i32* %2
ret i32 %111
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@DT_REG = global i64 0
@.str = [3 x i8] c"./\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [4 x i8] c" %s\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@.str.4 = [8 x i8] c" %d\0A\00"
@DT_DIR = global i64 0
@.str.5 = [2 x i8] c".\00"
@.str.6 = [3 x i8] c"..\00"
@.str.8 = [6 x i8] c" %s/\0A\00"
define i32 @ls(i8* %0) {
%2 = alloca [1024 x i8]
%3 = tail call i32* @opendir(i8* %0)
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call %struct.dirent* @readdir(i32* %3)
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %53, label %7
7: ; preds = %1, %50
%8 = phi %struct.dirent* [ %51, %50 ], [ %5, %1 ]
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @DT_REG
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %7
%14 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = select i1 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) %18, i8* %0, i8* %17)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %4, i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %55, label %24
24: ; preds = %13
%25 = load i32, i32* @SEEK_END
%26 = call i32 @lseek(i32 %22, i32 0, i32 %25)
%27 = call i32 @close(i32 %22)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %50
29: ; preds = %7
%30 = load i64, i64* @DT_DIR
%31 = icmp eq i64 %10, %30
br i1 %31, label %32, label %55
32: ; preds = %29
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 1
%34 = load i8*, i8** %33
%35 = call i32 @strcmp(i8* dereferenceable(1) %34, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
%37 = call i32 @strcmp(i8* dereferenceable(1) %34, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
%39 = select i1 %38, i1 true, i1 %36
%40 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %32
%43 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %34)
br label %46
44: ; preds = %32
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %34)
br label %46
46: ; preds = %44, %42
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br i1 %39, label %50, label %48
48: ; preds = %46
%49 = call i32 @ls(i8* %4)
br label %50
50: ; preds = %46, %48, %24
%51 = call %struct.dirent* @readdir(i32* %3)
%52 = icmp eq %struct.dirent* %51, null
br i1 %52, label %53, label %7
53: ; preds = %50, %1
%54 = call i32 @closedir(i32* %3)
br label %55
55: ; preds = %13, %29, %53
%56 = phi i32 [ 1, %53 ], [ -1, %13 ], [ 0, %29 ]
ret i32 %56
}