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

/* Variables and functions */
int DT_DIR;
int DT_REG;
scalar_t__ EACCES;
scalar_t__ EBADF;
scalar_t__ ENOENT;
scalar_t__ ENOTDIR;
int /*<<< orphan*/ assert(int);
int closedir(int /*<<< orphan*/ *);
scalar_t__ errno;
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ puts(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int readdir_r(int /*<<< orphan*/ *, struct dirent *, struct dirent **);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ seekdir(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int telldir(int /*<<< orphan*/ *);
void test() {
  int err;
  int loc;
  DIR *dir;
  struct dirent *ent;
  struct dirent ent_r;
  struct dirent *result;
  dir = opendir("noexist");
  assert(!dir);
  assert(errno == ENOENT);
  dir = opendir("nocanread");
  assert(!dir);
  assert(errno == EACCES);
  dir = opendir("foobar/file.txt");
  assert(!dir);
  assert(errno == ENOTDIR);
  dir = opendir("foobar");
  closedir(dir);
  ent = readdir(dir);
  assert(!ent);
  assert(errno == EBADF);
  dir = opendir("foobar");
  closedir(dir);
  err = readdir_r(dir, NULL, &result);
  assert(err == EBADF);
  dir = opendir("foobar");
  assert(dir);
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, "."));
  assert(ent->d_type & DT_DIR);
  assert(ent->d_reclen == sizeof(*ent));
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, ".."));
  assert(ent->d_type & DT_DIR);
  assert(ent->d_reclen == sizeof(*ent));
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, "file.txt"));
  assert(ent->d_type & DT_REG);
  assert(ent->d_reclen == sizeof(*ent));
  ent = readdir(dir);
  assert(!ent);
  rewinddir(dir);
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, "."));
  rewinddir(dir);
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, "."));
  loc = telldir(dir);
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, ".."));
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, "file.txt"));
  seekdir(dir, loc);
  ent = readdir(dir);
  assert(!strcmp(ent->d_name, ".."));
  rewinddir(dir);
  err = readdir_r(dir, &ent_r, &result);
  assert(!err);
  assert(&ent_r == result);
  assert(!strcmp(ent_r.d_name, "."));
  err = readdir_r(dir, &ent_r, &result);
  assert(!err);
  assert(&ent_r == result);
  assert(!strcmp(ent_r.d_name, ".."));
  err = readdir_r(dir, &ent_r, &result);
  assert(!err);
  assert(&ent_r == result);
  assert(!strcmp(ent_r.d_name, "file.txt"));
  err = readdir_r(dir, &ent_r, &result);
  assert(!err);
  assert(!result);
  err = closedir(dir);
  assert(!err);
  puts("success");
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe51(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%rax
mov    0x2dcb(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xe14(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%rax
mov    0x2dbe(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xdd9(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%rax
mov    0x2d91(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xda4(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%rax
mov    0x2cf6(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xd49(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
mov    0x2cae(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xd01(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xcda(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2c54(%rip),%rax
and    (%rax),%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
movslq 0x4(%rax),%rax
cmp    $0xc,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xc7a(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2bf5(%rip),%rax
and    (%rax),%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
movslq 0x4(%rax),%rax
cmp    $0xc,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xc0b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2b9e(%rip),%rax
and    (%rax),%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rax
movslq 0x4(%rax),%rax
cmp    $0xc,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <rewinddir@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xb93(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <rewinddir@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xb58(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <telldir@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xb19(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xad7(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <seekdir@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xaa9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <rewinddir@plt>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x20(%rbp),%edi
lea    0xa44(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x20(%rbp),%edi
lea    0x9e6(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x20(%rbp),%edi
lea    0x979(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <closedir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0x914(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe4b(%rip),%rdi
call   1050 <opendir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    0x2df1(%rip),%r14
mov    (%r14),%rax
mov    0x2dcf(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1090 <assert@plt>
lea    0xe1a(%rip),%rdi
call   1050 <opendir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    (%r14),%rax
mov    0x2dd5(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1090 <assert@plt>
lea    0xdf2(%rip),%rdi
call   1050 <opendir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    (%r14),%rax
mov    0x2dbb(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1090 <assert@plt>
lea    0xdd0(%rip),%r15
mov    %r15,%rdi
call   1050 <opendir@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <closedir@plt>
mov    %rbp,%rdi
call   10a0 <readdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    (%r14),%rax
mov    0x2d33(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
call   1050 <opendir@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <closedir@plt>
mov    %rsp,%r14
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <readdir_r@plt>
cltq
xor    %edi,%edi
cmp    %rax,(%rbx)
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
call   1050 <opendir@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbp
mov    0x8(%rax),%edi
lea    0xd3d(%rip),%r13
mov    %r13,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    0x2cbf(%rip),%r15
mov    (%r15),%edi
and    0x0(%rbp),%edi
call   1090 <assert@plt>
xor    %edi,%edi
cmpl   $0xc,0x4(%rbp)
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbp
mov    0x8(%rax),%edi
lea    0xcf1(%rip),%r12
mov    %r12,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    (%r15),%edi
and    0x0(%rbp),%edi
call   1090 <assert@plt>
xor    %edi,%edi
cmpl   $0xc,0x4(%rbp)
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbp
mov    0x8(%rax),%edi
lea    0xc9d(%rip),%r15
mov    %r15,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
and    0x0(%rbp),%edi
call   1090 <assert@plt>
xor    %edi,%edi
cmpl   $0xc,0x4(%rbp)
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   1060 <rewinddir@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    0x8(%rax),%edi
mov    %r13,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   1060 <rewinddir@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    0x8(%rax),%edi
mov    %r13,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10c0 <telldir@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    0x8(%rax),%edi
mov    %r12,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    0x8(%rax),%edi
mov    %r15,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10b0 <seekdir@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    0x8(%rax),%edi
mov    %r12,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   1060 <rewinddir@plt>
lea    0x8(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <readdir_r@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
xor    %edi,%edi
cmp    (%rsp),%rbp
sete   %dil
call   1090 <assert@plt>
mov    0x10(%rsp),%edi
mov    %r13,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <readdir_r@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
xor    %edi,%edi
cmp    (%rsp),%rbp
sete   %dil
call   1090 <assert@plt>
mov    0x10(%rsp),%edi
mov    %r12,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <readdir_r@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
xor    %edi,%edi
cmp    (%rsp),%rbp
sete   %dil
call   1090 <assert@plt>
mov    0x10(%rsp),%edi
mov    %r15,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <readdir_r@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
call   1070 <closedir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
lea    0xa84(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32, i32, i32 }
@.str = [8 x i8] c"noexist\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [10 x i8] c"nocanread\00"
@EACCES = global i64 0
@.str.2 = [16 x i8] c"foobar/file.txt\00"
@ENOTDIR = global i64 0
@.str.3 = [7 x i8] c"foobar\00"
@EBADF = global i64 0
@.str.4 = [2 x i8] c".\00"
@DT_DIR = global i32 0
@.str.5 = [3 x i8] c"..\00"
@.str.6 = [9 x i8] c"file.txt\00"
@DT_REG = global i32 0
@.str.7 = [8 x i8] c"success\00"
define void @test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca %struct.dirent*
%5 = alloca %struct.dirent
%6 = alloca %struct.dirent*
%7 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
%10 = xor i1 %9, true
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i64, i64* @errno
%14 = load i64, i64* @ENOENT
%15 = icmp eq i64 %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32* @opendir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %3
%19 = load i32*, i32** %3
%20 = icmp ne i32* %19, null
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i64, i64* @errno
%25 = load i64, i64* @EACCES
%26 = icmp eq i64 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32* @opendir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32* %29, i32** %3
%30 = load i32*, i32** %3
%31 = icmp ne i32* %30, null
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i64, i64* @errno
%36 = load i64, i64* @ENOTDIR
%37 = icmp eq i64 %35, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32* %40, i32** %3
%41 = load i32*, i32** %3
%42 = call i32 @closedir(i32* %41)
%43 = load i32*, i32** %3
%44 = call %struct.dirent* @readdir(i32* %43)
store %struct.dirent* %44, %struct.dirent** %4
%45 = load %struct.dirent*, %struct.dirent** %4
%46 = icmp ne %struct.dirent* %45, null
%47 = xor i1 %46, true
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i64, i64* @errno
%51 = load i64, i64* @EBADF
%52 = icmp eq i64 %50, %51
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32* %55, i32** %3
%56 = load i32*, i32** %3
%57 = call i32 @closedir(i32* %56)
%58 = load i32*, i32** %3
%59 = call i32 @readdir_r(i32* %58, %struct.dirent* null, %struct.dirent** %6)
store i32 %59, i32* %1
%60 = load i32, i32* %1
%61 = sext i32 %60 to i64
%62 = load i64, i64* @EBADF
%63 = icmp eq i64 %61, %62
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32* %66, i32** %3
%67 = load i32*, i32** %3
%68 = ptrtoint i32* %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = load i32*, i32** %3
%71 = call %struct.dirent* @readdir(i32* %70)
store %struct.dirent* %71, %struct.dirent** %4
%72 = load %struct.dirent*, %struct.dirent** %4
%73 = getelementptr inbounds %struct.dirent, %struct.dirent* %72, i32 0, i32 2
%74 = load i32, i32* %73
%75 = call i32 @strcmp(i32 %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = icmp ne i32 %75, 0
%77 = xor i1 %76, true
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = load %struct.dirent*, %struct.dirent** %4
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i32, i32* %81
%83 = load i32, i32* @DT_DIR
%84 = and i32 %82, %83
%85 = call i32 @assert(i32 %84)
%86 = load %struct.dirent*, %struct.dirent** %4
%87 = getelementptr inbounds %struct.dirent, %struct.dirent* %86, i32 0, i32 1
%88 = load i32, i32* %87
%89 = sext i32 %88 to i64
%90 = icmp eq i64 %89, 12
%91 = zext i1 %90 to i32
%92 = call i32 @assert(i32 %91)
%93 = load i32*, i32** %3
%94 = call %struct.dirent* @readdir(i32* %93)
store %struct.dirent* %94, %struct.dirent** %4
%95 = load %struct.dirent*, %struct.dirent** %4
%96 = getelementptr inbounds %struct.dirent, %struct.dirent* %95, i32 0, i32 2
%97 = load i32, i32* %96
%98 = call i32 @strcmp(i32 %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%99 = icmp ne i32 %98, 0
%100 = xor i1 %99, true
%101 = zext i1 %100 to i32
%102 = call i32 @assert(i32 %101)
%103 = load %struct.dirent*, %struct.dirent** %4
%104 = getelementptr inbounds %struct.dirent, %struct.dirent* %103, i32 0, i32 0
%105 = load i32, i32* %104
%106 = load i32, i32* @DT_DIR
%107 = and i32 %105, %106
%108 = call i32 @assert(i32 %107)
%109 = load %struct.dirent*, %struct.dirent** %4
%110 = getelementptr inbounds %struct.dirent, %struct.dirent* %109, i32 0, i32 1
%111 = load i32, i32* %110
%112 = sext i32 %111 to i64
%113 = icmp eq i64 %112, 12
%114 = zext i1 %113 to i32
%115 = call i32 @assert(i32 %114)
%116 = load i32*, i32** %3
%117 = call %struct.dirent* @readdir(i32* %116)
store %struct.dirent* %117, %struct.dirent** %4
%118 = load %struct.dirent*, %struct.dirent** %4
%119 = getelementptr inbounds %struct.dirent, %struct.dirent* %118, i32 0, i32 2
%120 = load i32, i32* %119
%121 = call i32 @strcmp(i32 %120, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%122 = icmp ne i32 %121, 0
%123 = xor i1 %122, true
%124 = zext i1 %123 to i32
%125 = call i32 @assert(i32 %124)
%126 = load %struct.dirent*, %struct.dirent** %4
%127 = getelementptr inbounds %struct.dirent, %struct.dirent* %126, i32 0, i32 0
%128 = load i32, i32* %127
%129 = load i32, i32* @DT_REG
%130 = and i32 %128, %129
%131 = call i32 @assert(i32 %130)
%132 = load %struct.dirent*, %struct.dirent** %4
%133 = getelementptr inbounds %struct.dirent, %struct.dirent* %132, i32 0, i32 1
%134 = load i32, i32* %133
%135 = sext i32 %134 to i64
%136 = icmp eq i64 %135, 12
%137 = zext i1 %136 to i32
%138 = call i32 @assert(i32 %137)
%139 = load i32*, i32** %3
%140 = call %struct.dirent* @readdir(i32* %139)
store %struct.dirent* %140, %struct.dirent** %4
%141 = load %struct.dirent*, %struct.dirent** %4
%142 = icmp ne %struct.dirent* %141, null
%143 = xor i1 %142, true
%144 = zext i1 %143 to i32
%145 = call i32 @assert(i32 %144)
%146 = load i32*, i32** %3
%147 = call i32 @rewinddir(i32* %146)
%148 = load i32*, i32** %3
%149 = call %struct.dirent* @readdir(i32* %148)
store %struct.dirent* %149, %struct.dirent** %4
%150 = load %struct.dirent*, %struct.dirent** %4
%151 = getelementptr inbounds %struct.dirent, %struct.dirent* %150, i32 0, i32 2
%152 = load i32, i32* %151
%153 = call i32 @strcmp(i32 %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%154 = icmp ne i32 %153, 0
%155 = xor i1 %154, true
%156 = zext i1 %155 to i32
%157 = call i32 @assert(i32 %156)
%158 = load i32*, i32** %3
%159 = call i32 @rewinddir(i32* %158)
%160 = load i32*, i32** %3
%161 = call %struct.dirent* @readdir(i32* %160)
store %struct.dirent* %161, %struct.dirent** %4
%162 = load %struct.dirent*, %struct.dirent** %4
%163 = getelementptr inbounds %struct.dirent, %struct.dirent* %162, i32 0, i32 2
%164 = load i32, i32* %163
%165 = call i32 @strcmp(i32 %164, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%166 = icmp ne i32 %165, 0
%167 = xor i1 %166, true
%168 = zext i1 %167 to i32
%169 = call i32 @assert(i32 %168)
%170 = load i32*, i32** %3
%171 = call i32 @telldir(i32* %170)
store i32 %171, i32* %2
%172 = load i32*, i32** %3
%173 = call %struct.dirent* @readdir(i32* %172)
store %struct.dirent* %173, %struct.dirent** %4
%174 = load %struct.dirent*, %struct.dirent** %4
%175 = getelementptr inbounds %struct.dirent, %struct.dirent* %174, i32 0, i32 2
%176 = load i32, i32* %175
%177 = call i32 @strcmp(i32 %176, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%178 = icmp ne i32 %177, 0
%179 = xor i1 %178, true
%180 = zext i1 %179 to i32
%181 = call i32 @assert(i32 %180)
%182 = load i32*, i32** %3
%183 = call %struct.dirent* @readdir(i32* %182)
store %struct.dirent* %183, %struct.dirent** %4
%184 = load %struct.dirent*, %struct.dirent** %4
%185 = getelementptr inbounds %struct.dirent, %struct.dirent* %184, i32 0, i32 2
%186 = load i32, i32* %185
%187 = call i32 @strcmp(i32 %186, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%188 = icmp ne i32 %187, 0
%189 = xor i1 %188, true
%190 = zext i1 %189 to i32
%191 = call i32 @assert(i32 %190)
%192 = load i32*, i32** %3
%193 = load i32, i32* %2
%194 = call i32 @seekdir(i32* %192, i32 %193)
%195 = load i32*, i32** %3
%196 = call %struct.dirent* @readdir(i32* %195)
store %struct.dirent* %196, %struct.dirent** %4
%197 = load %struct.dirent*, %struct.dirent** %4
%198 = getelementptr inbounds %struct.dirent, %struct.dirent* %197, i32 0, i32 2
%199 = load i32, i32* %198
%200 = call i32 @strcmp(i32 %199, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%201 = icmp ne i32 %200, 0
%202 = xor i1 %201, true
%203 = zext i1 %202 to i32
%204 = call i32 @assert(i32 %203)
%205 = load i32*, i32** %3
%206 = call i32 @rewinddir(i32* %205)
%207 = load i32*, i32** %3
%208 = call i32 @readdir_r(i32* %207, %struct.dirent* %5, %struct.dirent** %6)
store i32 %208, i32* %1
%209 = load i32, i32* %1
%210 = icmp ne i32 %209, 0
%211 = xor i1 %210, true
%212 = zext i1 %211 to i32
%213 = call i32 @assert(i32 %212)
%214 = load %struct.dirent*, %struct.dirent** %6
%215 = icmp eq %struct.dirent* %5, %214
%216 = zext i1 %215 to i32
%217 = call i32 @assert(i32 %216)
%218 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 2
%219 = load i32, i32* %218
%220 = call i32 @strcmp(i32 %219, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%221 = icmp ne i32 %220, 0
%222 = xor i1 %221, true
%223 = zext i1 %222 to i32
%224 = call i32 @assert(i32 %223)
%225 = load i32*, i32** %3
%226 = call i32 @readdir_r(i32* %225, %struct.dirent* %5, %struct.dirent** %6)
store i32 %226, i32* %1
%227 = load i32, i32* %1
%228 = icmp ne i32 %227, 0
%229 = xor i1 %228, true
%230 = zext i1 %229 to i32
%231 = call i32 @assert(i32 %230)
%232 = load %struct.dirent*, %struct.dirent** %6
%233 = icmp eq %struct.dirent* %5, %232
%234 = zext i1 %233 to i32
%235 = call i32 @assert(i32 %234)
%236 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 2
%237 = load i32, i32* %236
%238 = call i32 @strcmp(i32 %237, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%239 = icmp ne i32 %238, 0
%240 = xor i1 %239, true
%241 = zext i1 %240 to i32
%242 = call i32 @assert(i32 %241)
%243 = load i32*, i32** %3
%244 = call i32 @readdir_r(i32* %243, %struct.dirent* %5, %struct.dirent** %6)
store i32 %244, i32* %1
%245 = load i32, i32* %1
%246 = icmp ne i32 %245, 0
%247 = xor i1 %246, true
%248 = zext i1 %247 to i32
%249 = call i32 @assert(i32 %248)
%250 = load %struct.dirent*, %struct.dirent** %6
%251 = icmp eq %struct.dirent* %5, %250
%252 = zext i1 %251 to i32
%253 = call i32 @assert(i32 %252)
%254 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 2
%255 = load i32, i32* %254
%256 = call i32 @strcmp(i32 %255, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%257 = icmp ne i32 %256, 0
%258 = xor i1 %257, true
%259 = zext i1 %258 to i32
%260 = call i32 @assert(i32 %259)
%261 = load i32*, i32** %3
%262 = call i32 @readdir_r(i32* %261, %struct.dirent* %5, %struct.dirent** %6)
store i32 %262, i32* %1
%263 = load i32, i32* %1
%264 = icmp ne i32 %263, 0
%265 = xor i1 %264, true
%266 = zext i1 %265 to i32
%267 = call i32 @assert(i32 %266)
%268 = load %struct.dirent*, %struct.dirent** %6
%269 = icmp ne %struct.dirent* %268, null
%270 = xor i1 %269, true
%271 = zext i1 %270 to i32
%272 = call i32 @assert(i32 %271)
%273 = load i32*, i32** %3
%274 = call i32 @closedir(i32* %273)
store i32 %274, i32* %1
%275 = load i32, i32* %1
%276 = icmp ne i32 %275, 0
%277 = xor i1 %276, true
%278 = zext i1 %277 to i32
%279 = call i32 @assert(i32 %278)
%280 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i32, i32, i32 }
@.str = [8 x i8] c"noexist\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [10 x i8] c"nocanread\00"
@EACCES = global i64 0
@.str.2 = [16 x i8] c"foobar/file.txt\00"
@ENOTDIR = global i64 0
@.str.3 = [7 x i8] c"foobar\00"
@EBADF = global i64 0
@.str.4 = [2 x i8] c".\00"
@DT_DIR = global i32 0
@.str.5 = [3 x i8] c"..\00"
@.str.6 = [9 x i8] c"file.txt\00"
@DT_REG = global i32 0
@.str.7 = [8 x i8] c"success\00"
define void @test() {
%1 = alloca %struct.dirent
%2 = alloca %struct.dirent*
%3 = bitcast %struct.dirent* %1 to i8*
%4 = bitcast %struct.dirent** %2 to i8*
%5 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load i64, i64* @errno
%10 = load i64, i64* @ENOENT
%11 = icmp eq i64 %9, %10
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32* @opendir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = load i64, i64* @errno
%19 = load i64, i64* @EACCES
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32* @opendir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32* %23, null
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = load i64, i64* @errno
%28 = load i64, i64* @ENOTDIR
%29 = icmp eq i64 %27, %28
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = tail call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = tail call i32 @closedir(i32* %32)
%34 = tail call %struct.dirent* @readdir(i32* %32)
%35 = icmp eq %struct.dirent* %34, null
%36 = zext i1 %35 to i32
%37 = tail call i32 @assert(i32 %36)
%38 = load i64, i64* @errno
%39 = load i64, i64* @EBADF
%40 = icmp eq i64 %38, %39
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = tail call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%44 = tail call i32 @closedir(i32* %43)
%45 = call i32 @readdir_r(i32* %43, %struct.dirent* null, %struct.dirent** %2)
%46 = sext i32 %45 to i64
%47 = load i64, i64* @EBADF
%48 = icmp eq i64 %47, %46
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%52 = ptrtoint i32* %51 to i64
%53 = trunc i64 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call %struct.dirent* @readdir(i32* %51)
%56 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i64 0, i32 2
%57 = load i32, i32* %56
%58 = call i32 @strcmp(i32 %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp eq i32 %58, 0
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i64 0, i32 0
%63 = load i32, i32* %62
%64 = load i32, i32* @DT_DIR
%65 = and i32 %64, %63
%66 = call i32 @assert(i32 %65)
%67 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i64 0, i32 1
%68 = load i32, i32* %67
%69 = icmp eq i32 %68, 12
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
%72 = call %struct.dirent* @readdir(i32* %51)
%73 = getelementptr inbounds %struct.dirent, %struct.dirent* %72, i64 0, i32 2
%74 = load i32, i32* %73
%75 = call i32 @strcmp(i32 %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%76 = icmp eq i32 %75, 0
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = getelementptr inbounds %struct.dirent, %struct.dirent* %72, i64 0, i32 0
%80 = load i32, i32* %79
%81 = load i32, i32* @DT_DIR
%82 = and i32 %81, %80
%83 = call i32 @assert(i32 %82)
%84 = getelementptr inbounds %struct.dirent, %struct.dirent* %72, i64 0, i32 1
%85 = load i32, i32* %84
%86 = icmp eq i32 %85, 12
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = call %struct.dirent* @readdir(i32* %51)
%90 = getelementptr inbounds %struct.dirent, %struct.dirent* %89, i64 0, i32 2
%91 = load i32, i32* %90
%92 = call i32 @strcmp(i32 %91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%93 = icmp eq i32 %92, 0
%94 = zext i1 %93 to i32
%95 = call i32 @assert(i32 %94)
%96 = getelementptr inbounds %struct.dirent, %struct.dirent* %89, i64 0, i32 0
%97 = load i32, i32* %96
%98 = load i32, i32* @DT_REG
%99 = and i32 %98, %97
%100 = call i32 @assert(i32 %99)
%101 = getelementptr inbounds %struct.dirent, %struct.dirent* %89, i64 0, i32 1
%102 = load i32, i32* %101
%103 = icmp eq i32 %102, 12
%104 = zext i1 %103 to i32
%105 = call i32 @assert(i32 %104)
%106 = call %struct.dirent* @readdir(i32* %51)
%107 = icmp eq %struct.dirent* %106, null
%108 = zext i1 %107 to i32
%109 = call i32 @assert(i32 %108)
%110 = call i32 @rewinddir(i32* %51)
%111 = call %struct.dirent* @readdir(i32* %51)
%112 = getelementptr inbounds %struct.dirent, %struct.dirent* %111, i64 0, i32 2
%113 = load i32, i32* %112
%114 = call i32 @strcmp(i32 %113, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%115 = icmp eq i32 %114, 0
%116 = zext i1 %115 to i32
%117 = call i32 @assert(i32 %116)
%118 = call i32 @rewinddir(i32* %51)
%119 = call %struct.dirent* @readdir(i32* %51)
%120 = getelementptr inbounds %struct.dirent, %struct.dirent* %119, i64 0, i32 2
%121 = load i32, i32* %120
%122 = call i32 @strcmp(i32 %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%123 = icmp eq i32 %122, 0
%124 = zext i1 %123 to i32
%125 = call i32 @assert(i32 %124)
%126 = call i32 @telldir(i32* %51)
%127 = call %struct.dirent* @readdir(i32* %51)
%128 = getelementptr inbounds %struct.dirent, %struct.dirent* %127, i64 0, i32 2
%129 = load i32, i32* %128
%130 = call i32 @strcmp(i32 %129, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%131 = icmp eq i32 %130, 0
%132 = zext i1 %131 to i32
%133 = call i32 @assert(i32 %132)
%134 = call %struct.dirent* @readdir(i32* %51)
%135 = getelementptr inbounds %struct.dirent, %struct.dirent* %134, i64 0, i32 2
%136 = load i32, i32* %135
%137 = call i32 @strcmp(i32 %136, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%138 = icmp eq i32 %137, 0
%139 = zext i1 %138 to i32
%140 = call i32 @assert(i32 %139)
%141 = call i32 @seekdir(i32* %51, i32 %126)
%142 = call %struct.dirent* @readdir(i32* %51)
%143 = getelementptr inbounds %struct.dirent, %struct.dirent* %142, i64 0, i32 2
%144 = load i32, i32* %143
%145 = call i32 @strcmp(i32 %144, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%146 = icmp eq i32 %145, 0
%147 = zext i1 %146 to i32
%148 = call i32 @assert(i32 %147)
%149 = call i32 @rewinddir(i32* %51)
%150 = call i32 @readdir_r(i32* %51, %struct.dirent* %1, %struct.dirent** %2)
%151 = icmp eq i32 %150, 0
%152 = zext i1 %151 to i32
%153 = call i32 @assert(i32 %152)
%154 = load %struct.dirent*, %struct.dirent** %2
%155 = icmp eq %struct.dirent* %1, %154
%156 = zext i1 %155 to i32
%157 = call i32 @assert(i32 %156)
%158 = getelementptr inbounds %struct.dirent, %struct.dirent* %1, i64 0, i32 2
%159 = load i32, i32* %158
%160 = call i32 @strcmp(i32 %159, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%161 = icmp eq i32 %160, 0
%162 = zext i1 %161 to i32
%163 = call i32 @assert(i32 %162)
%164 = call i32 @readdir_r(i32* %51, %struct.dirent* %1, %struct.dirent** %2)
%165 = icmp eq i32 %164, 0
%166 = zext i1 %165 to i32
%167 = call i32 @assert(i32 %166)
%168 = load %struct.dirent*, %struct.dirent** %2
%169 = icmp eq %struct.dirent* %1, %168
%170 = zext i1 %169 to i32
%171 = call i32 @assert(i32 %170)
%172 = load i32, i32* %158
%173 = call i32 @strcmp(i32 %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%174 = icmp eq i32 %173, 0
%175 = zext i1 %174 to i32
%176 = call i32 @assert(i32 %175)
%177 = call i32 @readdir_r(i32* %51, %struct.dirent* %1, %struct.dirent** %2)
%178 = icmp eq i32 %177, 0
%179 = zext i1 %178 to i32
%180 = call i32 @assert(i32 %179)
%181 = load %struct.dirent*, %struct.dirent** %2
%182 = icmp eq %struct.dirent* %1, %181
%183 = zext i1 %182 to i32
%184 = call i32 @assert(i32 %183)
%185 = load i32, i32* %158
%186 = call i32 @strcmp(i32 %185, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%187 = icmp eq i32 %186, 0
%188 = zext i1 %187 to i32
%189 = call i32 @assert(i32 %188)
%190 = call i32 @readdir_r(i32* %51, %struct.dirent* %1, %struct.dirent** %2)
%191 = icmp eq i32 %190, 0
%192 = zext i1 %191 to i32
%193 = call i32 @assert(i32 %192)
%194 = load %struct.dirent*, %struct.dirent** %2
%195 = icmp eq %struct.dirent* %194, null
%196 = zext i1 %195 to i32
%197 = call i32 @assert(i32 %196)
%198 = call i32 @closedir(i32* %51)
%199 = icmp eq i32 %198, 0
%200 = zext i1 %199 to i32
%201 = call i32 @assert(i32 %200)
%202 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
ret void
}