#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*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, int, char *);
int read(int, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int);
int /*<<< orphan*/ v_printf(char *, char *, ...);
int readdirectory(char *dirname, int *dirsread, int *filesread, int *errors) {
  struct dirent *diriter;
  char fn[4096];
  DIR *dir;
  int fd;
  dir = opendir(dirname);
  if (dir == NULL) {
    printf("FAIL: dir is NULL %d %s\n", errno, strerror(errno));
    return -1;
  }
  diriter = readdir(dir);
  while (diriter != NULL) {
    struct stat stbuf;
    v_printf("d_name %s\n", diriter->d_name);
    if (!strcmp(diriter->d_name, ".") || !strcmp(diriter->d_name, "..")) {
      diriter = readdir(dir);
      continue;
    }
    snprintf(fn, 4096, "%s/%s", dirname, diriter->d_name);
    if (stat(fn, &stbuf) == -1) {
      v_printf("stat -1 on %s :: %d %s\n", fn, errno, strerror(errno));
      ++*errors;
      diriter = readdir(dir);
      continue;
    }
    if (S_ISDIR(stbuf.st_mode)) {
      v_printf("directory: %s\n", fn);
      ++*dirsread;
      readdirectory(fn, dirsread, filesread, errors);
    } else {
      int bytes_read;
      char rbuf[1025];
      fd = open(fn, O_RDONLY);
      v_printf("file: %s\n", fn);
      ++*filesread;
      bytes_read = read(fd, rbuf, 1024);
      if (bytes_read < 0) {
        v_printf("read -1 on %s :: %d %s\n", fn, errno, strerror(errno));
      }
      close(fd);
    }
    diriter = readdir(dir);
  }
  closedir(dir);
}


x86 assembly (clang, -O0):
<readdirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1470,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x1038(%rbp)
cmpq   $0x0,-0x1038(%rbp)
jne    1257 <readdirectory+0x77>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1454(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1454(%rbp),%esi
mov    %rax,%rdx
lea    0xdba(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a8 <readdirectory+0x2c8>
mov    -0x1038(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     149c <readdirectory+0x2bc>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   10f0 <v_printf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xd90(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
je     12bf <readdirectory+0xdf>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xd73(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12d4 <readdirectory+0xf4>
mov    -0x1038(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x30(%rbp)
jmp    1267 <readdirectory+0x87>
lea    -0x1030(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8
mov    $0x1000,%esi
lea    0xd35(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x1030(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
jne    137c <readdirectory+0x19c>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1460(%rbp)
mov    0x2cb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1458(%rbp)
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1460(%rbp),%rsi
mov    -0x1458(%rbp),%edx
mov    %rax,%rcx
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   10f0 <v_printf@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x1038(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x30(%rbp)
jmp    1267 <readdirectory+0x87>
mov    -0x1040(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     13ce <readdirectory+0x1ee>
lea    -0x1030(%rbp),%rsi
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   10f0 <v_printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    -0x1030(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   10b0 <readdirectory@plt>
jmp    1487 <readdirectory+0x2a7>
lea    -0x1030(%rbp),%rdi
mov    0x2c0c(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x103c(%rbp)
lea    -0x1030(%rbp),%rsi
lea    0xc5d(%rip),%rdi
mov    $0x0,%al
call   10f0 <v_printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x103c(%rbp),%edi
lea    -0x1450(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0x1044(%rbp)
cmpl   $0x0,-0x1044(%rbp)
jge    147c <readdirectory+0x29c>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1470(%rbp)
mov    0x2b90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1464(%rbp)
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1470(%rbp),%rsi
mov    -0x1464(%rbp),%edx
mov    %rax,%rcx
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   10f0 <v_printf@plt>
mov    -0x103c(%rbp),%edi
call   1070 <close@plt>
mov    -0x1038(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x30(%rbp)
jmp    1267 <readdirectory+0x87>
mov    -0x1038(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x4(%rbp),%eax
add    $0x1470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readdirectory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1448,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x28(%rsp)
call   1030 <opendir@plt>
test   %rax,%rax
je     13a8 <readdirectory+0x1c8>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     139e <readdirectory+0x1be>
mov    %rax,%r12
lea    0xde8(%rip),%r13
lea    0xded(%rip),%r14
lea    0x440(%rsp),%r15
jmp    1284 <readdirectory+0xa4>
mov    0x2d8f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1100 <strerror@plt>
lea    0xdd4(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10f0 <v_printf@plt>
mov    0x18(%rsp),%rax
addl   $0x1,(%rax)
mov    %rbx,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     139e <readdirectory+0x1be>
mov    (%r12),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   10f0 <v_printf@plt>
mov    (%r12),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1270 <readdirectory+0x90>
mov    %rbp,%rdi
lea    0xd75(%rip),%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1270 <readdirectory+0x90>
mov    %r15,%rdi
mov    $0x1000,%esi
lea    0xd60(%rip),%rdx
mov    0x28(%rsp),%rcx
mov    %rbp,%r8
call   1060 <snprintf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
je     1242 <readdirectory+0x62>
mov    0x8(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     1328 <readdirectory+0x148>
lea    0xd46(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10f0 <v_printf@plt>
mov    0x20(%rsp),%rsi
addl   $0x1,(%rsi)
mov    %r15,%rdi
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rcx
call   10b0 <readdirectory@plt>
jmp    1270 <readdirectory+0x90>
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10e0 <open@plt>
mov    %eax,%ebp
lea    0xd12(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10f0 <v_printf@plt>
mov    0x10(%rsp),%rax
addl   $0x1,(%rax)
mov    %ebp,%edi
lea    0x30(%rsp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
jns    1392 <readdirectory+0x1b2>
mov    0x2c68(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,%edi
call   1100 <strerror@plt>
lea    0xcdc(%rip),%rdi
mov    %r15,%rsi
mov    %r12d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10f0 <v_printf@plt>
mov    %ebp,%edi
call   1070 <close@plt>
jmp    1270 <readdirectory+0x90>
mov    %rbx,%rdi
call   1080 <closedir@plt>
jmp    13c9 <readdirectory+0x1e9>
mov    0x2c29(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xc41(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x1448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [25 x i8] c"FAIL: dir is NULL %d %s\0A\00"
@errno = global i32 0
@.str.1 = [11 x i8] c"d_name %s\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [24 x i8] c"stat -1 on %s :: %d %s\0A\00"
@.str.6 = [15 x i8] c"directory: %s\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [10 x i8] c"file: %s\0A\00"
@.str.8 = [24 x i8] c"read -1 on %s :: %d %s\0A\00"
define i32 @readdirectory(i8* %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3) {
%5 = alloca [4096 x i8]
%6 = alloca %struct.stat
%7 = alloca [1025 x i8]
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = tail call i32* @opendir(i8* %0)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
br label %71
15: ; preds = %4
%16 = tail call %struct.dirent* @readdir(i32* %9)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %69, label %18
18: ; preds = %15
%19 = bitcast %struct.stat* %6 to i8*
%20 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%21 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
br label %22
22: ; preds = %18, %66
%23 = phi %struct.dirent* [ %16, %18 ], [ %67, %66 ]
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, i8*, ...) @v_printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %24
%28 = call i32 @strcmp(i8* dereferenceable(1) %27, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %66, label %30
30: ; preds = %22
%31 = call i32 @strcmp(i8* dereferenceable(1) %27, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %66, label %33
33: ; preds = %30
%34 = call i32 @snprintf(i8* %8, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %27)
%35 = call i32 @stat(i8* %8, %struct.stat* %6)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i8*, i8*, ...) @v_printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %8, i32 %38, i8* %39)
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %66
43: ; preds = %33
%44 = load i32, i32* %20
%45 = call i64 @S_ISDIR(i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %43
%48 = call i32 (i8*, i8*, ...) @v_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%49 = load i32, i32* %1
%50 = add nsw i32 %49, 1
store i32 %50, i32* %1
%51 = call i32 @readdirectory(i8* %8, i32* %1, i32* %2, i32* %3)
br label %66
52: ; preds = %43
%53 = load i32, i32* @O_RDONLY
%54 = call i32 @open(i8* %8, i32 %53)
%55 = call i32 (i8*, i8*, ...) @v_printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
%58 = call i32 @read(i32 %54, i8* %21, i32 1024)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %52
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i8*, i8*, ...) @v_printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %8, i32 %61, i8* %62)
br label %64
64: ; preds = %60, %52
%65 = call i32 @close(i32 %54)
br label %66
66: ; preds = %47, %64, %22, %30, %37
%67 = call %struct.dirent* @readdir(i32* %9)
%68 = icmp eq %struct.dirent* %67, null
br i1 %68, label %69, label %22
69: ; preds = %66, %15
%70 = call i32 @closedir(i32* %9)
br label %71
71: ; preds = %69, %11
ret i32 -1
}