#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;
};
typedef int /*<<< orphan*/ exist;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, scalar_t__);
int read_directory(char *d, int nbFiles, int count) {
  DIR *dir;
  int ret;
  struct dirent *file;
  unsigned char exist[80];
  unsigned char subdir;
  int number;
  int i;
  char *pt;
  memset(exist, 0, sizeof(exist));
  subdir = 0;
  dir = opendir(".");
  if (dir == NULL) {
    printf("Can not open directory at level %d %s\n", count, strerror(errno));
    return -1;
  }
  ret = 0;
  while (1) {
    file = readdir(dir);
    if (file == NULL)
      break;
    if (strcmp(file->d_name, "..") == 0)
      continue;
    if (strcmp(file->d_name, ".") == 0)
      continue;
    if (strcmp(file->d_name, d) == 0) {
      subdir = 1;
      continue;
    }
    if (strncmp(
            file->d_name,
            "This_is_a_pretty_long_base_file_name_in_order_to_trigger_readdir_"
            "not_just_in_one_exchange_with_the_export_but_in_several_runs_"
            "toward_the_export______This_should_make_this_test_a_better_test_",
            strlen("This_is_a_pretty_long_base_file_name_in_order_to_trigger_"
                   "readdir_not_just_in_one_exchange_with_the_export_but_in_"
                   "several_runs_toward_the_export______This_should_make_this_"
                   "test_a_better_test_")) != 0) {
      printf("%s found in directory level %d\n", file->d_name, count);
      ret = -1;
      break;
    }
    pt = file->d_name;
    pt += strlen(
        "This_is_a_pretty_long_base_file_name_in_order_to_trigger_readdir_not_"
        "just_in_one_exchange_with_the_export_but_in_several_runs_toward_the_"
        "export______This_should_make_this_test_a_better_test_");
    ret = sscanf(pt, "%d", &number);
    if (ret != 1) {
      printf("%s found in directory level %d\n", file->d_name, count);
      ret = -1;
      break;
    }
    if (number >= nbFiles) {
      printf("%s found in directory level %d\n", file->d_name, count);
      ret = -1;
      break;
    }
    if (exist[number] != 0) {
      printf("%s already found in directory level %d\n", file->d_name, count);
      ret = -1;
      break;
    }
    exist[number] = 1;
  }
  for (i = 0; i < nbFiles; i++) {
    if (exist[i] != 1) {
      printf("file %d is missing in directory level %d\n", i, count);
      ret = -1;
    }
  }
  for (i; i < 80; i++) {
    if (exist[i] != 0) {
      printf("file %d exist in directory level %d\n", i, count);
      ret = -1;
    }
  }
  if (subdir == 0) {
    printf("subdir %s is missing in directory level %d\n", d, count);
    ret = -1;
  }
  closedir(dir);
  return ret;
}


x86 assembly (clang, -O0):
<read_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1070 <memset@plt>
movb   $0x0,-0x81(%rbp)
lea    0xe55(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1221 <read_directory+0x81>
mov    -0x18(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x9c(%rbp),%esi
mov    %rax,%rdx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f6 <read_directory+0x356>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1245 <read_directory+0xa5>
jmp    13fd <read_directory+0x25d>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1267 <read_directory+0xc7>
jmp    1228 <read_directory+0x88>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb3(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1289 <read_directory+0xe9>
jmp    1228 <read_directory+0x88>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12af <read_directory+0x10f>
movb   $0x1,-0x81(%rbp)
jmp    1228 <read_directory+0x88>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
lea    0xd66(%rip),%rdi
call   1050 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %rax,%rdx
lea    0xd50(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     130d <read_directory+0x16d>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    13fd <read_directory+0x25d>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x98(%rbp)
lea    0xd08(%rip),%rdi
call   1050 <strlen@plt>
add    -0x98(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xdc6(%rip),%rsi
lea    -0x88(%rbp),%rdx
call   10b0 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
je     1380 <read_directory+0x1e0>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    13fd <read_directory+0x25d>
mov    -0x88(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     13b3 <read_directory+0x213>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    13fd <read_directory+0x25d>
movslq -0x88(%rbp),%rax
movzbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     13ec <read_directory+0x24c>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    13fd <read_directory+0x25d>
movslq -0x88(%rbp),%rax
movb   $0x1,-0x80(%rbp,%rax,1)
jmp    1228 <read_directory+0x88>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1462 <read_directory+0x2c2>
movslq -0x8c(%rbp),%rax
movzbl -0x80(%rbp,%rax,1),%eax
cmp    $0x1,%eax
je     1449 <read_directory+0x2a9>
mov    -0x8c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    144e <read_directory+0x2ae>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1407 <read_directory+0x267>
cmpl   $0x50,-0x8c(%rbp)
jge    14bb <read_directory+0x31b>
movslq -0x8c(%rbp),%rax
movzbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     14a2 <read_directory+0x302>
mov    -0x8c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    14a7 <read_directory+0x307>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1462 <read_directory+0x2c2>
movzbl -0x81(%rbp),%eax
cmp    $0x0,%eax
jne    14e7 <read_directory+0x347>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_directory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x10(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    0xe69(%rip),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     133b <read_directory+0x1ab>
mov    %rax,%r14
mov    %ebx,0x8(%rsp)
mov    %ebp,0x4(%rsp)
mov    %ebp,%eax
mov    %rax,0x18(%rsp)
xor    %r12d,%r12d
lea    0xe3e(%rip),%r13
lea    0xe38(%rip),%rbx
xor    %ecx,%ecx
mov    %ecx,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1090 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
je     12ba <read_directory+0x12a>
mov    (%r15),%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1200 <read_directory+0x70>
mov    (%r15),%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1200 <read_directory+0x70>
mov    (%r15),%rdi
mov    0x10(%rsp),%rsi
call   1080 <strcmp@plt>
mov    $0x1,%cl
test   %rax,%rax
jne    124c <read_directory+0xbc>
mov    %ecx,%ebp
jmp    1200 <read_directory+0x70>
mov    (%r15),%rdi
mov    $0xbe,%edx
lea    0xdcf(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
jne    13bb <read_directory+0x22b>
mov    (%r15),%rdi
mov    $0xbe,%eax
add    %rax,%rdi
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    13bb <read_directory+0x22b>
movslq 0xc(%rsp),%rax
cmp    0x4(%rsp),%eax
jge    13bb <read_directory+0x22b>
cmpb   $0x0,0x20(%rsp,%rax,1)
jne    13c9 <read_directory+0x239>
movb   $0x1,0x20(%rsp,%rax,1)
mov    $0x1,%r12d
mov    %ebp,%ecx
jmp    1200 <read_directory+0x70>
mov    %bpl,0x3(%rsp)
mov    0x8(%rsp),%ebp
mov    0x4(%rsp),%r13d
test   %r13d,%r13d
jle    1374 <read_directory+0x1e4>
lea    0xe5c(%rip),%r15
xor    %ebx,%ebx
jmp    12eb <read_directory+0x15b>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,0x18(%rsp)
je     1308 <read_directory+0x178>
cmpb   $0x1,0x20(%rsp,%rbx,1)
je     12e0 <read_directory+0x150>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r12d
jmp    12e0 <read_directory+0x150>
cmpl   $0x4f,0x18(%rsp)
jbe    1377 <read_directory+0x1e7>
cmpb   $0x0,0x3(%rsp)
jne    1331 <read_directory+0x1a1>
lea    0xe66(%rip),%rdi
mov    0x10(%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r12d
mov    %r14,%rdi
call   1070 <closedir@plt>
jmp    1362 <read_directory+0x1d2>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xcb0(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
mov    %r13d,%ebx
lea    0xddd(%rip),%r15
jmp    139e <read_directory+0x20e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x50,%rbx
je     130f <read_directory+0x17f>
cmpb   $0x0,0x20(%rsp,%rbx,1)
je     1390 <read_directory+0x200>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r12d
jmp    1390 <read_directory+0x200>
mov    %bpl,0x3(%rsp)
lea    0xd22(%rip),%rdi
jmp    13d5 <read_directory+0x245>
mov    %bpl,0x3(%rsp)
lea    0xd37(%rip),%rdi
mov    (%r15),%rsi
mov    0x8(%rsp),%ebp
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r12d
jmp    12c3 <read_directory+0x133>

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

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c".\00"
@.str.1 = [39 x i8] c"Can not open directory at level %d %s\0A\00"
@errno = global i32 0
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [191 x i8] c"This_is_a_pretty_long_base_file_name_in_order_to_trigger_readdir_not_just_in_one_exchange_with_the_export_but_in_several_runs_toward_the_export______This_should_make_this_test_a_better_test_\00"
@.str.4 = [32 x i8] c"%s found in directory level %d\0A\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [40 x i8] c"%s already found in directory level %d\0A\00"
@.str.7 = [42 x i8] c"file %d is missing in directory level %d\0A\00"
@.str.8 = [37 x i8] c"file %d exist in directory level %d\0A\00"
@.str.9 = [44 x i8] c"subdir %s is missing in directory level %d\0A\00"
define i32 @read_directory(i8* %0, i32 %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = call i32 @memset(i8* %6, i32 0, i32 80)
%9 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %54
11: ; preds = %3
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %13)
br label %106
15: ; preds = %32, %21
%16 = phi %struct.dirent* [ %22, %21 ], [ %34, %32 ]
%17 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15, %24
%22 = call %struct.dirent* @readdir(i32* %9)
%23 = icmp eq %struct.dirent* %22, null
br i1 %23, label %61, label %15
24: ; preds = %15
%25 = load i8*, i8** %17
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %21, label %28
28: ; preds = %24
%29 = load i8*, i8** %17
%30 = call i64 @strcmp(i8* %29, i8* %0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %54, %28
%33 = phi i8 [ %56, %54 ], [ 1, %28 ]
%34 = call %struct.dirent* @readdir(i32* %9)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %61, label %15
36: ; preds = %28
%37 = load i8*, i8** %17
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([191 x i8], [191 x i8]* @.str.3, i64 0, i64 0), i64 190)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %57
40: ; preds = %36
%41 = load i8*, i8** %17
%42 = getelementptr inbounds i8, i8* %41, i64 190
%43 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %57
45: ; preds = %40
%46 = load i32, i32* %5
%47 = icmp slt i32 %46, %1
br i1 %47, label %48, label %57
48: ; preds = %45
%49 = sext i32 %46 to i64
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
store i8 1, i8* %50
br label %54
54: ; preds = %3, %53
%55 = phi i32 [ 1, %53 ], [ 0, %3 ]
%56 = phi i8 [ %33, %53 ], [ 0, %3 ]
br label %32
57: ; preds = %48, %45, %40, %36
%58 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), %36 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), %40 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), %45 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), %48 ]
%59 = load i8*, i8** %17
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %58, i8* %59, i32 %2)
br label %61
61: ; preds = %32, %21, %57
%62 = phi i32 [ -1, %57 ], [ %55, %21 ], [ %55, %32 ]
%63 = icmp sgt i32 %1, 0
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = zext i32 %1 to i64
br label %72
66: ; preds = %81
%67 = icmp ult i32 %1, 80
br i1 %67, label %68, label %98
68: ; preds = %61, %66
%69 = phi i32 [ %1, %66 ], [ 0, %61 ]
%70 = phi i32 [ %82, %66 ], [ %62, %61 ]
%71 = zext i32 %69 to i64
br label %85
72: ; preds = %64, %81
%73 = phi i64 [ 0, %64 ], [ %83, %81 ]
%74 = phi i32 [ %62, %64 ], [ %82, %81 ]
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %73
%76 = load i8, i8* %75
%77 = icmp eq i8 %76, 1
br i1 %77, label %81, label %78
78: ; preds = %72
%79 = trunc i64 %73 to i32
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %79, i32 %2)
br label %81
81: ; preds = %72, %78
%82 = phi i32 [ -1, %78 ], [ %74, %72 ]
%83 = add nuw nsw i64 %73, 1
%84 = icmp eq i64 %83, %65
br i1 %84, label %66, label %72
85: ; preds = %68, %94
%86 = phi i64 [ %71, %68 ], [ %96, %94 ]
%87 = phi i32 [ %70, %68 ], [ %95, %94 ]
%88 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %86
%89 = load i8, i8* %88
%90 = icmp eq i8 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %85
%92 = trunc i64 %86 to i32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %92, i32 %2)
br label %94
94: ; preds = %85, %91
%95 = phi i32 [ -1, %91 ], [ %87, %85 ]
%96 = add nuw nsw i64 %86, 1
%97 = icmp eq i64 %96, 80
br i1 %97, label %98, label %85
98: ; preds = %94, %66
%99 = phi i32 [ %82, %66 ], [ %95, %94 ]
%100 = icmp eq i8 %33, 0
br i1 %100, label %101, label %103
101: ; preds = %98
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i8* %0, i32 %2)
br label %103
103: ; preds = %101, %98
%104 = phi i32 [ -1, %101 ], [ %99, %98 ]
%105 = call i32 @closedir(i32* %9)
br label %106
106: ; preds = %103, %11
%107 = phi i32 [ -1, %11 ], [ %104, %103 ]
ret i32 %107
}