#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  char st_size;
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ off_t;
typedef int /*<<< orphan*/ lenfname;
typedef int /*<<< orphan*/ found;
typedef int /*<<< orphan*/ flag_f;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ chdir(char *);
int closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int write(int, ...);
void list(int fd, char *dirname, char *filename) {
  DIR *dp;
  DIR *dc;
  struct dirent *de;
  struct stat buf;
  int found = 0;
  char *fname;
  char flag_f = '#';
  size_t lenfname = 0;
  dp = opendir(dirname);
  if (dp == NULL) {
    perror("Error opendir");
    exit(EXIT_FAILURE);
  }
  while ((de = readdir(dp)) != NULL) {
    if (strcmp(de->d_name, filename) == 0) {
      found = 1;
      if (write(fd, &found, sizeof(found)) < sizeof(found)) {
        perror("Error write");
        exit(EXIT_FAILURE);
      }
      if (stat(de->d_name, &buf) == -1) {
        perror("Error stat");
        exit(EXIT_FAILURE);
      }
      if (S_ISREG(buf.st_mode)) {
        if (write(fd, "REG", 3) < 3) {
          perror("Error write");
          exit(EXIT_SUCCESS);
        }
        if (write(fd, &buf.st_size, sizeof(off_t)) < sizeof(off_t)) {
          perror("Error write");
          exit(EXIT_FAILURE);
        }
      } else {
        if (S_ISDIR(buf.st_mode)) {
          if (write(fd, "DIR", 3) < 3) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          chdir(filename);
          dc = opendir(".");
          if (dc == NULL) {
            perror("Error opendir");
            exit(EXIT_FAILURE);
          }
          while ((de = readdir(dc)) != NULL) {
            if ((strcmp(de->d_name, ".") == 0) ||
                (strcmp(de->d_name, "..") == 0)) {
              continue;
            }
            if (stat(de->d_name, &buf) == -1) {
              perror("Error stat");
              exit(EXIT_FAILURE);
            }
            if (S_ISREG(buf.st_mode)) {
              flag_f = 'f';
              if (write(fd, &flag_f, sizeof(flag_f)) < sizeof(flag_f)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              fname = (char *)malloc(sizeof(char) * 4096 + 1);
              if (fname == NULL) {
                perror("Error malloc");
                exit(EXIT_FAILURE);
              }
              if (strlen(de->d_name) >= 4096) {
                perror("Error: The length of the filename is too big. Memory "
                       "leak");
                exit(EXIT_FAILURE);
              }
              strcpy(fname, de->d_name);
              lenfname = strlen(fname);
              if (write(fd, &lenfname, sizeof(lenfname)) < sizeof(lenfname)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              if (write(fd, fname, lenfname) < lenfname) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              if (write(fd, &buf.st_size, sizeof(off_t)) < sizeof(off_t)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              free(fname);
            } else {
              flag_f = 'd';
              if (write(fd, &flag_f, sizeof(flag_f)) < sizeof(flag_f)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
            }
          }
          flag_f = 'e';
          if (write(fd, &flag_f, sizeof(flag_f)) < sizeof(flag_f)) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          if (closedir(dc) == -1) {
            perror("Error closedir");
            exit(EXIT_FAILURE);
          }
        }
      }
    }
  }
  if (closedir(dp) == -1) {
    perror("Error closedir");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x3c(%rbp)
movb   $0x23,-0x49(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1248 <list+0x58>
lea    0xdcb(%rip),%rdi
call   1100 <perror@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    124d <list+0x5d>
mov    -0x20(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     16df <list+0x4ef>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    16da <list+0x4ea>
movl   $0x1,-0x3c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    12be <list+0xce>
lea    0xd63(%rip),%rdi
call   1100 <perror@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x38(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
jne    12f1 <list+0x101>
lea    0xd3c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x34(%rbp),%edi
call   10d0 <S_ISREG@plt>
cmp    $0x0,%rax
je     137a <list+0x18a>
mov    -0x4(%rbp),%edi
lea    0xd18(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    133c <list+0x14c>
lea    0xce5(%rip),%rdi
call   1100 <perror@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    1375 <list+0x185>
lea    0xcac(%rip),%rdi
call   1100 <perror@plt>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    16d5 <list+0x4e5>
mov    -0x34(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     16d0 <list+0x4e0>
mov    -0x4(%rbp),%edi
lea    0xc93(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    13c5 <list+0x1d5>
lea    0xc5c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1080 <chdir@plt>
lea    0xc59(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1403 <list+0x213>
lea    0xc10(%rip),%rdi
call   1100 <perror@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    1408 <list+0x218>
mov    -0x28(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1662 <list+0x472>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xc01(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1459 <list+0x269>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xbe3(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    145e <list+0x26e>
jmp    1408 <list+0x218>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x38(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1491 <list+0x2a1>
lea    0xb9c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b56(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x34(%rbp),%edi
call   10d0 <S_ISREG@plt>
cmp    $0x0,%rax
je     161b <list+0x42b>
movb   $0x66,-0x49(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x49(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    14e0 <list+0x2f0>
lea    0xb41(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    $0x1001,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1513 <list+0x323>
lea    0xb30(%rip),%rdi
call   1100 <perror@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
cmp    $0x1000,%eax
jl     1544 <list+0x354>
lea    0xb0c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2aa3(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,-0x58(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x8,%rax
jae    159c <list+0x3ac>
lea    0xa85(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a4b(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    -0x58(%rbp),%rax
jae    15d4 <list+0x3e4>
lea    0xa4d(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a13(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    160d <list+0x41d>
lea    0xa14(%rip),%rdi
call   1100 <perror@plt>
mov    0x29da(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    165d <list+0x46d>
movb   $0x64,-0x49(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x49(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1658 <list+0x468>
lea    0x9c9(%rip),%rdi
call   1100 <perror@plt>
mov    0x298f(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    165d <list+0x46d>
jmp    1408 <list+0x218>
movb   $0x65,-0x49(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x49(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    169f <list+0x4af>
lea    0x982(%rip),%rdi
call   1100 <perror@plt>
mov    0x2948(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    16cb <list+0x4db>
lea    0x9bf(%rip),%rdi
call   1100 <perror@plt>
mov    0x291c(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    16d0 <list+0x4e0>
jmp    16d5 <list+0x4e5>
jmp    16da <list+0x4ea>
jmp    124d <list+0x5d>
mov    -0x20(%rbp),%rdi
call   10a0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    170b <list+0x51b>
lea    0x97f(%rip),%rdi
call   1100 <perror@plt>
mov    0x28dc(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %edi,%r14d
movl   $0x0,0xc(%rsp)
movb   $0x23,0xb(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsi,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     155b <list+0x36b>
mov    %rax,%rbp
mov    %rax,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     1501 <list+0x311>
mov    %rax,%rbx
lea    0xc(%rsp),%r12
lea    0x18(%rsp),%r13
mov    %rbp,0x20(%rsp)
jmp    1274 <list+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   10e0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1501 <list+0x311>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1260 <list+0x70>
movl   $0x1,0xc(%rsp)
mov    $0x4,%edx
mov    %r14d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    151d <list+0x32d>
mov    (%rbx),%rdi
mov    %r13,%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
je     1526 <list+0x336>
mov    0x1c(%rsp),%edi
call   10d0 <S_ISREG@plt>
test   %rax,%rax
je     1308 <list+0x118>
mov    %r14d,%edi
lea    0xd52(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    1541 <list+0x351>
mov    $0x4,%edx
mov    %r14d,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
ja     1260 <list+0x70>
jmp    151d <list+0x32d>
mov    0x1c(%rsp),%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
je     1260 <list+0x70>
mov    %r14d,%edi
lea    0xd05(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    151d <list+0x32d>
mov    %r15,%rbp
mov    %r15,%rdi
call   1080 <chdir@plt>
lea    0xce3(%rip),%rbx
mov    %rbx,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     155b <list+0x36b>
mov    %rax,%r15
jmp    1390 <list+0x1a0>
movb   $0x64,0xb(%rsp)
mov    $0x1,%edx
mov    %r14d,%edi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     151d <list+0x32d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   10e0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     14c4 <list+0x2d4>
mov    (%r12),%rdi
mov    %rbx,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1390 <list+0x1a0>
mov    (%r12),%rdi
lea    0xc6d(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1390 <list+0x1a0>
mov    (%r12),%rdi
mov    %r13,%rsi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
je     1526 <list+0x336>
mov    0x1c(%rsp),%edi
call   10d0 <S_ISREG@plt>
test   %rax,%rax
je     1361 <list+0x171>
mov    %r13,%rbx
movb   $0x66,0xb(%rsp)
mov    $0x1,%edx
mov    %r14d,%edi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     151d <list+0x32d>
mov    $0x1001,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     152f <list+0x33f>
mov    %rax,%r13
mov    (%r12),%rdi
call   1070 <strlen@plt>
cmp    $0x1000,%eax
jge    1538 <list+0x348>
mov    (%r12),%rsi
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,0x10(%rsp)
mov    $0x8,%edx
mov    %r14d,%edi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x7,%eax
jbe    151d <list+0x32d>
mov    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cltq
cmp    %rax,0x10(%rsp)
ja     151d <list+0x32d>
mov    $0x4,%edx
mov    %r14d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    151d <list+0x32d>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%r13
lea    0xb6f(%rip),%rbx
jmp    1390 <list+0x1a0>
movb   $0x65,0xb(%rsp)
mov    $0x1,%edx
mov    %r14d,%edi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     151d <list+0x32d>
mov    %r15,%rdi
call   10a0 <closedir@plt>
cmp    $0xffffffff,%eax
mov    %rbp,%r15
mov    0x20(%rsp),%rbp
lea    0xc(%rsp),%r12
jne    1260 <list+0x70>
jmp    1564 <list+0x374>
mov    %rbp,%rdi
call   10a0 <closedir@plt>
cmp    $0xffffffff,%eax
je     1564 <list+0x374>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaea(%rip),%rdi
jmp    156b <list+0x37b>
lea    0xaed(%rip),%rdi
jmp    156b <list+0x37b>
lea    0xafa(%rip),%rdi
jmp    156b <list+0x37b>
lea    0xafe(%rip),%rdi
jmp    156b <list+0x37b>
lea    0xac6(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a84(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xa9e(%rip),%rdi
jmp    156b <list+0x37b>
lea    0xb0c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i8, i32 }
@.str = [14 x i8] c"Error opendir\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"Error write\00"
@.str.2 = [11 x i8] c"Error stat\00"
@.str.3 = [4 x i8] c"REG\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [4 x i8] c"DIR\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [3 x i8] c"..\00"
@.str.7 = [13 x i8] c"Error malloc\00"
@.str.8 = [58 x i8] c"Error: The length of the filename is too big. Memory leak\00"
@.str.9 = [15 x i8] c"Error closedir\00"
define void @list(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca %struct.dirent*
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8
%14 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %11
store i8 35, i8* %13
store i64 0, i64* %14
%15 = load i8*, i8** %5
%16 = call i32* @opendir(i8* %15)
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %3
%20 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %3
br label %24
24: ; preds = %235, %23
%25 = load i32*, i32** %7
%26 = call %struct.dirent* @readdir(i32* %25)
store %struct.dirent* %26, %struct.dirent** %9
%27 = icmp ne %struct.dirent* %26, null
br i1 %27, label %28, label %236
28: ; preds = %24
%29 = load %struct.dirent*, %struct.dirent** %9
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = load i8*, i8** %6
%33 = call i64 @strcmp(i8* %31, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %235
35: ; preds = %28
store i32 1, i32* %11
%36 = load i32, i32* %4
%37 = call i32 (i32, ...) @write(i32 %36, i32* %11, i64 4)
%38 = sext i32 %37 to i64
%39 = icmp ult i64 %38, 4
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %35
%45 = load %struct.dirent*, %struct.dirent** %9
%46 = getelementptr inbounds %struct.dirent, %struct.dirent* %45, i32 0, i32 0
%47 = load i8*, i8** %46
%48 = call i32 @stat(i8* %47, %struct.stat* %10)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %54
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %44
%55 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%56 = load i32, i32* %55
%57 = call i64 @S_ISREG(i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %78
59: ; preds = %54
%60 = load i32, i32* %4
%61 = call i32 (i32, ...) @write(i32 %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%65 = load i32, i32* @EXIT_SUCCESS
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %59
%68 = load i32, i32* %4
%69 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%70 = call i32 (i32, ...) @write(i32 %68, i8* %69, i64 4)
%71 = sext i32 %70 to i64
%72 = icmp ult i64 %71, 4
br i1 %72, label %73, label %77
73: ; preds = %67
%74 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %67
br label %234
78: ; preds = %54
%79 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%80 = load i32, i32* %79
%81 = call i64 @S_ISDIR(i32 %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %233
83: ; preds = %78
%84 = load i32, i32* %4
%85 = call i32 (i32, ...) @write(i32 %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%86 = icmp slt i32 %85, 3
br i1 %86, label %87, label %91
87: ; preds = %83
%88 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %83
%92 = load i8*, i8** %6
%93 = call i32 @chdir(i8* %92)
%94 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %94, i32** %8
%95 = load i32*, i32** %8
%96 = icmp eq i32* %95, null
br i1 %96, label %97, label %101
97: ; preds = %91
%98 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
%100 = call i32 @exit(i32 %99)
unreachable
101: ; preds = %91
br label %102
102: ; preds = %214, %118, %101
%103 = load i32*, i32** %8
%104 = call %struct.dirent* @readdir(i32* %103)
store %struct.dirent* %104, %struct.dirent** %9
%105 = icmp ne %struct.dirent* %104, null
br i1 %105, label %106, label %215
106: ; preds = %102
%107 = load %struct.dirent*, %struct.dirent** %9
%108 = getelementptr inbounds %struct.dirent, %struct.dirent* %107, i32 0, i32 0
%109 = load i8*, i8** %108
%110 = call i64 @strcmp(i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%111 = icmp eq i64 %110, 0
br i1 %111, label %118, label %112
112: ; preds = %106
%113 = load %struct.dirent*, %struct.dirent** %9
%114 = getelementptr inbounds %struct.dirent, %struct.dirent* %113, i32 0, i32 0
%115 = load i8*, i8** %114
%116 = call i64 @strcmp(i8* %115, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %112, %106
br label %102
119: ; preds = %112
%120 = load %struct.dirent*, %struct.dirent** %9
%121 = getelementptr inbounds %struct.dirent, %struct.dirent* %120, i32 0, i32 0
%122 = load i8*, i8** %121
%123 = call i32 @stat(i8* %122, %struct.stat* %10)
%124 = icmp eq i32 %123, -1
br i1 %124, label %125, label %129
125: ; preds = %119
%126 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%127 = load i32, i32* @EXIT_FAILURE
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %119
%130 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%131 = load i32, i32* %130
%132 = call i64 @S_ISREG(i32 %131)
%133 = icmp ne i64 %132, 0
br i1 %133, label %134, label %204
134: ; preds = %129
store i8 102, i8* %13
%135 = load i32, i32* %4
%136 = call i32 (i32, ...) @write(i32 %135, i8* %13, i64 1)
%137 = sext i32 %136 to i64
%138 = icmp ult i64 %137, 1
br i1 %138, label %139, label %143
139: ; preds = %134
%140 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
143: ; preds = %134
%144 = call i64 @malloc(i32 4097)
%145 = inttoptr i64 %144 to i8*
store i8* %145, i8** %12
%146 = load i8*, i8** %12
%147 = icmp eq i8* %146, null
br i1 %147, label %148, label %152
148: ; preds = %143
%149 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%150 = load i32, i32* @EXIT_FAILURE
%151 = call i32 @exit(i32 %150)
unreachable
152: ; preds = %143
%153 = load %struct.dirent*, %struct.dirent** %9
%154 = getelementptr inbounds %struct.dirent, %struct.dirent* %153, i32 0, i32 0
%155 = load i8*, i8** %154
%156 = call i32 @strlen(i8* %155)
%157 = icmp sge i32 %156, 4096
br i1 %157, label %158, label %162
158: ; preds = %152
%159 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%160 = load i32, i32* @EXIT_FAILURE
%161 = call i32 @exit(i32 %160)
unreachable
162: ; preds = %152
%163 = load i8*, i8** %12
%164 = load %struct.dirent*, %struct.dirent** %9
%165 = getelementptr inbounds %struct.dirent, %struct.dirent* %164, i32 0, i32 0
%166 = load i8*, i8** %165
%167 = call i32 @strcpy(i8* %163, i8* %166)
%168 = load i8*, i8** %12
%169 = call i32 @strlen(i8* %168)
%170 = sext i32 %169 to i64
store i64 %170, i64* %14
%171 = load i32, i32* %4
%172 = call i32 (i32, ...) @write(i32 %171, i64* %14, i64 8)
%173 = sext i32 %172 to i64
%174 = icmp ult i64 %173, 8
br i1 %174, label %175, label %179
175: ; preds = %162
%176 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%177 = load i32, i32* @EXIT_FAILURE
%178 = call i32 @exit(i32 %177)
unreachable
179: ; preds = %162
%180 = load i32, i32* %4
%181 = load i8*, i8** %12
%182 = load i64, i64* %14
%183 = call i32 (i32, ...) @write(i32 %180, i8* %181, i64 %182)
%184 = sext i32 %183 to i64
%185 = load i64, i64* %14
%186 = icmp ult i64 %184, %185
br i1 %186, label %187, label %191
187: ; preds = %179
%188 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%189 = load i32, i32* @EXIT_FAILURE
%190 = call i32 @exit(i32 %189)
unreachable
191: ; preds = %179
%192 = load i32, i32* %4
%193 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%194 = call i32 (i32, ...) @write(i32 %192, i8* %193, i64 4)
%195 = sext i32 %194 to i64
%196 = icmp ult i64 %195, 4
br i1 %196, label %197, label %201
197: ; preds = %191
%198 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%199 = load i32, i32* @EXIT_FAILURE
%200 = call i32 @exit(i32 %199)
unreachable
201: ; preds = %191
%202 = load i8*, i8** %12
%203 = call i32 @free(i8* %202)
br label %214
204: ; preds = %129
store i8 100, i8* %13
%205 = load i32, i32* %4
%206 = call i32 (i32, ...) @write(i32 %205, i8* %13, i64 1)
%207 = sext i32 %206 to i64
%208 = icmp ult i64 %207, 1
br i1 %208, label %209, label %213
209: ; preds = %204
%210 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%211 = load i32, i32* @EXIT_FAILURE
%212 = call i32 @exit(i32 %211)
unreachable
213: ; preds = %204
br label %214
214: ; preds = %213, %201
br label %102
215: ; preds = %102
store i8 101, i8* %13
%216 = load i32, i32* %4
%217 = call i32 (i32, ...) @write(i32 %216, i8* %13, i64 1)
%218 = sext i32 %217 to i64
%219 = icmp ult i64 %218, 1
br i1 %219, label %220, label %224
220: ; preds = %215
%221 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%222 = load i32, i32* @EXIT_FAILURE
%223 = call i32 @exit(i32 %222)
unreachable
224: ; preds = %215
%225 = load i32*, i32** %8
%226 = call i32 @closedir(i32* %225)
%227 = icmp eq i32 %226, -1
br i1 %227, label %228, label %232
228: ; preds = %224
%229 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%230 = load i32, i32* @EXIT_FAILURE
%231 = call i32 @exit(i32 %230)
unreachable
232: ; preds = %224
br label %233
233: ; preds = %232, %78
br label %234
234: ; preds = %233, %77
br label %235
235: ; preds = %234, %28
br label %24
236: ; preds = %24
%237 = load i32*, i32** %7
%238 = call i32 @closedir(i32* %237)
%239 = icmp eq i32 %238, -1
br i1 %239, label %240, label %244
240: ; preds = %236
%241 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%242 = load i32, i32* @EXIT_FAILURE
%243 = call i32 @exit(i32 %242)
unreachable
244: ; preds = %236
ret void
}

LLVM IR (-O2):
%struct.stat = type { i8, i32 }
%struct.dirent = type { i8* }
@.str = [14 x i8] c"Error opendir\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"Error write\00"
@.str.2 = [11 x i8] c"Error stat\00"
@.str.3 = [4 x i8] c"REG\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [4 x i8] c"DIR\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [3 x i8] c"..\00"
@.str.7 = [13 x i8] c"Error malloc\00"
@.str.8 = [58 x i8] c"Error: The length of the filename is too big. Memory leak\00"
@.str.9 = [15 x i8] c"Error closedir\00"
define void @list(i32 %0, i8* nocapture %1, i8* %2) {
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i8
%7 = alloca i64
%8 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%9 = bitcast i32* %5 to i8*
store i32 0, i32* %5
store i8 35, i8* %6
%10 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%11 = tail call i32* @opendir(i8* %1)
%12 = icmp eq i32* %11, null
br i1 %12, label %18, label %13
13: ; preds = %3
%14 = call %struct.dirent* @readdir(i32* %11)
%15 = icmp eq %struct.dirent* %14, null
br i1 %15, label %185, label %16
16: ; preds = %13
%17 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
br label %22
18: ; preds = %3
%19 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %16, %182
%23 = phi %struct.dirent* [ %14, %16 ], [ %183, %182 ]
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* %2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %182
28: ; preds = %22
store i32 1, i32* %5
%29 = call i32 (i32, ...) @write(i32 %0, i32* %5, i64 4)
%30 = icmp ult i32 %29, 4
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %28
%36 = load i8*, i8** %24
%37 = call i32 @stat(i8* %36, %struct.stat* %4)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %35
%44 = load i32, i32* %17
%45 = call i64 @S_ISREG(i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %61, label %47
47: ; preds = %43
%48 = call i32 (i32, ...) @write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%49 = icmp slt i32 %48, 3
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* @EXIT_SUCCESS
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %47
%55 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 4)
%56 = icmp ult i32 %55, 4
br i1 %56, label %57, label %182
57: ; preds = %54
%58 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %43
%62 = load i32, i32* %17
%63 = call i64 @S_ISDIR(i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %182, label %65
65: ; preds = %61
%66 = call i32 (i32, ...) @write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%67 = icmp slt i32 %66, 3
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %65
%73 = call i32 @chdir(i8* %2)
%74 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%75 = icmp eq i32* %74, null
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = call %struct.dirent* @readdir(i32* %74)
%78 = icmp eq %struct.dirent* %77, null
br i1 %78, label %168, label %83
79: ; preds = %72
%80 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %76, %93
%84 = phi %struct.dirent* [ %94, %93 ], [ %77, %76 ]
%85 = getelementptr inbounds %struct.dirent, %struct.dirent* %84, i64 0, i32 0
%86 = load i8*, i8** %85
%87 = call i64 @strcmp(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %93, label %89
89: ; preds = %83
%90 = load i8*, i8** %85
%91 = call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %159, %161, %83, %89
%94 = call %struct.dirent* @readdir(i32* %74)
%95 = icmp eq %struct.dirent* %94, null
br i1 %95, label %168, label %83
96: ; preds = %89
%97 = load i8*, i8** %85
%98 = call i32 @stat(i8* %97, %struct.stat* %4)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %104
100: ; preds = %96
%101 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %96
%105 = load i32, i32* %17
%106 = call i64 @S_ISREG(i32 %105)
%107 = icmp eq i64 %106, 0
br i1 %107, label %161, label %108
108: ; preds = %104
store i8 102, i8* %6
%109 = call i32 (i32, ...) @write(i32 %0, i8* %6, i64 1)
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %108
%112 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %108
%116 = call i64 @malloc(i32 4097)
%117 = inttoptr i64 %116 to i8*
%118 = icmp eq i64 %116, 0
br i1 %118, label %119, label %123
119: ; preds = %115
%120 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %115
%124 = load i8*, i8** %85
%125 = call i32 @strlen(i8* %124)
%126 = icmp sgt i32 %125, 4095
br i1 %126, label %127, label %131
127: ; preds = %123
%128 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%129 = load i32, i32* @EXIT_FAILURE
%130 = call i32 @exit(i32 %129)
unreachable
131: ; preds = %123
%132 = load i8*, i8** %85
%133 = call i32 @strcpy(i8* %117, i8* %132)
%134 = call i32 @strlen(i8* %117)
%135 = sext i32 %134 to i64
store i64 %135, i64* %7
%136 = call i32 (i32, ...) @write(i32 %0, i64* %7, i64 8)
%137 = icmp ult i32 %136, 8
br i1 %137, label %138, label %142
138: ; preds = %131
%139 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%140 = load i32, i32* @EXIT_FAILURE
%141 = call i32 @exit(i32 %140)
unreachable
142: ; preds = %131
%143 = load i64, i64* %7
%144 = call i32 (i32, ...) @write(i32 %0, i8* %117, i64 %143)
%145 = sext i32 %144 to i64
%146 = load i64, i64* %7
%147 = icmp ugt i64 %146, %145
br i1 %147, label %148, label %152
148: ; preds = %142
%149 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%150 = load i32, i32* @EXIT_FAILURE
%151 = call i32 @exit(i32 %150)
unreachable
152: ; preds = %142
%153 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 4)
%154 = icmp ult i32 %153, 4
br i1 %154, label %155, label %159
155: ; preds = %152
%156 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%157 = load i32, i32* @EXIT_FAILURE
%158 = call i32 @exit(i32 %157)
unreachable
159: ; preds = %152
%160 = call i32 @free(i8* %117)
br label %93
161: ; preds = %104
store i8 100, i8* %6
%162 = call i32 (i32, ...) @write(i32 %0, i8* %6, i64 1)
%163 = icmp eq i32 %162, 0
br i1 %163, label %164, label %93
164: ; preds = %161
%165 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%166 = load i32, i32* @EXIT_FAILURE
%167 = call i32 @exit(i32 %166)
unreachable
168: ; preds = %93, %76
store i8 101, i8* %6
%169 = call i32 (i32, ...) @write(i32 %0, i8* %6, i64 1)
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %175
171: ; preds = %168
%172 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%173 = load i32, i32* @EXIT_FAILURE
%174 = call i32 @exit(i32 %173)
unreachable
175: ; preds = %168
%176 = call i32 @closedir(i32* %74)
%177 = icmp eq i32 %176, -1
br i1 %177, label %178, label %182
178: ; preds = %175
%179 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%180 = load i32, i32* @EXIT_FAILURE
%181 = call i32 @exit(i32 %180)
unreachable
182: ; preds = %54, %175, %61, %22
%183 = call %struct.dirent* @readdir(i32* %11)
%184 = icmp eq %struct.dirent* %183, null
br i1 %184, label %185, label %22
185: ; preds = %182, %13
%186 = call i32 @closedir(i32* %11)
%187 = icmp eq i32 %186, -1
br i1 %187, label %188, label %192
188: ; preds = %185
%189 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%190 = load i32, i32* @EXIT_FAILURE
%191 = call i32 @exit(i32 %190)
unreachable
192: ; preds = %185
ret void
}