#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 */
scalar_t__ DTTOIF(scalar_t__);
scalar_t__ DT_BLK;
scalar_t__ DT_CHR;
scalar_t__ DT_DIR;
scalar_t__ DT_FIFO;
scalar_t__ DT_REG;
scalar_t__ DT_SOCK;
int EXIT_SUCCESS;
scalar_t__ IFTODT(scalar_t__);
scalar_t__ S_IFBLK;
scalar_t__ S_IFCHR;
scalar_t__ S_IFDIR;
scalar_t__ S_IFIFO;
scalar_t__ S_IFREG;
scalar_t__ S_IFSOCK;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(int);
int chdir(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  (void)argc;
  (void)argv;
  {
    assert(DTTOIF(DT_REG) == S_IFREG);
    assert(DTTOIF(DT_DIR) == S_IFDIR);
    assert(DTTOIF(DT_FIFO) == S_IFIFO);
    assert(DTTOIF(DT_SOCK) == S_IFSOCK);
    assert(DTTOIF(DT_CHR) == S_IFCHR);
    assert(DTTOIF(DT_BLK) == S_IFBLK);
    assert(IFTODT(S_IFREG) == DT_REG);
    assert(IFTODT(S_IFDIR) == DT_DIR);
    assert(IFTODT(S_IFIFO) == DT_FIFO);
    assert(IFTODT(S_IFSOCK) == DT_SOCK);
    assert(IFTODT(S_IFCHR) == DT_CHR);
    assert(IFTODT(S_IFBLK) == DT_BLK);
  }
  {
    DIR *dir;
    struct dirent *ent;
    int found = 0;
    dir = opendir("tests/1");
    if (dir == NULL) {
      fprintf(stderr, "Directory tests/1 not found\n");
      abort();
    }
    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);
    closedir(dir);
  }
  {
    DIR *dir;
    struct dirent *ent;
    int found = 0;
    dir = opendir("tests/1");
    assert(dir != NULL);
    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);
    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);
    closedir(dir);
  }
  {
    DIR *dir;
    struct dirent *ent;
    int found = 0;
    int errorcode;
    dir = opendir("tests/1");
    assert(dir != NULL);
    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("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);
  }
  {
    DIR *dir;
    struct dirent *ent;
    int found = 0;
    dir = opendir("tests/2");
    if (dir == NULL) {
      fprintf(stderr, "Directory tests/2 not found\n");
      abort();
    }
    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.txt") == 0) {
        found += 4;
      } else if (strcmp(ent->d_name, "Testfile-1.2.3.dat") == 0) {
        found += 8;
      } else {
        fprintf(stderr, "Unexpected file %s\n", ent->d_name);
        abort();
      }
    }
    assert(found == 0xf);
    closedir(dir);
  }
  printf("OK\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d58(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d7a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d1e(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2d00(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2cba(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2c5c(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2c2e(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2c5f(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2c38(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%rdi
call   10e0 <IFTODT@plt>
mov    0x2c1a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
movl   $0x0,-0x24(%rbp)
lea    0xc54(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13de <main+0x21e>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    13e3 <main+0x223>
mov    -0x18(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     14df <main+0x31f>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xc1e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1425 <main+0x265>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14da <main+0x31a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xbf2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1450 <main+0x290>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    14d5 <main+0x315>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xbca(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    147b <main+0x2bb>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    14d0 <main+0x310>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xba4(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    14a6 <main+0x2e6>
mov    -0x24(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x24(%rbp)
jmp    14cb <main+0x30b>
mov    0x2b13(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    14d0 <main+0x310>
jmp    14d5 <main+0x315>
jmp    14da <main+0x31a>
jmp    13e3 <main+0x223>
cmpl   $0xf,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1080 <closedir@plt>
movl   $0x0,-0x3c(%rbp)
lea    0xaf9(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x30(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     161e <main+0x45e>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xadf(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1564 <main+0x3a4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1619 <main+0x459>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xab3(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    158f <main+0x3cf>
mov    -0x3c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3c(%rbp)
jmp    1614 <main+0x454>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xa8b(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    15ba <main+0x3fa>
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
jmp    160f <main+0x44f>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xa65(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    15e5 <main+0x425>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    160a <main+0x44a>
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xa35(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    160f <main+0x44f>
jmp    1614 <main+0x454>
jmp    1619 <main+0x459>
jmp    1522 <main+0x362>
cmpl   $0xf,-0x3c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x30(%rbp),%rdi
call   1070 <rewinddir@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     173b <main+0x57b>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0x9c2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1681 <main+0x4c1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1736 <main+0x576>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0x996(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    16ac <main+0x4ec>
mov    -0x3c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3c(%rbp)
jmp    1731 <main+0x571>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0x96e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    16d7 <main+0x517>
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
jmp    172c <main+0x56c>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0x948(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1702 <main+0x542>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    1727 <main+0x567>
mov    0x28b7(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0x918(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    172c <main+0x56c>
jmp    1731 <main+0x571>
jmp    1736 <main+0x576>
jmp    163f <main+0x47f>
cmpl   $0xf,-0x3c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x30(%rbp),%rdi
call   1080 <closedir@plt>
movl   $0x0,-0x54(%rbp)
lea    0x89d(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     187a <main+0x6ba>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x883(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    17c0 <main+0x600>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1875 <main+0x6b5>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x857(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    17eb <main+0x62b>
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
jmp    1870 <main+0x6b0>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x82f(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1816 <main+0x656>
mov    -0x54(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x54(%rbp)
jmp    186b <main+0x6ab>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x809(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1841 <main+0x681>
mov    -0x54(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x54(%rbp)
jmp    1866 <main+0x6a6>
mov    0x2778(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
mov    (%rax),%rdx
lea    0x7d9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    186b <main+0x6ab>
jmp    1870 <main+0x6b0>
jmp    1875 <main+0x6b5>
jmp    177e <main+0x5be>
cmpl   $0xf,-0x54(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
lea    0x7b3(%rip),%rdi
call   1050 <chdir@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
call   1070 <rewinddir@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     19b7 <main+0x7f7>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x746(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    18fd <main+0x73d>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    19b2 <main+0x7f2>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x71a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1928 <main+0x768>
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
jmp    19ad <main+0x7ed>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x6f2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1953 <main+0x793>
mov    -0x54(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x54(%rbp)
jmp    19a8 <main+0x7e8>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0x6cc(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    197e <main+0x7be>
mov    -0x54(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x54(%rbp)
jmp    19a3 <main+0x7e3>
mov    0x263b(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
mov    (%rax),%rdx
lea    0x69c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    19a8 <main+0x7e8>
jmp    19ad <main+0x7ed>
jmp    19b2 <main+0x7f2>
jmp    18bb <main+0x6fb>
cmpl   $0xf,-0x54(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
lea    0x656(%rip),%rdi
call   1050 <chdir@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
call   1080 <closedir@plt>
movl   $0x0,-0x6c(%rbp)
lea    0x64c(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1a31 <main+0x871>
mov    0x25a6(%rip),%rax
mov    (%rax),%edi
lea    0x630(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1a36 <main+0x876>
mov    -0x60(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
je     1b32 <main+0x972>
mov    -0x68(%rbp),%rax
mov    (%rax),%rdi
lea    0x5cb(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1a78 <main+0x8b8>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1b2d <main+0x96d>
mov    -0x68(%rbp),%rax
mov    (%rax),%rdi
lea    0x59f(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1aa3 <main+0x8e3>
mov    -0x6c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x6c(%rbp)
jmp    1b28 <main+0x968>
mov    -0x68(%rbp),%rax
mov    (%rax),%rdi
lea    0x5bf(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1ace <main+0x90e>
mov    -0x6c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x6c(%rbp)
jmp    1b23 <main+0x963>
mov    -0x68(%rbp),%rax
mov    (%rax),%rdi
lea    0x59d(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1af9 <main+0x939>
mov    -0x6c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x6c(%rbp)
jmp    1b1e <main+0x95e>
mov    0x24c0(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rax
mov    (%rax),%rdx
lea    0x521(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1b23 <main+0x963>
jmp    1b28 <main+0x968>
jmp    1b2d <main+0x96d>
jmp    1a36 <main+0x876>
cmpl   $0xf,-0x6c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x60(%rbp),%rdi
call   1080 <closedir@plt>
lea    0x539(%rip),%rdi
call   1060 <printf@plt>
mov    0x2439(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2dfe(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2e07(%rip),%r14
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d7b(%rip),%r15
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d67(%rip),%r12
xor    %edi,%edi
cmp    (%r12),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d8a(%rip),%r13
xor    %edi,%edi
cmp    0x0(%r13),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d45(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%rdi
call   10d0 <DTTOIF@plt>
mov    0x2d31(%rip),%rbp
xor    %edi,%edi
cmp    0x0(%rbp),%rax
sete   %dil
call   10a0 <assert@plt>
mov    (%r14),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2d19(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    (%r15),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2cdc(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    (%r12),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2c86(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x0(%r13),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2c60(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    (%rbx),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2c73(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
mov    0x0(%rbp),%rdi
call   10e0 <IFTODT@plt>
xor    %edi,%edi
mov    0x2c5d(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   10a0 <assert@plt>
lea    0xca2(%rip),%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     192d <main+0x76d>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <readdir@plt>
xor    %r15d,%r15d
mov    $0x0,%edi
test   %rax,%rax
je     143b <main+0x27b>
mov    %rax,%r14
xor    %r13d,%r13d
lea    0xc91(%rip),%rbp
lea    0xc89(%rip),%r15
lea    0xc85(%rip),%r12
jmp    13c8 <main+0x208>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%ecx
add    %ecx,%r13d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     142e <main+0x26e>
mov    (%r14),%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13b0 <main+0x1f0>
mov    (%r14),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1420 <main+0x260>
mov    (%r14),%rdi
mov    %r12,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1427 <main+0x267>
mov    (%r14),%rdi
lea    0xc2b(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     13b5 <main+0x1f5>
jmp    190c <main+0x74c>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    13b5 <main+0x1f5>
mov    $0x4,%ecx
jmp    13b5 <main+0x1f5>
xor    %edi,%edi
cmp    $0xf,%r13d
sete   %dil
xor    %r15d,%r15d
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1080 <closedir@plt>
lea    0xbb1(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1529 <main+0x369>
mov    %rax,%rbp
xor    %r12d,%r12d
lea    0xba3(%rip),%r13
lea    0xb9b(%rip),%r14
lea    0xb97(%rip),%r15
jmp    14b8 <main+0x2f8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%ecx
add    %ecx,%r12d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     151e <main+0x35e>
mov    0x0(%rbp),%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     14a0 <main+0x2e0>
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1510 <main+0x350>
mov    0x0(%rbp),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1517 <main+0x357>
mov    0x0(%rbp),%rdi
lea    0xb37(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     14a5 <main+0x2e5>
jmp    18fd <main+0x73d>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    14a5 <main+0x2e5>
mov    $0x4,%ecx
jmp    14a5 <main+0x2e5>
xor    %r15d,%r15d
cmp    $0xf,%r12d
sete   %r15b
mov    %r15d,%edi
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1070 <rewinddir@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
xor    %r15d,%r15d
mov    $0x0,%edi
test   %rax,%rax
je     15fb <main+0x43b>
mov    %rax,%r14
xor    %r13d,%r13d
lea    0xac7(%rip),%rbp
lea    0xabf(%rip),%r15
lea    0xabb(%rip),%r12
jmp    1588 <main+0x3c8>
nop
mov    $0x1,%ecx
add    %ecx,%r13d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     15ee <main+0x42e>
mov    (%r14),%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1570 <main+0x3b0>
mov    (%r14),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     15e0 <main+0x420>
mov    (%r14),%rdi
mov    %r12,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     15e7 <main+0x427>
mov    (%r14),%rdi
lea    0xa6b(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     1575 <main+0x3b5>
jmp    190c <main+0x74c>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    1575 <main+0x3b5>
mov    $0x4,%ecx
jmp    1575 <main+0x3b5>
xor    %edi,%edi
cmp    $0xf,%r13d
sete   %dil
xor    %r15d,%r15d
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1080 <closedir@plt>
lea    0x9f1(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     16e9 <main+0x529>
mov    %rax,%rbp
xor    %r12d,%r12d
lea    0x9e3(%rip),%r13
lea    0x9db(%rip),%r14
lea    0x9d7(%rip),%r15
jmp    1678 <main+0x4b8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%ecx
add    %ecx,%r12d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     16de <main+0x51e>
mov    0x0(%rbp),%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1660 <main+0x4a0>
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     16d0 <main+0x510>
mov    0x0(%rbp),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     16d7 <main+0x517>
mov    0x0(%rbp),%rdi
lea    0x977(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     1665 <main+0x4a5>
jmp    18fd <main+0x73d>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    1665 <main+0x4a5>
mov    $0x4,%ecx
jmp    1665 <main+0x4a5>
xor    %r15d,%r15d
cmp    $0xf,%r12d
sete   %r15b
mov    %r15d,%edi
call   10a0 <assert@plt>
lea    0x94d(%rip),%rdi
call   1060 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1070 <rewinddir@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     17ca <main+0x60a>
mov    %rax,%rbp
xor    %r12d,%r12d
lea    0x8f6(%rip),%r13
lea    0x8ee(%rip),%r14
lea    0x8ea(%rip),%r15
jmp    1758 <main+0x598>
mov    $0x1,%ecx
add    %ecx,%r12d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     17be <main+0x5fe>
mov    0x0(%rbp),%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1740 <main+0x580>
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     17b0 <main+0x5f0>
mov    0x0(%rbp),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     17b7 <main+0x5f7>
mov    0x0(%rbp),%rdi
lea    0x897(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     1745 <main+0x585>
jmp    18fd <main+0x73d>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    1745 <main+0x585>
mov    $0x4,%ecx
jmp    1745 <main+0x585>
xor    %edi,%edi
cmp    $0xf,%r12d
sete   %dil
jmp    17cc <main+0x60c>
xor    %edi,%edi
call   10a0 <assert@plt>
lea    0x84d(%rip),%rdi
call   1060 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1080 <closedir@plt>
lea    0x852(%rip),%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     193f <main+0x77f>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     18ca <main+0x70a>
mov    %rax,%rbp
xor    %r12d,%r12d
lea    0x7fe(%rip),%r13
lea    0x7f6(%rip),%r14
lea    0x83a(%rip),%r15
jmp    1858 <main+0x698>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%ecx
add    %ecx,%r12d
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     18be <main+0x6fe>
mov    0x0(%rbp),%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1840 <main+0x680>
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     18b0 <main+0x6f0>
mov    0x0(%rbp),%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     18b7 <main+0x6f7>
mov    0x0(%rbp),%rdi
lea    0x7e3(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
test   %rax,%rax
je     1845 <main+0x685>
jmp    18fd <main+0x73d>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%ecx
jmp    1845 <main+0x685>
mov    $0x4,%ecx
jmp    1845 <main+0x685>
xor    %edi,%edi
cmp    $0xf,%r12d
sete   %dil
jmp    18cc <main+0x70c>
xor    %edi,%edi
call   10a0 <assert@plt>
mov    %rbx,%rdi
call   1080 <closedir@plt>
lea    0x7ac(%rip),%rdi
call   1040 <puts@plt>
mov    0x26ac(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x26bc(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
jmp    1918 <main+0x758>
mov    0x26ad(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0x712(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x268c(%rip),%rax
mov    (%rax),%edi
lea    0x6cb(%rip),%rsi
jmp    194f <main+0x78f>
mov    0x267a(%rip),%rax
mov    (%rax),%edi
lea    0x704(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@DT_REG = global i64 0
@S_IFREG = global i64 0
@DT_DIR = global i64 0
@S_IFDIR = global i64 0
@DT_FIFO = global i64 0
@S_IFIFO = global i64 0
@DT_SOCK = global i64 0
@S_IFSOCK = global i64 0
@DT_CHR = global i64 0
@S_IFCHR = global i64 0
@DT_BLK = global i64 0
@S_IFBLK = global i64 0
@.str = [8 x i8] c"tests/1\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"Directory tests/1 not found\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [5 x i8] c"file\00"
@.str.5 = [4 x i8] c"dir\00"
@.str.6 = [20 x i8] c"Unexpected file %s\0A\00"
@.str.7 = [6 x i8] c"tests\00"
@.str.8 = [8 x i8] c"tests/2\00"
@.str.9 = [29 x i8] c"Directory tests/2 not found\0A\00"
@.str.10 = [9 x i8] c"file.txt\00"
@.str.11 = [19 x i8] c"Testfile-1.2.3.dat\00"
@.str.12 = [4 x i8] c"OK\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca %struct.dirent*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca %struct.dirent*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca %struct.dirent*
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = load i64, i64* @DT_REG
%22 = call i64 @DTTOIF(i64 %21)
%23 = load i64, i64* @S_IFREG
%24 = icmp eq i64 %22, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i64, i64* @DT_DIR
%28 = call i64 @DTTOIF(i64 %27)
%29 = load i64, i64* @S_IFDIR
%30 = icmp eq i64 %28, %29
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i64, i64* @DT_FIFO
%34 = call i64 @DTTOIF(i64 %33)
%35 = load i64, i64* @S_IFIFO
%36 = icmp eq i64 %34, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i64, i64* @DT_SOCK
%40 = call i64 @DTTOIF(i64 %39)
%41 = load i64, i64* @S_IFSOCK
%42 = icmp eq i64 %40, %41
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i64, i64* @DT_CHR
%46 = call i64 @DTTOIF(i64 %45)
%47 = load i64, i64* @S_IFCHR
%48 = icmp eq i64 %46, %47
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i64, i64* @DT_BLK
%52 = call i64 @DTTOIF(i64 %51)
%53 = load i64, i64* @S_IFBLK
%54 = icmp eq i64 %52, %53
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load i64, i64* @S_IFREG
%58 = call i64 @IFTODT(i64 %57)
%59 = load i64, i64* @DT_REG
%60 = icmp eq i64 %58, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i64, i64* @S_IFDIR
%64 = call i64 @IFTODT(i64 %63)
%65 = load i64, i64* @DT_DIR
%66 = icmp eq i64 %64, %65
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = load i64, i64* @S_IFIFO
%70 = call i64 @IFTODT(i64 %69)
%71 = load i64, i64* @DT_FIFO
%72 = icmp eq i64 %70, %71
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load i64, i64* @S_IFSOCK
%76 = call i64 @IFTODT(i64 %75)
%77 = load i64, i64* @DT_SOCK
%78 = icmp eq i64 %76, %77
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = load i64, i64* @S_IFCHR
%82 = call i64 @IFTODT(i64 %81)
%83 = load i64, i64* @DT_CHR
%84 = icmp eq i64 %82, %83
%85 = zext i1 %84 to i32
%86 = call i32 @assert(i32 %85)
%87 = load i64, i64* @S_IFBLK
%88 = call i64 @IFTODT(i64 %87)
%89 = load i64, i64* @DT_BLK
%90 = icmp eq i64 %88, %89
%91 = zext i1 %90 to i32
%92 = call i32 @assert(i32 %91)
store i32 0, i32* %8
%93 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %93, i32** %6
%94 = load i32*, i32** %6
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %100
96: ; preds = %2
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%99 = call i32 (...) @abort()
unreachable
100: ; preds = %2
br label %101
101: ; preds = %151, %100
%102 = load i32*, i32** %6
%103 = call %struct.dirent* @readdir(i32* %102)
store %struct.dirent* %103, %struct.dirent** %7
%104 = icmp ne %struct.dirent* %103, null
br i1 %104, label %105, label %152
105: ; preds = %101
%106 = load %struct.dirent*, %struct.dirent** %7
%107 = getelementptr inbounds %struct.dirent, %struct.dirent* %106, i32 0, i32 0
%108 = load i8*, i8** %107
%109 = call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %105
%112 = load i32, i32* %8
%113 = add nsw i32 %112, 1
store i32 %113, i32* %8
br label %151
114: ; preds = %105
%115 = load %struct.dirent*, %struct.dirent** %7
%116 = getelementptr inbounds %struct.dirent, %struct.dirent* %115, i32 0, i32 0
%117 = load i8*, i8** %116
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %123
120: ; preds = %114
%121 = load i32, i32* %8
%122 = add nsw i32 %121, 2
store i32 %122, i32* %8
br label %150
123: ; preds = %114
%124 = load %struct.dirent*, %struct.dirent** %7
%125 = getelementptr inbounds %struct.dirent, %struct.dirent* %124, i32 0, i32 0
%126 = load i8*, i8** %125
%127 = call i64 @strcmp(i8* %126, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %123
%130 = load i32, i32* %8
%131 = add nsw i32 %130, 4
store i32 %131, i32* %8
br label %149
132: ; preds = %123
%133 = load %struct.dirent*, %struct.dirent** %7
%134 = getelementptr inbounds %struct.dirent, %struct.dirent* %133, i32 0, i32 0
%135 = load i8*, i8** %134
%136 = call i64 @strcmp(i8* %135, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %132
%139 = load i32, i32* %8
%140 = add nsw i32 %139, 8
store i32 %140, i32* %8
br label %148
141: ; preds = %132
%142 = load i32, i32* @stderr
%143 = load %struct.dirent*, %struct.dirent** %7
%144 = getelementptr inbounds %struct.dirent, %struct.dirent* %143, i32 0, i32 0
%145 = load i8*, i8** %144
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %145)
%147 = call i32 (...) @abort()
unreachable
148: ; preds = %138
br label %149
149: ; preds = %148, %129
br label %150
150: ; preds = %149, %120
br label %151
151: ; preds = %150, %111
br label %101
152: ; preds = %101
%153 = load i32, i32* %8
%154 = icmp eq i32 %153, 15
%155 = zext i1 %154 to i32
%156 = call i32 @assert(i32 %155)
%157 = load i32*, i32** %6
%158 = call i32 @closedir(i32* %157)
store i32 0, i32* %11
%159 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %159, i32** %9
%160 = load i32*, i32** %9
%161 = icmp ne i32* %160, null
%162 = zext i1 %161 to i32
%163 = call i32 @assert(i32 %162)
br label %164
164: ; preds = %214, %152
%165 = load i32*, i32** %9
%166 = call %struct.dirent* @readdir(i32* %165)
store %struct.dirent* %166, %struct.dirent** %10
%167 = icmp ne %struct.dirent* %166, null
br i1 %167, label %168, label %215
168: ; preds = %164
%169 = load %struct.dirent*, %struct.dirent** %10
%170 = getelementptr inbounds %struct.dirent, %struct.dirent* %169, i32 0, i32 0
%171 = load i8*, i8** %170
%172 = call i64 @strcmp(i8* %171, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%173 = icmp eq i64 %172, 0
br i1 %173, label %174, label %177
174: ; preds = %168
%175 = load i32, i32* %11
%176 = add nsw i32 %175, 1
store i32 %176, i32* %11
br label %214
177: ; preds = %168
%178 = load %struct.dirent*, %struct.dirent** %10
%179 = getelementptr inbounds %struct.dirent, %struct.dirent* %178, i32 0, i32 0
%180 = load i8*, i8** %179
%181 = call i64 @strcmp(i8* %180, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%182 = icmp eq i64 %181, 0
br i1 %182, label %183, label %186
183: ; preds = %177
%184 = load i32, i32* %11
%185 = add nsw i32 %184, 2
store i32 %185, i32* %11
br label %213
186: ; preds = %177
%187 = load %struct.dirent*, %struct.dirent** %10
%188 = getelementptr inbounds %struct.dirent, %struct.dirent* %187, i32 0, i32 0
%189 = load i8*, i8** %188
%190 = call i64 @strcmp(i8* %189, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%191 = icmp eq i64 %190, 0
br i1 %191, label %192, label %195
192: ; preds = %186
%193 = load i32, i32* %11
%194 = add nsw i32 %193, 4
store i32 %194, i32* %11
br label %212
195: ; preds = %186
%196 = load %struct.dirent*, %struct.dirent** %10
%197 = getelementptr inbounds %struct.dirent, %struct.dirent* %196, i32 0, i32 0
%198 = load i8*, i8** %197
%199 = call i64 @strcmp(i8* %198, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%200 = icmp eq i64 %199, 0
br i1 %200, label %201, label %204
201: ; preds = %195
%202 = load i32, i32* %11
%203 = add nsw i32 %202, 8
store i32 %203, i32* %11
br label %211
204: ; preds = %195
%205 = load i32, i32* @stderr
%206 = load %struct.dirent*, %struct.dirent** %10
%207 = getelementptr inbounds %struct.dirent, %struct.dirent* %206, i32 0, i32 0
%208 = load i8*, i8** %207
%209 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %208)
%210 = call i32 (...) @abort()
unreachable
211: ; preds = %201
br label %212
212: ; preds = %211, %192
br label %213
213: ; preds = %212, %183
br label %214
214: ; preds = %213, %174
br label %164
215: ; preds = %164
%216 = load i32, i32* %11
%217 = icmp eq i32 %216, 15
%218 = zext i1 %217 to i32
%219 = call i32 @assert(i32 %218)
%220 = load i32*, i32** %9
%221 = call i32 @rewinddir(i32* %220)
store i32 0, i32* %11
br label %222
222: ; preds = %272, %215
%223 = load i32*, i32** %9
%224 = call %struct.dirent* @readdir(i32* %223)
store %struct.dirent* %224, %struct.dirent** %10
%225 = icmp ne %struct.dirent* %224, null
br i1 %225, label %226, label %273
226: ; preds = %222
%227 = load %struct.dirent*, %struct.dirent** %10
%228 = getelementptr inbounds %struct.dirent, %struct.dirent* %227, i32 0, i32 0
%229 = load i8*, i8** %228
%230 = call i64 @strcmp(i8* %229, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%231 = icmp eq i64 %230, 0
br i1 %231, label %232, label %235
232: ; preds = %226
%233 = load i32, i32* %11
%234 = add nsw i32 %233, 1
store i32 %234, i32* %11
br label %272
235: ; preds = %226
%236 = load %struct.dirent*, %struct.dirent** %10
%237 = getelementptr inbounds %struct.dirent, %struct.dirent* %236, i32 0, i32 0
%238 = load i8*, i8** %237
%239 = call i64 @strcmp(i8* %238, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%240 = icmp eq i64 %239, 0
br i1 %240, label %241, label %244
241: ; preds = %235
%242 = load i32, i32* %11
%243 = add nsw i32 %242, 2
store i32 %243, i32* %11
br label %271
244: ; preds = %235
%245 = load %struct.dirent*, %struct.dirent** %10
%246 = getelementptr inbounds %struct.dirent, %struct.dirent* %245, i32 0, i32 0
%247 = load i8*, i8** %246
%248 = call i64 @strcmp(i8* %247, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%249 = icmp eq i64 %248, 0
br i1 %249, label %250, label %253
250: ; preds = %244
%251 = load i32, i32* %11
%252 = add nsw i32 %251, 4
store i32 %252, i32* %11
br label %270
253: ; preds = %244
%254 = load %struct.dirent*, %struct.dirent** %10
%255 = getelementptr inbounds %struct.dirent, %struct.dirent* %254, i32 0, i32 0
%256 = load i8*, i8** %255
%257 = call i64 @strcmp(i8* %256, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%258 = icmp eq i64 %257, 0
br i1 %258, label %259, label %262
259: ; preds = %253
%260 = load i32, i32* %11
%261 = add nsw i32 %260, 8
store i32 %261, i32* %11
br label %269
262: ; preds = %253
%263 = load i32, i32* @stderr
%264 = load %struct.dirent*, %struct.dirent** %10
%265 = getelementptr inbounds %struct.dirent, %struct.dirent* %264, i32 0, i32 0
%266 = load i8*, i8** %265
%267 = call i32 (i32, i8*, ...) @fprintf(i32 %263, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %266)
%268 = call i32 (...) @abort()
unreachable
269: ; preds = %259
br label %270
270: ; preds = %269, %250
br label %271
271: ; preds = %270, %241
br label %272
272: ; preds = %271, %232
br label %222
273: ; preds = %222
%274 = load i32, i32* %11
%275 = icmp eq i32 %274, 15
%276 = zext i1 %275 to i32
%277 = call i32 @assert(i32 %276)
%278 = load i32*, i32** %9
%279 = call i32 @closedir(i32* %278)
store i32 0, i32* %14
%280 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %280, i32** %12
%281 = load i32*, i32** %12
%282 = icmp ne i32* %281, null
%283 = zext i1 %282 to i32
%284 = call i32 @assert(i32 %283)
br label %285
285: ; preds = %335, %273
%286 = load i32*, i32** %12
%287 = call %struct.dirent* @readdir(i32* %286)
store %struct.dirent* %287, %struct.dirent** %13
%288 = icmp ne %struct.dirent* %287, null
br i1 %288, label %289, label %336
289: ; preds = %285
%290 = load %struct.dirent*, %struct.dirent** %13
%291 = getelementptr inbounds %struct.dirent, %struct.dirent* %290, i32 0, i32 0
%292 = load i8*, i8** %291
%293 = call i64 @strcmp(i8* %292, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%294 = icmp eq i64 %293, 0
br i1 %294, label %295, label %298
295: ; preds = %289
%296 = load i32, i32* %14
%297 = add nsw i32 %296, 1
store i32 %297, i32* %14
br label %335
298: ; preds = %289
%299 = load %struct.dirent*, %struct.dirent** %13
%300 = getelementptr inbounds %struct.dirent, %struct.dirent* %299, i32 0, i32 0
%301 = load i8*, i8** %300
%302 = call i64 @strcmp(i8* %301, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%303 = icmp eq i64 %302, 0
br i1 %303, label %304, label %307
304: ; preds = %298
%305 = load i32, i32* %14
%306 = add nsw i32 %305, 2
store i32 %306, i32* %14
br label %334
307: ; preds = %298
%308 = load %struct.dirent*, %struct.dirent** %13
%309 = getelementptr inbounds %struct.dirent, %struct.dirent* %308, i32 0, i32 0
%310 = load i8*, i8** %309
%311 = call i64 @strcmp(i8* %310, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%312 = icmp eq i64 %311, 0
br i1 %312, label %313, label %316
313: ; preds = %307
%314 = load i32, i32* %14
%315 = add nsw i32 %314, 4
store i32 %315, i32* %14
br label %333
316: ; preds = %307
%317 = load %struct.dirent*, %struct.dirent** %13
%318 = getelementptr inbounds %struct.dirent, %struct.dirent* %317, i32 0, i32 0
%319 = load i8*, i8** %318
%320 = call i64 @strcmp(i8* %319, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%321 = icmp eq i64 %320, 0
br i1 %321, label %322, label %325
322: ; preds = %316
%323 = load i32, i32* %14
%324 = add nsw i32 %323, 8
store i32 %324, i32* %14
br label %332
325: ; preds = %316
%326 = load i32, i32* @stderr
%327 = load %struct.dirent*, %struct.dirent** %13
%328 = getelementptr inbounds %struct.dirent, %struct.dirent* %327, i32 0, i32 0
%329 = load i8*, i8** %328
%330 = call i32 (i32, i8*, ...) @fprintf(i32 %326, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %329)
%331 = call i32 (...) @abort()
unreachable
332: ; preds = %322
br label %333
333: ; preds = %332, %313
br label %334
334: ; preds = %333, %304
br label %335
335: ; preds = %334, %295
br label %285
336: ; preds = %285
%337 = load i32, i32* %14
%338 = icmp eq i32 %337, 15
%339 = zext i1 %338 to i32
%340 = call i32 @assert(i32 %339)
%341 = call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
store i32 %341, i32* %15
%342 = load i32, i32* %15
%343 = icmp eq i32 %342, 0
%344 = zext i1 %343 to i32
%345 = call i32 @assert(i32 %344)
%346 = load i32*, i32** %12
%347 = call i32 @rewinddir(i32* %346)
store i32 0, i32* %14
br label %348
348: ; preds = %398, %336
%349 = load i32*, i32** %12
%350 = call %struct.dirent* @readdir(i32* %349)
store %struct.dirent* %350, %struct.dirent** %13
%351 = icmp ne %struct.dirent* %350, null
br i1 %351, label %352, label %399
352: ; preds = %348
%353 = load %struct.dirent*, %struct.dirent** %13
%354 = getelementptr inbounds %struct.dirent, %struct.dirent* %353, i32 0, i32 0
%355 = load i8*, i8** %354
%356 = call i64 @strcmp(i8* %355, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%357 = icmp eq i64 %356, 0
br i1 %357, label %358, label %361
358: ; preds = %352
%359 = load i32, i32* %14
%360 = add nsw i32 %359, 1
store i32 %360, i32* %14
br label %398
361: ; preds = %352
%362 = load %struct.dirent*, %struct.dirent** %13
%363 = getelementptr inbounds %struct.dirent, %struct.dirent* %362, i32 0, i32 0
%364 = load i8*, i8** %363
%365 = call i64 @strcmp(i8* %364, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%366 = icmp eq i64 %365, 0
br i1 %366, label %367, label %370
367: ; preds = %361
%368 = load i32, i32* %14
%369 = add nsw i32 %368, 2
store i32 %369, i32* %14
br label %397
370: ; preds = %361
%371 = load %struct.dirent*, %struct.dirent** %13
%372 = getelementptr inbounds %struct.dirent, %struct.dirent* %371, i32 0, i32 0
%373 = load i8*, i8** %372
%374 = call i64 @strcmp(i8* %373, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%375 = icmp eq i64 %374, 0
br i1 %375, label %376, label %379
376: ; preds = %370
%377 = load i32, i32* %14
%378 = add nsw i32 %377, 4
store i32 %378, i32* %14
br label %396
379: ; preds = %370
%380 = load %struct.dirent*, %struct.dirent** %13
%381 = getelementptr inbounds %struct.dirent, %struct.dirent* %380, i32 0, i32 0
%382 = load i8*, i8** %381
%383 = call i64 @strcmp(i8* %382, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%384 = icmp eq i64 %383, 0
br i1 %384, label %385, label %388
385: ; preds = %379
%386 = load i32, i32* %14
%387 = add nsw i32 %386, 8
store i32 %387, i32* %14
br label %395
388: ; preds = %379
%389 = load i32, i32* @stderr
%390 = load %struct.dirent*, %struct.dirent** %13
%391 = getelementptr inbounds %struct.dirent, %struct.dirent* %390, i32 0, i32 0
%392 = load i8*, i8** %391
%393 = call i32 (i32, i8*, ...) @fprintf(i32 %389, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %392)
%394 = call i32 (...) @abort()
unreachable
395: ; preds = %385
br label %396
396: ; preds = %395, %376
br label %397
397: ; preds = %396, %367
br label %398
398: ; preds = %397, %358
br label %348
399: ; preds = %348
%400 = load i32, i32* %14
%401 = icmp eq i32 %400, 15
%402 = zext i1 %401 to i32
%403 = call i32 @assert(i32 %402)
%404 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %404, i32* %15
%405 = load i32, i32* %15
%406 = icmp eq i32 %405, 0
%407 = zext i1 %406 to i32
%408 = call i32 @assert(i32 %407)
%409 = load i32*, i32** %12
%410 = call i32 @closedir(i32* %409)
store i32 0, i32* %18
%411 = call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
store i32* %411, i32** %16
%412 = load i32*, i32** %16
%413 = icmp eq i32* %412, null
br i1 %413, label %414, label %418
414: ; preds = %399
%415 = load i32, i32* @stderr
%416 = call i32 (i32, i8*, ...) @fprintf(i32 %415, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%417 = call i32 (...) @abort()
unreachable
418: ; preds = %399
br label %419
419: ; preds = %469, %418
%420 = load i32*, i32** %16
%421 = call %struct.dirent* @readdir(i32* %420)
store %struct.dirent* %421, %struct.dirent** %17
%422 = icmp ne %struct.dirent* %421, null
br i1 %422, label %423, label %470
423: ; preds = %419
%424 = load %struct.dirent*, %struct.dirent** %17
%425 = getelementptr inbounds %struct.dirent, %struct.dirent* %424, i32 0, i32 0
%426 = load i8*, i8** %425
%427 = call i64 @strcmp(i8* %426, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%428 = icmp eq i64 %427, 0
br i1 %428, label %429, label %432
429: ; preds = %423
%430 = load i32, i32* %18
%431 = add nsw i32 %430, 1
store i32 %431, i32* %18
br label %469
432: ; preds = %423
%433 = load %struct.dirent*, %struct.dirent** %17
%434 = getelementptr inbounds %struct.dirent, %struct.dirent* %433, i32 0, i32 0
%435 = load i8*, i8** %434
%436 = call i64 @strcmp(i8* %435, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%437 = icmp eq i64 %436, 0
br i1 %437, label %438, label %441
438: ; preds = %432
%439 = load i32, i32* %18
%440 = add nsw i32 %439, 2
store i32 %440, i32* %18
br label %468
441: ; preds = %432
%442 = load %struct.dirent*, %struct.dirent** %17
%443 = getelementptr inbounds %struct.dirent, %struct.dirent* %442, i32 0, i32 0
%444 = load i8*, i8** %443
%445 = call i64 @strcmp(i8* %444, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%446 = icmp eq i64 %445, 0
br i1 %446, label %447, label %450
447: ; preds = %441
%448 = load i32, i32* %18
%449 = add nsw i32 %448, 4
store i32 %449, i32* %18
br label %467
450: ; preds = %441
%451 = load %struct.dirent*, %struct.dirent** %17
%452 = getelementptr inbounds %struct.dirent, %struct.dirent* %451, i32 0, i32 0
%453 = load i8*, i8** %452
%454 = call i64 @strcmp(i8* %453, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%455 = icmp eq i64 %454, 0
br i1 %455, label %456, label %459
456: ; preds = %450
%457 = load i32, i32* %18
%458 = add nsw i32 %457, 8
store i32 %458, i32* %18
br label %466
459: ; preds = %450
%460 = load i32, i32* @stderr
%461 = load %struct.dirent*, %struct.dirent** %17
%462 = getelementptr inbounds %struct.dirent, %struct.dirent* %461, i32 0, i32 0
%463 = load i8*, i8** %462
%464 = call i32 (i32, i8*, ...) @fprintf(i32 %460, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %463)
%465 = call i32 (...) @abort()
unreachable
466: ; preds = %456
br label %467
467: ; preds = %466, %447
br label %468
468: ; preds = %467, %438
br label %469
469: ; preds = %468, %429
br label %419
470: ; preds = %419
%471 = load i32, i32* %18
%472 = icmp eq i32 %471, 15
%473 = zext i1 %472 to i32
%474 = call i32 @assert(i32 %473)
%475 = load i32*, i32** %16
%476 = call i32 @closedir(i32* %475)
%477 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%478 = load i32, i32* @EXIT_SUCCESS
ret i32 %478
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@DT_REG = global i64 0
@S_IFREG = global i64 0
@DT_DIR = global i64 0
@S_IFDIR = global i64 0
@DT_FIFO = global i64 0
@S_IFIFO = global i64 0
@DT_SOCK = global i64 0
@S_IFSOCK = global i64 0
@DT_CHR = global i64 0
@S_IFCHR = global i64 0
@DT_BLK = global i64 0
@S_IFBLK = global i64 0
@.str = [8 x i8] c"tests/1\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"Directory tests/1 not found\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [5 x i8] c"file\00"
@.str.5 = [4 x i8] c"dir\00"
@.str.6 = [20 x i8] c"Unexpected file %s\0A\00"
@.str.7 = [6 x i8] c"tests\00"
@.str.8 = [8 x i8] c"tests/2\00"
@.str.9 = [29 x i8] c"Directory tests/2 not found\0A\00"
@.str.10 = [9 x i8] c"file.txt\00"
@.str.11 = [19 x i8] c"Testfile-1.2.3.dat\00"
@EXIT_SUCCESS = global i32 0
@str = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i64, i64* @DT_REG
%4 = tail call i64 @DTTOIF(i64 %3)
%5 = load i64, i64* @S_IFREG
%6 = icmp eq i64 %4, %5
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load i64, i64* @DT_DIR
%10 = tail call i64 @DTTOIF(i64 %9)
%11 = load i64, i64* @S_IFDIR
%12 = icmp eq i64 %10, %11
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = load i64, i64* @DT_FIFO
%16 = tail call i64 @DTTOIF(i64 %15)
%17 = load i64, i64* @S_IFIFO
%18 = icmp eq i64 %16, %17
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = load i64, i64* @DT_SOCK
%22 = tail call i64 @DTTOIF(i64 %21)
%23 = load i64, i64* @S_IFSOCK
%24 = icmp eq i64 %22, %23
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = load i64, i64* @DT_CHR
%28 = tail call i64 @DTTOIF(i64 %27)
%29 = load i64, i64* @S_IFCHR
%30 = icmp eq i64 %28, %29
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = load i64, i64* @DT_BLK
%34 = tail call i64 @DTTOIF(i64 %33)
%35 = load i64, i64* @S_IFBLK
%36 = icmp eq i64 %34, %35
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = load i64, i64* @S_IFREG
%40 = tail call i64 @IFTODT(i64 %39)
%41 = load i64, i64* @DT_REG
%42 = icmp eq i64 %40, %41
%43 = zext i1 %42 to i32
%44 = tail call i32 @assert(i32 %43)
%45 = load i64, i64* @S_IFDIR
%46 = tail call i64 @IFTODT(i64 %45)
%47 = load i64, i64* @DT_DIR
%48 = icmp eq i64 %46, %47
%49 = zext i1 %48 to i32
%50 = tail call i32 @assert(i32 %49)
%51 = load i64, i64* @S_IFIFO
%52 = tail call i64 @IFTODT(i64 %51)
%53 = load i64, i64* @DT_FIFO
%54 = icmp eq i64 %52, %53
%55 = zext i1 %54 to i32
%56 = tail call i32 @assert(i32 %55)
%57 = load i64, i64* @S_IFSOCK
%58 = tail call i64 @IFTODT(i64 %57)
%59 = load i64, i64* @DT_SOCK
%60 = icmp eq i64 %58, %59
%61 = zext i1 %60 to i32
%62 = tail call i32 @assert(i32 %61)
%63 = load i64, i64* @S_IFCHR
%64 = tail call i64 @IFTODT(i64 %63)
%65 = load i64, i64* @DT_CHR
%66 = icmp eq i64 %64, %65
%67 = zext i1 %66 to i32
%68 = tail call i32 @assert(i32 %67)
%69 = load i64, i64* @S_IFBLK
%70 = tail call i64 @IFTODT(i64 %69)
%71 = load i64, i64* @DT_BLK
%72 = icmp eq i64 %70, %71
%73 = zext i1 %72 to i32
%74 = tail call i32 @assert(i32 %73)
%75 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%76 = icmp eq i32* %75, null
br i1 %76, label %80, label %77
77: ; preds = %2
%78 = tail call %struct.dirent* @readdir(i32* %75)
%79 = icmp eq %struct.dirent* %78, null
br i1 %79, label %116, label %84
80: ; preds = %2
%81 = load i32, i32* @stderr
%82 = tail call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%83 = tail call i32 (...) @abort()
unreachable
84: ; preds = %77, %108
%85 = phi %struct.dirent* [ %111, %108 ], [ %78, %77 ]
%86 = phi i32 [ %110, %108 ], [ 0, %77 ]
%87 = getelementptr inbounds %struct.dirent, %struct.dirent* %85, i64 0, i32 0
%88 = load i8*, i8** %87
%89 = tail call i64 @strcmp(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%90 = icmp eq i64 %89, 0
br i1 %90, label %108, label %91
91: ; preds = %84
%92 = load i8*, i8** %87
%93 = tail call i64 @strcmp(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %108, label %95
95: ; preds = %91
%96 = load i8*, i8** %87
%97 = tail call i64 @strcmp(i8* %96, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%98 = icmp eq i64 %97, 0
br i1 %98, label %108, label %99
99: ; preds = %95
%100 = load i8*, i8** %87
%101 = tail call i64 @strcmp(i8* %100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
br i1 %102, label %108, label %103
103: ; preds = %99
%104 = load i32, i32* @stderr
%105 = load i8*, i8** %87
%106 = tail call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %105)
%107 = tail call i32 (...) @abort()
unreachable
108: ; preds = %99, %95, %91, %84
%109 = phi i32 [ 1, %84 ], [ 2, %91 ], [ 4, %95 ], [ 8, %99 ]
%110 = add nuw nsw i32 %86, %109
%111 = tail call %struct.dirent* @readdir(i32* %75)
%112 = icmp eq %struct.dirent* %111, null
br i1 %112, label %113, label %84
113: ; preds = %108
%114 = icmp eq i32 %110, 15
%115 = zext i1 %114 to i32
br label %116
116: ; preds = %113, %77
%117 = phi i32 [ 0, %77 ], [ %115, %113 ]
%118 = tail call i32 @assert(i32 %117)
%119 = tail call i32 @closedir(i32* %75)
%120 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%121 = icmp ne i32* %120, null
%122 = zext i1 %121 to i32
%123 = tail call i32 @assert(i32 %122)
%124 = tail call %struct.dirent* @readdir(i32* %120)
%125 = icmp eq %struct.dirent* %124, null
br i1 %125, label %158, label %126
126: ; preds = %116, %150
%127 = phi %struct.dirent* [ %153, %150 ], [ %124, %116 ]
%128 = phi i32 [ %152, %150 ], [ 0, %116 ]
%129 = getelementptr inbounds %struct.dirent, %struct.dirent* %127, i64 0, i32 0
%130 = load i8*, i8** %129
%131 = tail call i64 @strcmp(i8* %130, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%132 = icmp eq i64 %131, 0
br i1 %132, label %150, label %133
133: ; preds = %126
%134 = load i8*, i8** %129
%135 = tail call i64 @strcmp(i8* %134, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%136 = icmp eq i64 %135, 0
br i1 %136, label %150, label %137
137: ; preds = %133
%138 = load i8*, i8** %129
%139 = tail call i64 @strcmp(i8* %138, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%140 = icmp eq i64 %139, 0
br i1 %140, label %150, label %141
141: ; preds = %137
%142 = load i8*, i8** %129
%143 = tail call i64 @strcmp(i8* %142, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%144 = icmp eq i64 %143, 0
br i1 %144, label %150, label %145
145: ; preds = %141
%146 = load i32, i32* @stderr
%147 = load i8*, i8** %129
%148 = tail call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %147)
%149 = tail call i32 (...) @abort()
unreachable
150: ; preds = %141, %137, %133, %126
%151 = phi i32 [ 1, %126 ], [ 2, %133 ], [ 4, %137 ], [ 8, %141 ]
%152 = add nuw nsw i32 %128, %151
%153 = tail call %struct.dirent* @readdir(i32* %120)
%154 = icmp eq %struct.dirent* %153, null
br i1 %154, label %155, label %126
155: ; preds = %150
%156 = icmp eq i32 %152, 15
%157 = zext i1 %156 to i32
br label %158
158: ; preds = %155, %116
%159 = phi i32 [ 0, %116 ], [ %157, %155 ]
%160 = tail call i32 @assert(i32 %159)
%161 = tail call i32 @rewinddir(i32* %120)
%162 = tail call %struct.dirent* @readdir(i32* %120)
%163 = icmp eq %struct.dirent* %162, null
br i1 %163, label %196, label %164
164: ; preds = %158, %188
%165 = phi %struct.dirent* [ %191, %188 ], [ %162, %158 ]
%166 = phi i32 [ %190, %188 ], [ 0, %158 ]
%167 = getelementptr inbounds %struct.dirent, %struct.dirent* %165, i64 0, i32 0
%168 = load i8*, i8** %167
%169 = tail call i64 @strcmp(i8* %168, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%170 = icmp eq i64 %169, 0
br i1 %170, label %188, label %171
171: ; preds = %164
%172 = load i8*, i8** %167
%173 = tail call i64 @strcmp(i8* %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%174 = icmp eq i64 %173, 0
br i1 %174, label %188, label %175
175: ; preds = %171
%176 = load i8*, i8** %167
%177 = tail call i64 @strcmp(i8* %176, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%178 = icmp eq i64 %177, 0
br i1 %178, label %188, label %179
179: ; preds = %175
%180 = load i8*, i8** %167
%181 = tail call i64 @strcmp(i8* %180, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%182 = icmp eq i64 %181, 0
br i1 %182, label %188, label %183
183: ; preds = %179
%184 = load i32, i32* @stderr
%185 = load i8*, i8** %167
%186 = tail call i32 (i32, i8*, ...) @fprintf(i32 %184, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %185)
%187 = tail call i32 (...) @abort()
unreachable
188: ; preds = %179, %175, %171, %164
%189 = phi i32 [ 1, %164 ], [ 2, %171 ], [ 4, %175 ], [ 8, %179 ]
%190 = add nuw nsw i32 %166, %189
%191 = tail call %struct.dirent* @readdir(i32* %120)
%192 = icmp eq %struct.dirent* %191, null
br i1 %192, label %193, label %164
193: ; preds = %188
%194 = icmp eq i32 %190, 15
%195 = zext i1 %194 to i32
br label %196
196: ; preds = %193, %158
%197 = phi i32 [ 0, %158 ], [ %195, %193 ]
%198 = tail call i32 @assert(i32 %197)
%199 = tail call i32 @closedir(i32* %120)
%200 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%201 = icmp ne i32* %200, null
%202 = zext i1 %201 to i32
%203 = tail call i32 @assert(i32 %202)
%204 = tail call %struct.dirent* @readdir(i32* %200)
%205 = icmp eq %struct.dirent* %204, null
br i1 %205, label %238, label %206
206: ; preds = %196, %230
%207 = phi %struct.dirent* [ %233, %230 ], [ %204, %196 ]
%208 = phi i32 [ %232, %230 ], [ 0, %196 ]
%209 = getelementptr inbounds %struct.dirent, %struct.dirent* %207, i64 0, i32 0
%210 = load i8*, i8** %209
%211 = tail call i64 @strcmp(i8* %210, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%212 = icmp eq i64 %211, 0
br i1 %212, label %230, label %213
213: ; preds = %206
%214 = load i8*, i8** %209
%215 = tail call i64 @strcmp(i8* %214, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%216 = icmp eq i64 %215, 0
br i1 %216, label %230, label %217
217: ; preds = %213
%218 = load i8*, i8** %209
%219 = tail call i64 @strcmp(i8* %218, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%220 = icmp eq i64 %219, 0
br i1 %220, label %230, label %221
221: ; preds = %217
%222 = load i8*, i8** %209
%223 = tail call i64 @strcmp(i8* %222, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%224 = icmp eq i64 %223, 0
br i1 %224, label %230, label %225
225: ; preds = %221
%226 = load i32, i32* @stderr
%227 = load i8*, i8** %209
%228 = tail call i32 (i32, i8*, ...) @fprintf(i32 %226, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %227)
%229 = tail call i32 (...) @abort()
unreachable
230: ; preds = %221, %217, %213, %206
%231 = phi i32 [ 1, %206 ], [ 2, %213 ], [ 4, %217 ], [ 8, %221 ]
%232 = add nuw nsw i32 %208, %231
%233 = tail call %struct.dirent* @readdir(i32* %200)
%234 = icmp eq %struct.dirent* %233, null
br i1 %234, label %235, label %206
235: ; preds = %230
%236 = icmp eq i32 %232, 15
%237 = zext i1 %236 to i32
br label %238
238: ; preds = %235, %196
%239 = phi i32 [ 0, %196 ], [ %237, %235 ]
%240 = tail call i32 @assert(i32 %239)
%241 = tail call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%242 = icmp eq i32 %241, 0
%243 = zext i1 %242 to i32
%244 = tail call i32 @assert(i32 %243)
%245 = tail call i32 @rewinddir(i32* %200)
%246 = tail call %struct.dirent* @readdir(i32* %200)
%247 = icmp eq %struct.dirent* %246, null
br i1 %247, label %280, label %248
248: ; preds = %238, %272
%249 = phi %struct.dirent* [ %275, %272 ], [ %246, %238 ]
%250 = phi i32 [ %274, %272 ], [ 0, %238 ]
%251 = getelementptr inbounds %struct.dirent, %struct.dirent* %249, i64 0, i32 0
%252 = load i8*, i8** %251
%253 = tail call i64 @strcmp(i8* %252, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%254 = icmp eq i64 %253, 0
br i1 %254, label %272, label %255
255: ; preds = %248
%256 = load i8*, i8** %251
%257 = tail call i64 @strcmp(i8* %256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%258 = icmp eq i64 %257, 0
br i1 %258, label %272, label %259
259: ; preds = %255
%260 = load i8*, i8** %251
%261 = tail call i64 @strcmp(i8* %260, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%262 = icmp eq i64 %261, 0
br i1 %262, label %272, label %263
263: ; preds = %259
%264 = load i8*, i8** %251
%265 = tail call i64 @strcmp(i8* %264, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%266 = icmp eq i64 %265, 0
br i1 %266, label %272, label %267
267: ; preds = %263
%268 = load i32, i32* @stderr
%269 = load i8*, i8** %251
%270 = tail call i32 (i32, i8*, ...) @fprintf(i32 %268, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %269)
%271 = tail call i32 (...) @abort()
unreachable
272: ; preds = %263, %259, %255, %248
%273 = phi i32 [ 1, %248 ], [ 2, %255 ], [ 4, %259 ], [ 8, %263 ]
%274 = add nuw nsw i32 %250, %273
%275 = tail call %struct.dirent* @readdir(i32* %200)
%276 = icmp eq %struct.dirent* %275, null
br i1 %276, label %277, label %248
277: ; preds = %272
%278 = icmp eq i32 %274, 15
%279 = zext i1 %278 to i32
br label %280
280: ; preds = %277, %238
%281 = phi i32 [ 0, %238 ], [ %279, %277 ]
%282 = tail call i32 @assert(i32 %281)
%283 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%284 = icmp eq i32 %283, 0
%285 = zext i1 %284 to i32
%286 = tail call i32 @assert(i32 %285)
%287 = tail call i32 @closedir(i32* %200)
%288 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%289 = icmp eq i32* %288, null
br i1 %289, label %293, label %290
290: ; preds = %280
%291 = tail call %struct.dirent* @readdir(i32* %288)
%292 = icmp eq %struct.dirent* %291, null
br i1 %292, label %329, label %297
293: ; preds = %280
%294 = load i32, i32* @stderr
%295 = tail call i32 (i32, i8*, ...) @fprintf(i32 %294, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%296 = tail call i32 (...) @abort()
unreachable
297: ; preds = %290, %321
%298 = phi %struct.dirent* [ %324, %321 ], [ %291, %290 ]
%299 = phi i32 [ %323, %321 ], [ 0, %290 ]
%300 = getelementptr inbounds %struct.dirent, %struct.dirent* %298, i64 0, i32 0
%301 = load i8*, i8** %300
%302 = tail call i64 @strcmp(i8* %301, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%303 = icmp eq i64 %302, 0
br i1 %303, label %321, label %304
304: ; preds = %297
%305 = load i8*, i8** %300
%306 = tail call i64 @strcmp(i8* %305, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%307 = icmp eq i64 %306, 0
br i1 %307, label %321, label %308
308: ; preds = %304
%309 = load i8*, i8** %300
%310 = tail call i64 @strcmp(i8* %309, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%311 = icmp eq i64 %310, 0
br i1 %311, label %321, label %312
312: ; preds = %308
%313 = load i8*, i8** %300
%314 = tail call i64 @strcmp(i8* %313, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%315 = icmp eq i64 %314, 0
br i1 %315, label %321, label %316
316: ; preds = %312
%317 = load i32, i32* @stderr
%318 = load i8*, i8** %300
%319 = tail call i32 (i32, i8*, ...) @fprintf(i32 %317, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %318)
%320 = tail call i32 (...) @abort()
unreachable
321: ; preds = %312, %308, %304, %297
%322 = phi i32 [ 1, %297 ], [ 2, %304 ], [ 4, %308 ], [ 8, %312 ]
%323 = add nuw nsw i32 %299, %322
%324 = tail call %struct.dirent* @readdir(i32* %288)
%325 = icmp eq %struct.dirent* %324, null
br i1 %325, label %326, label %297
326: ; preds = %321
%327 = icmp eq i32 %323, 15
%328 = zext i1 %327 to i32
br label %329
329: ; preds = %326, %290
%330 = phi i32 [ 0, %290 ], [ %328, %326 ]
%331 = tail call i32 @assert(i32 %330)
%332 = tail call i32 @closedir(i32* %288)
%333 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%334 = load i32, i32* @EXIT_SUCCESS
ret i32 %334
}