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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(int);
int chdir(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
void test_chdir(void) {
  DIR *dir = opendir("tests/1");
  assert(dir != NULL);
  struct dirent *ent;
  int found = 0;
  while ((ent = readdir(dir)) != NULL) {
    if (strcmp(ent->d_name, ".") == 0) {
      found += 1;
    } else if (strcmp(ent->d_name, "..") == 0) {
      found += 2;
    } else if (strcmp(ent->d_name, "file") == 0) {
      found += 4;
    } else if (strcmp(ent->d_name, "dir") == 0) {
      found += 8;
    } else {
      fprintf(stderr, "Unexpected file %s\n", ent->d_name);
      abort();
    }
  }
  assert(found == 0xf);
  int errorcode = chdir("tests");
  assert(errorcode == 0);
  rewinddir(dir);
  found = 0;
  while ((ent = readdir(dir)) != NULL) {
    if (strcmp(ent->d_name, ".") == 0) {
      found += 1;
    } else if (strcmp(ent->d_name, "..") == 0) {
      found += 2;
    } else if (strcmp(ent->d_name, "file") == 0) {
      found += 4;
    } else if (strcmp(ent->d_name, "dir") == 0) {
      found += 8;
    } else {
      fprintf(stderr, "Unexpected file %s\n", ent->d_name);
      abort();
    }
  }
  assert(found == 0xf);
  errorcode = chdir("..");
  assert(errorcode == 0);
  closedir(dir);
}


x86 assembly (clang, -O0):
<test_chdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe61(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12bb <test_chdir+0x12b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe23(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <test_chdir+0x73>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12b6 <test_chdir+0x126>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf7(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    122e <test_chdir+0x9e>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    12b1 <test_chdir+0x121>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdcf(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1259 <test_chdir+0xc9>
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    12ac <test_chdir+0x11c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xda9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1284 <test_chdir+0xf4>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    12a7 <test_chdir+0x117>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd79(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12ac <test_chdir+0x11c>
jmp    12b1 <test_chdir+0x121>
jmp    12b6 <test_chdir+0x126>
jmp    11c1 <test_chdir+0x31>
cmpl   $0xf,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xd55(%rip),%rdi
call   1050 <chdir@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1060 <rewinddir@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     13f6 <test_chdir+0x266>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xce8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    133e <test_chdir+0x1ae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13f1 <test_chdir+0x261>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xcbc(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1369 <test_chdir+0x1d9>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    13ec <test_chdir+0x25c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xc94(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1394 <test_chdir+0x204>
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    13e7 <test_chdir+0x257>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xc6e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13bf <test_chdir+0x22f>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    13e2 <test_chdir+0x252>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc3e(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    13e7 <test_chdir+0x257>
jmp    13ec <test_chdir+0x25c>
jmp    13f1 <test_chdir+0x261>
jmp    12fc <test_chdir+0x16c>
cmpl   $0xf,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xbfa(%rip),%rdi
call   1050 <chdir@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1070 <closedir@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_chdir>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe5e(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10b0 <readdir@plt>
xor    %r15d,%r15d
mov    $0x0,%edi
test   %rax,%rax
je     127b <test_chdir+0xeb>
mov    %rax,%r14
xor    %r13d,%r13d
lea    0xe2b(%rip),%rbp
lea    0xe23(%rip),%r15
lea    0xe1f(%rip),%r12
jmp    1208 <test_chdir+0x78>
xchg   %ax,%ax
mov    $0x1,%ecx
add    %ecx,%r13d
mov    %rbx,%rdi
call   10b0 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     126e <test_chdir+0xde>
mov    (%r14),%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11f0 <test_chdir+0x60>
mov    (%r14),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1260 <test_chdir+0xd0>
mov    (%r14),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1267 <test_chdir+0xd7>
mov    (%r14),%rdi
lea    0xdce(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     11f5 <test_chdir+0x65>
jmp    1390 <test_chdir+0x200>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    11f5 <test_chdir+0x65>
mov    $0x4,%ecx
jmp    11f5 <test_chdir+0x65>
xor    %edi,%edi
cmp    $0xf,%r13d
sete   %dil
xor    %r15d,%r15d
call   1090 <assert@plt>
lea    0xda1(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   1060 <rewinddir@plt>
mov    %rbx,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     1359 <test_chdir+0x1c9>
mov    %rax,%rbp
xor    %r12d,%r12d
lea    0xd4a(%rip),%r13
lea    0xd42(%rip),%r14
lea    0xd3e(%rip),%r15
jmp    12e8 <test_chdir+0x158>
nop
mov    $0x1,%ecx
add    %ecx,%r12d
mov    %rbx,%rdi
call   10b0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     134e <test_chdir+0x1be>
mov    0x0(%rbp),%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12d0 <test_chdir+0x140>
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1340 <test_chdir+0x1b0>
mov    0x0(%rbp),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1347 <test_chdir+0x1b7>
mov    0x0(%rbp),%rdi
lea    0xcea(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     12d5 <test_chdir+0x145>
jmp    139e <test_chdir+0x20e>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    12d5 <test_chdir+0x145>
mov    $0x4,%ecx
jmp    12d5 <test_chdir+0x145>
xor    %r15d,%r15d
cmp    $0xf,%r12d
sete   %r15b
mov    %r15d,%edi
call   1090 <assert@plt>
lea    0xca0(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <closedir@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
jmp    13ab <test_chdir+0x21b>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xc62(%rip),%rsi
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [8 x i8] c"tests/1\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"file\00"
@.str.4 = [4 x i8] c"dir\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Unexpected file %s\0A\00"
@.str.6 = [6 x i8] c"tests\00"
define void @test_chdir() {
%1 = alloca i32*
%2 = alloca %struct.dirent*
%3 = alloca i32
%4 = alloca i32
%5 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = icmp ne i32* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
store i32 0, i32* %3
br label %10
10: ; preds = %60, %0
%11 = load i32*, i32** %1
%12 = call %struct.dirent* @readdir(i32* %11)
store %struct.dirent* %12, %struct.dirent** %2
%13 = icmp ne %struct.dirent* %12, null
br i1 %13, label %14, label %61
14: ; preds = %10
%15 = load %struct.dirent*, %struct.dirent** %2
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %60
23: ; preds = %14
%24 = load %struct.dirent*, %struct.dirent** %2
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 2
store i32 %31, i32* %3
br label %59
32: ; preds = %23
%33 = load %struct.dirent*, %struct.dirent** %2
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 4
store i32 %40, i32* %3
br label %58
41: ; preds = %32
%42 = load %struct.dirent*, %struct.dirent** %2
%43 = getelementptr inbounds %struct.dirent, %struct.dirent* %42, i32 0, i32 0
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 8
store i32 %49, i32* %3
br label %57
50: ; preds = %41
%51 = load i32, i32* @stderr
%52 = load %struct.dirent*, %struct.dirent** %2
%53 = getelementptr inbounds %struct.dirent, %struct.dirent* %52, i32 0, i32 0
%54 = load i8*, i8** %53
%55 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = call i32 (...) @abort()
unreachable
57: ; preds = %47
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %29
br label %60
60: ; preds = %59, %20
br label %10
61: ; preds = %10
%62 = load i32, i32* %3
%63 = icmp eq i32 %62, 15
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 %66, i32* %4
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 0
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = load i32*, i32** %1
%72 = call i32 @rewinddir(i32* %71)
store i32 0, i32* %3
br label %73
73: ; preds = %123, %61
%74 = load i32*, i32** %1
%75 = call %struct.dirent* @readdir(i32* %74)
store %struct.dirent* %75, %struct.dirent** %2
%76 = icmp ne %struct.dirent* %75, null
br i1 %76, label %77, label %124
77: ; preds = %73
%78 = load %struct.dirent*, %struct.dirent** %2
%79 = getelementptr inbounds %struct.dirent, %struct.dirent* %78, i32 0, i32 0
%80 = load i8*, i8** %79
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %77
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 1
store i32 %85, i32* %3
br label %123
86: ; preds = %77
%87 = load %struct.dirent*, %struct.dirent** %2
%88 = getelementptr inbounds %struct.dirent, %struct.dirent* %87, i32 0, i32 0
%89 = load i8*, i8** %88
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %86
%93 = load i32, i32* %3
%94 = add nsw i32 %93, 2
store i32 %94, i32* %3
br label %122
95: ; preds = %86
%96 = load %struct.dirent*, %struct.dirent** %2
%97 = getelementptr inbounds %struct.dirent, %struct.dirent* %96, i32 0, i32 0
%98 = load i8*, i8** %97
%99 = call i64 @strcmp(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %95
%102 = load i32, i32* %3
%103 = add nsw i32 %102, 4
store i32 %103, i32* %3
br label %121
104: ; preds = %95
%105 = load %struct.dirent*, %struct.dirent** %2
%106 = getelementptr inbounds %struct.dirent, %struct.dirent* %105, i32 0, i32 0
%107 = load i8*, i8** %106
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %104
%111 = load i32, i32* %3
%112 = add nsw i32 %111, 8
store i32 %112, i32* %3
br label %120
113: ; preds = %104
%114 = load i32, i32* @stderr
%115 = load %struct.dirent*, %struct.dirent** %2
%116 = getelementptr inbounds %struct.dirent, %struct.dirent* %115, i32 0, i32 0
%117 = load i8*, i8** %116
%118 = call i32 @fprintf(i32 %114, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %117)
%119 = call i32 (...) @abort()
unreachable
120: ; preds = %110
br label %121
121: ; preds = %120, %101
br label %122
122: ; preds = %121, %92
br label %123
123: ; preds = %122, %83
br label %73
124: ; preds = %73
%125 = load i32, i32* %3
%126 = icmp eq i32 %125, 15
%127 = zext i1 %126 to i32
%128 = call i32 @assert(i32 %127)
%129 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %129, i32* %4
%130 = load i32, i32* %4
%131 = icmp eq i32 %130, 0
%132 = zext i1 %131 to i32
%133 = call i32 @assert(i32 %132)
%134 = load i32*, i32** %1
%135 = call i32 @closedir(i32* %134)
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [8 x i8] c"tests/1\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"file\00"
@.str.4 = [4 x i8] c"dir\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Unexpected file %s\0A\00"
@.str.6 = [6 x i8] c"tests\00"
define void @test_chdir() {
%1 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp ne i32* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call %struct.dirent* @readdir(i32* %1)
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %39, label %7
7: ; preds = %0, %31
%8 = phi %struct.dirent* [ %34, %31 ], [ %5, %0 ]
%9 = phi i32 [ %33, %31 ], [ 0, %0 ]
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %31, label %14
14: ; preds = %7
%15 = load i8*, i8** %10
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %14
%19 = load i8*, i8** %10
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %18
%23 = load i8*, i8** %10
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %10
%29 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = tail call i32 (...) @abort()
unreachable
31: ; preds = %22, %18, %14, %7
%32 = phi i32 [ 1, %7 ], [ 2, %14 ], [ 4, %18 ], [ 8, %22 ]
%33 = add nuw nsw i32 %9, %32
%34 = tail call %struct.dirent* @readdir(i32* %1)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %36, label %7
36: ; preds = %31
%37 = icmp eq i32 %33, 15
%38 = zext i1 %37 to i32
br label %39
39: ; preds = %36, %0
%40 = phi i32 [ 0, %0 ], [ %38, %36 ]
%41 = tail call i32 @assert(i32 %40)
%42 = tail call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i32
%45 = tail call i32 @assert(i32 %44)
%46 = tail call i32 @rewinddir(i32* %1)
%47 = tail call %struct.dirent* @readdir(i32* %1)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %81, label %49
49: ; preds = %39, %73
%50 = phi %struct.dirent* [ %76, %73 ], [ %47, %39 ]
%51 = phi i32 [ %75, %73 ], [ 0, %39 ]
%52 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i64 0, i32 0
%53 = load i8*, i8** %52
%54 = tail call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %73, label %56
56: ; preds = %49
%57 = load i8*, i8** %52
%58 = tail call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %73, label %60
60: ; preds = %56
%61 = load i8*, i8** %52
%62 = tail call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %73, label %64
64: ; preds = %60
%65 = load i8*, i8** %52
%66 = tail call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %73, label %68
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %52
%71 = tail call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %70)
%72 = tail call i32 (...) @abort()
unreachable
73: ; preds = %64, %60, %56, %49
%74 = phi i32 [ 1, %49 ], [ 2, %56 ], [ 4, %60 ], [ 8, %64 ]
%75 = add nuw nsw i32 %51, %74
%76 = tail call %struct.dirent* @readdir(i32* %1)
%77 = icmp eq %struct.dirent* %76, null
br i1 %77, label %78, label %49
78: ; preds = %73
%79 = icmp eq i32 %75, 15
%80 = zext i1 %79 to i32
br label %81
81: ; preds = %78, %39
%82 = phi i32 [ 0, %39 ], [ %80, %78 ]
%83 = tail call i32 @assert(i32 %82)
%84 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%85 = icmp eq i32 %84, 0
%86 = zext i1 %85 to i32
%87 = tail call i32 @assert(i32 %86)
%88 = tail call i32 @closedir(i32* %1)
ret void
}