#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 {
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ nbytes;
typedef int /*<<< orphan*/ lenfilename;
typedef int /*<<< orphan*/ found;
typedef int /*<<< orphan*/ flag_f;
typedef int /*<<< orphan*/ flag;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ chdir(char *);
int close(int);
int closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int write(int, ...);
void get(int fd, char *dirname, char *filename) {
  DIR *dp;
  DIR *dc;
  struct dirent *de;
  struct stat buf;
  int found = 0;
  int f;
  size_t lenfilename = 0;
  ssize_t nbytes;
  char *f_content;
  char *fname;
  char flag = '-';
  char flag_f = 'f';
  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_FAILURE);
        }
        lenfilename = strlen(filename);
        if (write(fd, &lenfilename, sizeof(lenfilename)) <
            sizeof(lenfilename)) {
          perror("Error write");
          exit(EXIT_FAILURE);
        }
        if (write(fd, filename, lenfilename) < lenfilename) {
          perror("Error write");
          exit(EXIT_FAILURE);
        }
        f = open(filename, O_RDONLY);
        if (f == -1) {
          perror("Error open file");
          exit(EXIT_FAILURE);
        }
        f_content = (char *)malloc(sizeof(char) * 4096 + 1);
        if (f_content == NULL) {
          perror("Error malloc");
          exit(EXIT_FAILURE);
        }
        while ((nbytes = read(f, f_content, 100)) != 0) {
          if (nbytes == -1) {
            perror("Error read");
            exit(EXIT_FAILURE);
          }
          if (write(fd, &flag, sizeof(flag)) < sizeof(flag)) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          if (write(fd, &nbytes, sizeof(nbytes)) < sizeof(nbytes)) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          if (write(fd, f_content, nbytes) < nbytes) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          sleep(1);
        }
        flag = '+';
        if (write(fd, &flag, sizeof(flag)) < sizeof(flag)) {
          perror("Error write");
          exit(EXIT_FAILURE);
        }
        if (close(f) == -1) {
          perror("Error closing file");
          exit(EXIT_FAILURE);
        }
        free(f_content);
      } 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);
              }
              f_content = (char *)malloc(sizeof(char) * 4096 + 1);
              if (f_content == 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);
              lenfilename = strlen(fname);
              if (write(fd, &lenfilename, sizeof(lenfilename)) <
                  sizeof(lenfilename)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              if (write(fd, fname, lenfilename) < lenfilename) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              f = open(fname, O_RDONLY);
              if (f == -1) {
                perror("Error open file");
                exit(EXIT_FAILURE);
              }
              while ((nbytes = read(f, f_content, 100)) != 0) {
                flag = '-';
                if (write(fd, &flag, sizeof(flag)) < sizeof(flag)) {
                  perror("Error write");
                  exit(EXIT_FAILURE);
                }
                if (write(fd, &nbytes, sizeof(nbytes)) < sizeof(nbytes)) {
                  perror("Error write");
                  exit(EXIT_FAILURE);
                }
                if (write(fd, f_content, nbytes) < nbytes) {
                  perror("Error write");
                  exit(EXIT_FAILURE);
                }
                sleep(1);
              }
              flag = '+';
              if (write(fd, &flag, sizeof(flag)) < sizeof(flag)) {
                perror("Error write");
                exit(EXIT_FAILURE);
              }
              if (close(f) == -1) {
                perror("Error close file");
                exit(EXIT_FAILURE);
              }
              free(f_content);
              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 close");
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
movb   $0x2d,-0x61(%rbp)
movb   $0x66,-0x62(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    128c <get+0x5c>
lea    0xd87(%rip),%rdi
call   1130 <perror@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1291 <get+0x61>
mov    -0x20(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1ac1 <get+0x891>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    1abc <get+0x88c>
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    1302 <get+0xd2>
lea    0xd1f(%rip),%rdi
call   1130 <perror@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x38(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1335 <get+0x105>
lea    0xcf8(%rip),%rdi
call   1130 <perror@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x38(%rbp),%edi
call   10f0 <S_ISREG@plt>
cmp    $0x0,%rax
je     15dd <get+0x3ad>
mov    -0x4(%rbp),%edi
lea    0xcd4(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    1380 <get+0x150>
lea    0xca1(%rip),%rdi
call   1130 <perror@plt>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x8,%rax
jae    13c8 <get+0x198>
lea    0xc59(%rip),%rdi
call   1130 <perror@plt>
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    -0x48(%rbp),%rax
jae    1400 <get+0x1d0>
lea    0xc21(%rip),%rdi
call   1130 <perror@plt>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2bdd(%rip),%rax
mov    (%rax),%esi
call   1120 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
jne    1439 <get+0x209>
lea    0xc03(%rip),%rdi
call   1130 <perror@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1001,%edi
call   1110 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    146c <get+0x23c>
lea    0xbe0(%rip),%rdi
call   1130 <perror@plt>
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1471 <get+0x241>
mov    -0x40(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     1567 <get+0x337>
cmpl   $0xffffffff,-0x4c(%rbp)
jne    14b2 <get+0x282>
lea    0xba7(%rip),%rdi
call   1130 <perror@plt>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x61(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    14eb <get+0x2bb>
lea    0xb36(%rip),%rdi
call   1130 <perror@plt>
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x4c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    1524 <get+0x2f4>
lea    0xafd(%rip),%rdi
call   1130 <perror@plt>
mov    0x2abb(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x4c(%rbp),%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    -0x4c(%rbp),%eax
jge    1558 <get+0x328>
lea    0xac9(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a87(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    1471 <get+0x241>
movb   $0x2b,-0x61(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x61(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    15a4 <get+0x374>
lea    0xa7d(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a3b(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    15cf <get+0x39f>
lea    0xa95(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a10(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
jmp    1ab7 <get+0x887>
mov    -0x38(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1ab2 <get+0x882>
mov    -0x4(%rbp),%edi
lea    0xa6b(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    1628 <get+0x3f8>
lea    0x9f9(%rip),%rdi
call   1130 <perror@plt>
mov    0x29b7(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1080 <chdir@plt>
lea    0xa31(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1666 <get+0x436>
lea    0x9ad(%rip),%rdi
call   1130 <perror@plt>
mov    0x2979(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    166b <get+0x43b>
mov    -0x28(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1a44 <get+0x814>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0x9d9(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     16bc <get+0x48c>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0x9bb(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    16c1 <get+0x491>
jmp    166b <get+0x43b>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x38(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
jne    16f4 <get+0x4c4>
lea    0x939(%rip),%rdi
call   1130 <perror@plt>
mov    0x28eb(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x38(%rbp),%edi
call   10f0 <S_ISREG@plt>
cmp    $0x0,%rax
je     19fd <get+0x7cd>
movb   $0x66,-0x62(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x62(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1743 <get+0x513>
lea    0x8de(%rip),%rdi
call   1130 <perror@plt>
mov    0x289c(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1001,%edi
call   1110 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1776 <get+0x546>
lea    0x8d6(%rip),%rdi
call   1130 <perror@plt>
mov    0x2869(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1001,%edi
call   1110 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    17a9 <get+0x579>
lea    0x8a3(%rip),%rdi
call   1130 <perror@plt>
mov    0x2836(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
cmp    $0x1000,%eax
jl     17da <get+0x5aa>
lea    0x8a4(%rip),%rdi
call   1130 <perror@plt>
mov    0x2805(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x8,%rax
jae    1832 <get+0x602>
lea    0x7ef(%rip),%rdi
call   1130 <perror@plt>
mov    0x27ad(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    -0x48(%rbp),%rax
jae    186a <get+0x63a>
lea    0x7b7(%rip),%rdi
call   1130 <perror@plt>
mov    0x2775(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x60(%rbp),%rdi
mov    0x2773(%rip),%rax
mov    (%rax),%esi
call   1120 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
jne    18a3 <get+0x673>
lea    0x799(%rip),%rdi
call   1130 <perror@plt>
mov    0x273c(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    18a8 <get+0x678>
mov    -0x40(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     197e <get+0x74e>
movb   $0x2d,-0x61(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x61(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1902 <get+0x6d2>
lea    0x71f(%rip),%rdi
call   1130 <perror@plt>
mov    0x26dd(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x4c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    193b <get+0x70b>
lea    0x6e6(%rip),%rdi
call   1130 <perror@plt>
mov    0x26a4(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x4c(%rbp),%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    -0x4c(%rbp),%eax
jge    196f <get+0x73f>
lea    0x6b2(%rip),%rdi
call   1130 <perror@plt>
mov    0x2670(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    18a8 <get+0x678>
movb   $0x2b,-0x61(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x61(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    19bb <get+0x78b>
lea    0x666(%rip),%rdi
call   1130 <perror@plt>
mov    0x2624(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    19e6 <get+0x7b6>
lea    0x6d2(%rip),%rdi
call   1130 <perror@plt>
mov    0x25f9(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
jmp    1a3f <get+0x80f>
movb   $0x64,-0x62(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x62(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1a3a <get+0x80a>
lea    0x5e7(%rip),%rdi
call   1130 <perror@plt>
mov    0x25a5(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1a3f <get+0x80f>
jmp    166b <get+0x43b>
movb   $0x65,-0x62(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x62(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1a81 <get+0x851>
lea    0x5a0(%rip),%rdi
call   1130 <perror@plt>
mov    0x255e(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    1aad <get+0x87d>
lea    0x61c(%rip),%rdi
call   1130 <perror@plt>
mov    0x2532(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1ab2 <get+0x882>
jmp    1ab7 <get+0x887>
jmp    1abc <get+0x88c>
jmp    1291 <get+0x61>
mov    -0x20(%rbp),%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    1aed <get+0x8bd>
lea    0x5eb(%rip),%rdi
call   1130 <perror@plt>
mov    0x24f2(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    0x24dc(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>

x86 assembly (clang, -O2):
<get>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbp
mov    %edi,%r15d
movl   $0x0,0x1c(%rsp)
movq   $0x0,0x10(%rsp)
movb   $0x2d,0xb(%rsp)
movb   $0x66,0xa(%rsp)
mov    %rsi,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
jne    1278 <get+0x48>
lea    0xd8d(%rip),%rdi
jmp    1788 <get+0x558>
mov    %rax,%r13
mov    %rax,%rdi
call   1100 <readdir@plt>
test   %rax,%rax
jne    12a5 <get+0x75>
mov    %r13,%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    179b <get+0x56b>
lea    0xe25(%rip),%rdi
jmp    1788 <get+0x558>
mov    %rax,%rbx
lea    0xb(%rsp),%r12
mov    %rbp,0x28(%rsp)
mov    %r13,0x20(%rsp)
jmp    12d8 <get+0xa8>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1100 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1288 <get+0x58>
mov    (%rbx),%rdi
mov    %rbp,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    12c8 <get+0x98>
movl   $0x1,0x1c(%rsp)
mov    $0x4,%edx
mov    %r15d,%edi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    1781 <get+0x551>
mov    (%rbx),%rdi
lea    0x18(%rsp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
je     17bb <get+0x58b>
mov    0x18(%rsp),%ebx
mov    %ebx,%edi
call   10f0 <S_ISREG@plt>
test   %rax,%rax
je     1495 <get+0x265>
mov    %r15d,%edi
lea    0xce4(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    1781 <get+0x551>
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,0x10(%rsp)
mov    $0x8,%edx
mov    %r15d,%edi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x7,%eax
jbe    1781 <get+0x551>
mov    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cltq
cmp    %rax,0x10(%rsp)
ja     1781 <get+0x551>
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1120 <open@plt>
cmp    $0xffffffff,%eax
je     17c4 <get+0x594>
mov    %eax,%r14d
mov    $0x1001,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <get+0x582>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     1460 <get+0x230>
cmp    $0xffffffff,%eax
je     17a9 <get+0x579>
mov    $0x1,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    $0x4,%edx
mov    %r15d,%edi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    1781 <get+0x551>
mov    0xc(%rsp),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    0xc(%rsp),%eax
jl     1781 <get+0x551>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    13e0 <get+0x1b0>
nop
movb   $0x2b,0xb(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    %r14d,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    12c0 <get+0x90>
jmp    17df <get+0x5af>
mov    %ebx,%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
je     12c8 <get+0x98>
mov    %r15d,%edi
lea    0xbb5(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    1781 <get+0x551>
mov    %rbp,%rdi
call   1080 <chdir@plt>
lea    0xb96(%rip),%r14
mov    %r14,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     126c <get+0x3c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1100 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
lea    0xb6c(%rip),%rbp
mov    %rbx,0x30(%rsp)
jne    1580 <get+0x350>
movb   $0x65,0xa(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    %rbx,%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
mov    0x28(%rsp),%rbp
mov    0x20(%rsp),%r13
jne    12c8 <get+0x98>
jmp    17e8 <get+0x5b8>
movb   $0x64,0xa(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1100 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     1503 <get+0x2d3>
mov    0x0(%r13),%rdi
mov    %r14,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1570 <get+0x340>
mov    0x0(%r13),%rdi
mov    %rbp,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1570 <get+0x340>
mov    0x0(%r13),%rdi
lea    0x18(%rsp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
je     17bb <get+0x58b>
mov    0x18(%rsp),%edi
call   10f0 <S_ISREG@plt>
test   %rax,%rax
je     1544 <get+0x314>
movb   $0x66,0xa(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    $0x1001,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <get+0x582>
mov    %rax,%r14
mov    $0x1001,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <get+0x582>
mov    %rax,%rbx
mov    0x0(%r13),%rdi
call   1070 <strlen@plt>
cmp    $0x1000,%eax
jge    17cd <get+0x59d>
mov    0x0(%r13),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,0x10(%rsp)
mov    $0x8,%edx
mov    %r15d,%edi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x7,%eax
jbe    1781 <get+0x551>
mov    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cltq
cmp    %rax,0x10(%rsp)
ja     1781 <get+0x551>
mov    0x295e(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1120 <open@plt>
cmp    $0xffffffff,%eax
je     17c4 <get+0x594>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
lea    0xc(%rsp),%r13
je     1732 <get+0x502>
nopl   0x0(%rax,%rax,1)
movb   $0x2d,0xb(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    $0x4,%edx
mov    %r15d,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    1781 <get+0x551>
mov    0xc(%rsp),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    0xc(%rsp),%eax
jl     1781 <get+0x551>
mov    $0x1,%edi
call   1150 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jne    16c0 <get+0x490>
movb   $0x2b,0xb(%rsp)
mov    $0x1,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <get+0x551>
mov    %ebp,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
je     17d6 <get+0x5a6>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x8f9(%rip),%r14
lea    0x8f1(%rip),%rbp
mov    0x30(%rsp),%rbx
jmp    1570 <get+0x340>
lea    0x886(%rip),%rdi
call   1130 <perror@plt>
mov    0x2844(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    0x282e(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
lea    0x896(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x880(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x858(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x85e(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x897(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x8c8(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x86b(%rip),%rdi
jmp    1788 <get+0x558>
lea    0x8c7(%rip),%rdi
jmp    1788 <get+0x558>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { 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"
@O_RDONLY = global i32 0
@.str.4 = [16 x i8] c"Error open file\00"
@.str.5 = [13 x i8] c"Error malloc\00"
@.str.6 = [11 x i8] c"Error read\00"
@.str.7 = [19 x i8] c"Error closing file\00"
@.str.8 = [4 x i8] c"DIR\00"
@.str.9 = [2 x i8] c".\00"
@.str.10 = [3 x i8] c"..\00"
@.str.11 = [58 x i8] c"Error: the length of the filename is too big. Memory leak\00"
@.str.12 = [17 x i8] c"Error close file\00"
@.str.13 = [15 x i8] c"Error closedir\00"
@.str.14 = [12 x i8] c"Error close\00"
@EXIT_SUCCESS = global i32 0
define void @get(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 i32
%13 = alloca i64
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8
%18 = alloca i8
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %11
store i64 0, i64* %13
store i8 45, i8* %17
store i8 102, i8* %18
%19 = load i8*, i8** %5
%20 = call i32* @opendir(i8* %19)
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %3
%24 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %3
br label %28
28: ; preds = %400, %27
%29 = load i32*, i32** %7
%30 = call %struct.dirent* @readdir(i32* %29)
store %struct.dirent* %30, %struct.dirent** %9
%31 = icmp ne %struct.dirent* %30, null
br i1 %31, label %32, label %401
32: ; preds = %28
%33 = load %struct.dirent*, %struct.dirent** %9
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = load i8*, i8** %6
%37 = call i64 @strcmp(i8* %35, i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %400
39: ; preds = %32
store i32 1, i32* %11
%40 = load i32, i32* %4
%41 = call i32 (i32, ...) @write(i32 %40, i32* %11, i64 4)
%42 = sext i32 %41 to i64
%43 = icmp ult i64 %42, 4
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %39
%49 = load %struct.dirent*, %struct.dirent** %9
%50 = getelementptr inbounds %struct.dirent, %struct.dirent* %49, i32 0, i32 0
%51 = load i8*, i8** %50
%52 = call i32 @stat(i8* %51, %struct.stat* %10)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %58
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %48
%59 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i64 @S_ISREG(i32 %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %178
63: ; preds = %58
%64 = load i32, i32* %4
%65 = call i32 (i32, ...) @write(i32 %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%66 = icmp slt i32 %65, 3
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %63
%72 = load i8*, i8** %6
%73 = call i32 @strlen(i8* %72)
%74 = sext i32 %73 to i64
store i64 %74, i64* %13
%75 = load i32, i32* %4
%76 = call i32 (i32, ...) @write(i32 %75, i64* %13, i64 8)
%77 = sext i32 %76 to i64
%78 = icmp ult i64 %77, 8
br i1 %78, label %79, label %83
79: ; preds = %71
%80 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %71
%84 = load i32, i32* %4
%85 = load i8*, i8** %6
%86 = load i64, i64* %13
%87 = call i32 (i32, ...) @write(i32 %84, i8* %85, i64 %86)
%88 = sext i32 %87 to i64
%89 = load i64, i64* %13
%90 = icmp ult i64 %88, %89
br i1 %90, label %91, label %95
91: ; preds = %83
%92 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @exit(i32 %93)
unreachable
95: ; preds = %83
%96 = load i8*, i8** %6
%97 = load i32, i32* @O_RDONLY
%98 = call i32 @open(i8* %96, i32 %97)
store i32 %98, i32* %12
%99 = load i32, i32* %12
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %105
101: ; preds = %95
%102 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %95
%106 = call i64 @malloc(i32 4097)
%107 = inttoptr i64 %106 to i8*
store i8* %107, i8** %15
%108 = load i8*, i8** %15
%109 = icmp eq i8* %108, null
br i1 %109, label %110, label %114
110: ; preds = %105
%111 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %105
br label %115
115: ; preds = %156, %114
%116 = load i32, i32* %12
%117 = load i8*, i8** %15
%118 = call i32 @read(i32 %116, i8* %117, i32 100)
store i32 %118, i32* %14
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %158
120: ; preds = %115
%121 = load i32, i32* %14
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %127
123: ; preds = %120
%124 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%125 = load i32, i32* @EXIT_FAILURE
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %120
%128 = load i32, i32* %4
%129 = call i32 (i32, ...) @write(i32 %128, i8* %17, i64 1)
%130 = sext i32 %129 to i64
%131 = icmp ult i64 %130, 1
br i1 %131, label %132, label %136
132: ; preds = %127
%133 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%134 = load i32, i32* @EXIT_FAILURE
%135 = call i32 @exit(i32 %134)
unreachable
136: ; preds = %127
%137 = load i32, i32* %4
%138 = call i32 (i32, ...) @write(i32 %137, i32* %14, i64 4)
%139 = sext i32 %138 to i64
%140 = icmp ult i64 %139, 4
br i1 %140, label %141, label %145
141: ; preds = %136
%142 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%143 = load i32, i32* @EXIT_FAILURE
%144 = call i32 @exit(i32 %143)
unreachable
145: ; preds = %136
%146 = load i32, i32* %4
%147 = load i8*, i8** %15
%148 = load i32, i32* %14
%149 = call i32 (i32, ...) @write(i32 %146, i8* %147, i32 %148)
%150 = load i32, i32* %14
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %156
152: ; preds = %145
%153 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%154 = load i32, i32* @EXIT_FAILURE
%155 = call i32 @exit(i32 %154)
unreachable
156: ; preds = %145
%157 = call i32 @sleep(i32 1)
br label %115
158: ; preds = %115
store i8 43, i8* %17
%159 = load i32, i32* %4
%160 = call i32 (i32, ...) @write(i32 %159, i8* %17, i64 1)
%161 = sext i32 %160 to i64
%162 = icmp ult i64 %161, 1
br i1 %162, label %163, label %167
163: ; preds = %158
%164 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%165 = load i32, i32* @EXIT_FAILURE
%166 = call i32 @exit(i32 %165)
unreachable
167: ; preds = %158
%168 = load i32, i32* %12
%169 = call i32 @close(i32 %168)
%170 = icmp eq i32 %169, -1
br i1 %170, label %171, label %175
171: ; preds = %167
%172 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%173 = load i32, i32* @EXIT_FAILURE
%174 = call i32 @exit(i32 %173)
unreachable
175: ; preds = %167
%176 = load i8*, i8** %15
%177 = call i32 @free(i8* %176)
br label %399
178: ; preds = %58
%179 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%180 = load i32, i32* %179
%181 = call i64 @S_ISDIR(i32 %180)
%182 = icmp ne i64 %181, 0
br i1 %182, label %183, label %398
183: ; preds = %178
%184 = load i32, i32* %4
%185 = call i32 (i32, ...) @write(i32 %184, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%186 = icmp slt i32 %185, 3
br i1 %186, label %187, label %191
187: ; preds = %183
%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 = %183
%192 = load i8*, i8** %6
%193 = call i32 @chdir(i8* %192)
%194 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %194, i32** %8
%195 = load i32*, i32** %8
%196 = icmp eq i32* %195, null
br i1 %196, label %197, label %201
197: ; preds = %191
%198 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%199 = load i32, i32* @EXIT_FAILURE
%200 = call i32 @exit(i32 %199)
unreachable
201: ; preds = %191
br label %202
202: ; preds = %379, %218, %201
%203 = load i32*, i32** %8
%204 = call %struct.dirent* @readdir(i32* %203)
store %struct.dirent* %204, %struct.dirent** %9
%205 = icmp ne %struct.dirent* %204, null
br i1 %205, label %206, label %380
206: ; preds = %202
%207 = load %struct.dirent*, %struct.dirent** %9
%208 = getelementptr inbounds %struct.dirent, %struct.dirent* %207, i32 0, i32 0
%209 = load i8*, i8** %208
%210 = call i64 @strcmp(i8* %209, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%211 = icmp eq i64 %210, 0
br i1 %211, label %218, label %212
212: ; preds = %206
%213 = load %struct.dirent*, %struct.dirent** %9
%214 = getelementptr inbounds %struct.dirent, %struct.dirent* %213, i32 0, i32 0
%215 = load i8*, i8** %214
%216 = call i64 @strcmp(i8* %215, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%217 = icmp eq i64 %216, 0
br i1 %217, label %218, label %219
218: ; preds = %212, %206
br label %202
219: ; preds = %212
%220 = load %struct.dirent*, %struct.dirent** %9
%221 = getelementptr inbounds %struct.dirent, %struct.dirent* %220, i32 0, i32 0
%222 = load i8*, i8** %221
%223 = call i32 @stat(i8* %222, %struct.stat* %10)
%224 = icmp eq i32 %223, -1
br i1 %224, label %225, label %229
225: ; preds = %219
%226 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%227 = load i32, i32* @EXIT_FAILURE
%228 = call i32 @exit(i32 %227)
unreachable
229: ; preds = %219
%230 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%231 = load i32, i32* %230
%232 = call i64 @S_ISREG(i32 %231)
%233 = icmp ne i64 %232, 0
br i1 %233, label %234, label %369
234: ; preds = %229
store i8 102, i8* %18
%235 = load i32, i32* %4
%236 = call i32 (i32, ...) @write(i32 %235, i8* %18, i64 1)
%237 = sext i32 %236 to i64
%238 = icmp ult i64 %237, 1
br i1 %238, label %239, label %243
239: ; preds = %234
%240 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%241 = load i32, i32* @EXIT_FAILURE
%242 = call i32 @exit(i32 %241)
unreachable
243: ; preds = %234
%244 = call i64 @malloc(i32 4097)
%245 = inttoptr i64 %244 to i8*
store i8* %245, i8** %16
%246 = load i8*, i8** %16
%247 = icmp eq i8* %246, null
br i1 %247, label %248, label %252
248: ; preds = %243
%249 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%250 = load i32, i32* @EXIT_FAILURE
%251 = call i32 @exit(i32 %250)
unreachable
252: ; preds = %243
%253 = call i64 @malloc(i32 4097)
%254 = inttoptr i64 %253 to i8*
store i8* %254, i8** %15
%255 = load i8*, i8** %15
%256 = icmp eq i8* %255, null
br i1 %256, label %257, label %261
257: ; preds = %252
%258 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%259 = load i32, i32* @EXIT_FAILURE
%260 = call i32 @exit(i32 %259)
unreachable
261: ; preds = %252
%262 = load %struct.dirent*, %struct.dirent** %9
%263 = getelementptr inbounds %struct.dirent, %struct.dirent* %262, i32 0, i32 0
%264 = load i8*, i8** %263
%265 = call i32 @strlen(i8* %264)
%266 = icmp sge i32 %265, 4096
br i1 %266, label %267, label %271
267: ; preds = %261
%268 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
%269 = load i32, i32* @EXIT_FAILURE
%270 = call i32 @exit(i32 %269)
unreachable
271: ; preds = %261
%272 = load i8*, i8** %16
%273 = load %struct.dirent*, %struct.dirent** %9
%274 = getelementptr inbounds %struct.dirent, %struct.dirent* %273, i32 0, i32 0
%275 = load i8*, i8** %274
%276 = call i32 @strcpy(i8* %272, i8* %275)
%277 = load i8*, i8** %16
%278 = call i32 @strlen(i8* %277)
%279 = sext i32 %278 to i64
store i64 %279, i64* %13
%280 = load i32, i32* %4
%281 = call i32 (i32, ...) @write(i32 %280, i64* %13, i64 8)
%282 = sext i32 %281 to i64
%283 = icmp ult i64 %282, 8
br i1 %283, label %284, label %288
284: ; preds = %271
%285 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%286 = load i32, i32* @EXIT_FAILURE
%287 = call i32 @exit(i32 %286)
unreachable
288: ; preds = %271
%289 = load i32, i32* %4
%290 = load i8*, i8** %16
%291 = load i64, i64* %13
%292 = call i32 (i32, ...) @write(i32 %289, i8* %290, i64 %291)
%293 = sext i32 %292 to i64
%294 = load i64, i64* %13
%295 = icmp ult i64 %293, %294
br i1 %295, label %296, label %300
296: ; preds = %288
%297 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%298 = load i32, i32* @EXIT_FAILURE
%299 = call i32 @exit(i32 %298)
unreachable
300: ; preds = %288
%301 = load i8*, i8** %16
%302 = load i32, i32* @O_RDONLY
%303 = call i32 @open(i8* %301, i32 %302)
store i32 %303, i32* %12
%304 = load i32, i32* %12
%305 = icmp eq i32 %304, -1
br i1 %305, label %306, label %310
306: ; preds = %300
%307 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%308 = load i32, i32* @EXIT_FAILURE
%309 = call i32 @exit(i32 %308)
unreachable
310: ; preds = %300
br label %311
311: ; preds = %345, %310
%312 = load i32, i32* %12
%313 = load i8*, i8** %15
%314 = call i32 @read(i32 %312, i8* %313, i32 100)
store i32 %314, i32* %14
%315 = icmp ne i32 %314, 0
br i1 %315, label %316, label %347
316: ; preds = %311
store i8 45, i8* %17
%317 = load i32, i32* %4
%318 = call i32 (i32, ...) @write(i32 %317, i8* %17, i64 1)
%319 = sext i32 %318 to i64
%320 = icmp ult i64 %319, 1
br i1 %320, label %321, label %325
321: ; preds = %316
%322 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%323 = load i32, i32* @EXIT_FAILURE
%324 = call i32 @exit(i32 %323)
unreachable
325: ; preds = %316
%326 = load i32, i32* %4
%327 = call i32 (i32, ...) @write(i32 %326, i32* %14, i64 4)
%328 = sext i32 %327 to i64
%329 = icmp ult i64 %328, 4
br i1 %329, label %330, label %334
330: ; preds = %325
%331 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%332 = load i32, i32* @EXIT_FAILURE
%333 = call i32 @exit(i32 %332)
unreachable
334: ; preds = %325
%335 = load i32, i32* %4
%336 = load i8*, i8** %15
%337 = load i32, i32* %14
%338 = call i32 (i32, ...) @write(i32 %335, i8* %336, i32 %337)
%339 = load i32, i32* %14
%340 = icmp slt i32 %338, %339
br i1 %340, label %341, label %345
341: ; preds = %334
%342 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%343 = load i32, i32* @EXIT_FAILURE
%344 = call i32 @exit(i32 %343)
unreachable
345: ; preds = %334
%346 = call i32 @sleep(i32 1)
br label %311
347: ; preds = %311
store i8 43, i8* %17
%348 = load i32, i32* %4
%349 = call i32 (i32, ...) @write(i32 %348, i8* %17, i64 1)
%350 = sext i32 %349 to i64
%351 = icmp ult i64 %350, 1
br i1 %351, label %352, label %356
352: ; preds = %347
%353 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%354 = load i32, i32* @EXIT_FAILURE
%355 = call i32 @exit(i32 %354)
unreachable
356: ; preds = %347
%357 = load i32, i32* %12
%358 = call i32 @close(i32 %357)
%359 = icmp eq i32 %358, -1
br i1 %359, label %360, label %364
360: ; preds = %356
%361 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
%362 = load i32, i32* @EXIT_FAILURE
%363 = call i32 @exit(i32 %362)
unreachable
364: ; preds = %356
%365 = load i8*, i8** %15
%366 = call i32 @free(i8* %365)
%367 = load i8*, i8** %16
%368 = call i32 @free(i8* %367)
br label %379
369: ; preds = %229
store i8 100, i8* %18
%370 = load i32, i32* %4
%371 = call i32 (i32, ...) @write(i32 %370, i8* %18, i64 1)
%372 = sext i32 %371 to i64
%373 = icmp ult i64 %372, 1
br i1 %373, label %374, label %378
374: ; preds = %369
%375 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%376 = load i32, i32* @EXIT_FAILURE
%377 = call i32 @exit(i32 %376)
unreachable
378: ; preds = %369
br label %379
379: ; preds = %378, %364
br label %202
380: ; preds = %202
store i8 101, i8* %18
%381 = load i32, i32* %4
%382 = call i32 (i32, ...) @write(i32 %381, i8* %18, i64 1)
%383 = sext i32 %382 to i64
%384 = icmp ult i64 %383, 1
br i1 %384, label %385, label %389
385: ; preds = %380
%386 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%387 = load i32, i32* @EXIT_FAILURE
%388 = call i32 @exit(i32 %387)
unreachable
389: ; preds = %380
%390 = load i32*, i32** %8
%391 = call i32 @closedir(i32* %390)
%392 = icmp eq i32 %391, -1
br i1 %392, label %393, label %397
393: ; preds = %389
%394 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%395 = load i32, i32* @EXIT_FAILURE
%396 = call i32 @exit(i32 %395)
unreachable
397: ; preds = %389
br label %398
398: ; preds = %397, %178
br label %399
399: ; preds = %398, %175
br label %400
400: ; preds = %399, %32
br label %28
401: ; preds = %28
%402 = load i32*, i32** %7
%403 = call i32 @closedir(i32* %402)
%404 = icmp eq i32 %403, -1
br i1 %404, label %405, label %409
405: ; preds = %401
%406 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%407 = load i32, i32* @EXIT_FAILURE
%408 = call i32 @exit(i32 %407)
unreachable
409: ; preds = %401
%410 = load i32, i32* @EXIT_SUCCESS
%411 = call i32 @exit(i32 %410)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { 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"
@O_RDONLY = global i32 0
@.str.4 = [16 x i8] c"Error open file\00"
@.str.5 = [13 x i8] c"Error malloc\00"
@.str.6 = [11 x i8] c"Error read\00"
@.str.7 = [19 x i8] c"Error closing file\00"
@.str.8 = [4 x i8] c"DIR\00"
@.str.9 = [2 x i8] c".\00"
@.str.10 = [3 x i8] c"..\00"
@.str.11 = [58 x i8] c"Error: the length of the filename is too big. Memory leak\00"
@.str.12 = [17 x i8] c"Error close file\00"
@.str.13 = [15 x i8] c"Error closedir\00"
@.str.14 = [12 x i8] c"Error close\00"
@EXIT_SUCCESS = global i32 0
define void @get(i32 %0, i8* nocapture %1, i8* %2) {
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = bitcast %struct.stat* %4 to i8*
%11 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%12 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%13 = bitcast i32* %7 to i8*
store i8 45, i8* %8
store i8 102, i8* %9
%14 = tail call i32* @opendir(i8* %1)
%15 = icmp eq i32* %14, null
br i1 %15, label %21, label %16
16: ; preds = %3
%17 = call %struct.dirent* @readdir(i32* %14)
%18 = icmp eq %struct.dirent* %17, null
br i1 %18, label %316, label %19
19: ; preds = %16
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %25
21: ; preds = %3
%22 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %19, %313
%26 = phi %struct.dirent* [ %17, %19 ], [ %314, %313 ]
%27 = getelementptr inbounds %struct.dirent, %struct.dirent* %26, i64 0, i32 0
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* %2)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %313
31: ; preds = %25
store i32 1, i32* %5
%32 = call i32 (i32, ...) @write(i32 %0, i32* %5, i64 4)
%33 = icmp ult i32 %32, 4
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %31
%39 = load i8*, i8** %27
%40 = call i32 @stat(i8* %39, %struct.stat* %4)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %38
%47 = load i32, i32* %20
%48 = call i64 @S_ISREG(i32 %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %139, label %50
50: ; preds = %46
%51 = call i32 (i32, ...) @write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%52 = icmp slt i32 %51, 3
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %50
%58 = call i32 @strlen(i8* %2)
%59 = sext i32 %58 to i64
store i64 %59, i64* %6
%60 = call i32 (i32, ...) @write(i32 %0, i64* %6, i64 8)
%61 = icmp ult i32 %60, 8
br i1 %61, label %62, label %66
62: ; preds = %57
%63 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %57
%67 = load i64, i64* %6
%68 = call i32 (i32, ...) @write(i32 %0, i8* %2, i64 %67)
%69 = sext i32 %68 to i64
%70 = load i64, i64* %6
%71 = icmp ugt i64 %70, %69
br i1 %71, label %72, label %76
72: ; preds = %66
%73 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %66
%77 = load i32, i32* @O_RDONLY
%78 = call i32 @open(i8* %2, i32 %77)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %76
%85 = call i64 @malloc(i32 4097)
%86 = inttoptr i64 %85 to i8*
%87 = icmp eq i64 %85, 0
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %84, %121
%93 = call i32 @read(i32 %78, i8* %86, i32 100)
store i32 %93, i32* %7
switch i32 %93, label %98 [
i32 0, label %123
i32 -1, label %94
]
94: ; preds = %92
%95 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %92
%99 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 1)
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %98
%102 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %98
%106 = call i32 (i32, ...) @write(i32 %0, i32* %7, i64 4)
%107 = icmp ult i32 %106, 4
br i1 %107, label %108, label %112
108: ; preds = %105
%109 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @exit(i32 %110)
unreachable
112: ; preds = %105
%113 = load i32, i32* %7
%114 = call i32 (i32, ...) @write(i32 %0, i8* %86, i32 %113)
%115 = load i32, i32* %7
%116 = icmp slt i32 %114, %115
br i1 %116, label %117, label %121
117: ; preds = %112
%118 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %112
%122 = call i32 @sleep(i32 1)
br label %92
123: ; preds = %92
store i8 43, i8* %8
%124 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 1)
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %130
126: ; preds = %123
%127 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %123
%131 = call i32 @close(i32 %78)
%132 = icmp eq i32 %131, -1
br i1 %132, label %133, label %137
133: ; preds = %130
%134 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%135 = load i32, i32* @EXIT_FAILURE
%136 = call i32 @exit(i32 %135)
unreachable
137: ; preds = %130
%138 = call i32 @free(i8* %86)
br label %313
139: ; preds = %46
%140 = call i64 @S_ISDIR(i32 %47)
%141 = icmp eq i64 %140, 0
br i1 %141, label %313, label %142
142: ; preds = %139
%143 = call i32 (i32, ...) @write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%144 = icmp slt i32 %143, 3
br i1 %144, label %145, label %149
145: ; preds = %142
%146 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%147 = load i32, i32* @EXIT_FAILURE
%148 = call i32 @exit(i32 %147)
unreachable
149: ; preds = %142
%150 = call i32 @chdir(i8* %2)
%151 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%152 = icmp eq i32* %151, null
br i1 %152, label %156, label %153
153: ; preds = %149
%154 = call %struct.dirent* @readdir(i32* %151)
%155 = icmp eq %struct.dirent* %154, null
br i1 %155, label %299, label %160
156: ; preds = %149
%157 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %153, %170
%161 = phi %struct.dirent* [ %171, %170 ], [ %154, %153 ]
%162 = getelementptr inbounds %struct.dirent, %struct.dirent* %161, i64 0, i32 0
%163 = load i8*, i8** %162
%164 = call i64 @strcmp(i8* %163, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%165 = icmp eq i64 %164, 0
br i1 %165, label %170, label %166
166: ; preds = %160
%167 = load i8*, i8** %162
%168 = call i64 @strcmp(i8* %167, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%169 = icmp eq i64 %168, 0
br i1 %169, label %170, label %173
170: ; preds = %289, %292, %160, %166
%171 = call %struct.dirent* @readdir(i32* %151)
%172 = icmp eq %struct.dirent* %171, null
br i1 %172, label %299, label %160
173: ; preds = %166
%174 = load i8*, i8** %162
%175 = call i32 @stat(i8* %174, %struct.stat* %4)
%176 = icmp eq i32 %175, -1
br i1 %176, label %177, label %181
177: ; preds = %173
%178 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%179 = load i32, i32* @EXIT_FAILURE
%180 = call i32 @exit(i32 %179)
unreachable
181: ; preds = %173
%182 = load i32, i32* %20
%183 = call i64 @S_ISREG(i32 %182)
%184 = icmp eq i64 %183, 0
br i1 %184, label %292, label %185
185: ; preds = %181
store i8 102, i8* %9
%186 = call i32 (i32, ...) @write(i32 %0, i8* %9, i64 1)
%187 = icmp eq i32 %186, 0
br i1 %187, label %188, label %192
188: ; preds = %185
%189 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%190 = load i32, i32* @EXIT_FAILURE
%191 = call i32 @exit(i32 %190)
unreachable
192: ; preds = %185
%193 = call i64 @malloc(i32 4097)
%194 = inttoptr i64 %193 to i8*
%195 = icmp eq i64 %193, 0
br i1 %195, label %196, label %200
196: ; preds = %192
%197 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%198 = load i32, i32* @EXIT_FAILURE
%199 = call i32 @exit(i32 %198)
unreachable
200: ; preds = %192
%201 = call i64 @malloc(i32 4097)
%202 = inttoptr i64 %201 to i8*
%203 = icmp eq i64 %201, 0
br i1 %203, label %204, label %208
204: ; preds = %200
%205 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%206 = load i32, i32* @EXIT_FAILURE
%207 = call i32 @exit(i32 %206)
unreachable
208: ; preds = %200
%209 = load i8*, i8** %162
%210 = call i32 @strlen(i8* %209)
%211 = icmp sgt i32 %210, 4095
br i1 %211, label %212, label %216
212: ; preds = %208
%213 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
%214 = load i32, i32* @EXIT_FAILURE
%215 = call i32 @exit(i32 %214)
unreachable
216: ; preds = %208
%217 = load i8*, i8** %162
%218 = call i32 @strcpy(i8* %194, i8* %217)
%219 = call i32 @strlen(i8* %194)
%220 = sext i32 %219 to i64
store i64 %220, i64* %6
%221 = call i32 (i32, ...) @write(i32 %0, i64* %6, i64 8)
%222 = icmp ult i32 %221, 8
br i1 %222, label %223, label %227
223: ; preds = %216
%224 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%225 = load i32, i32* @EXIT_FAILURE
%226 = call i32 @exit(i32 %225)
unreachable
227: ; preds = %216
%228 = load i64, i64* %6
%229 = call i32 (i32, ...) @write(i32 %0, i8* %194, i64 %228)
%230 = sext i32 %229 to i64
%231 = load i64, i64* %6
%232 = icmp ugt i64 %231, %230
br i1 %232, label %233, label %237
233: ; preds = %227
%234 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%235 = load i32, i32* @EXIT_FAILURE
%236 = call i32 @exit(i32 %235)
unreachable
237: ; preds = %227
%238 = load i32, i32* @O_RDONLY
%239 = call i32 @open(i8* %194, i32 %238)
%240 = icmp eq i32 %239, -1
br i1 %240, label %244, label %241
241: ; preds = %237
%242 = call i32 @read(i32 %239, i8* %202, i32 100)
store i32 %242, i32* %7
%243 = icmp eq i32 %242, 0
br i1 %243, label %275, label %248
244: ; preds = %237
%245 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%246 = load i32, i32* @EXIT_FAILURE
%247 = call i32 @exit(i32 %246)
unreachable
248: ; preds = %241, %271
store i8 45, i8* %8
%249 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 1)
%250 = icmp eq i32 %249, 0
br i1 %250, label %251, label %255
251: ; preds = %248
%252 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%253 = load i32, i32* @EXIT_FAILURE
%254 = call i32 @exit(i32 %253)
unreachable
255: ; preds = %248
%256 = call i32 (i32, ...) @write(i32 %0, i32* %7, i64 4)
%257 = icmp ult i32 %256, 4
br i1 %257, label %258, label %262
258: ; preds = %255
%259 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%260 = load i32, i32* @EXIT_FAILURE
%261 = call i32 @exit(i32 %260)
unreachable
262: ; preds = %255
%263 = load i32, i32* %7
%264 = call i32 (i32, ...) @write(i32 %0, i8* %202, i32 %263)
%265 = load i32, i32* %7
%266 = icmp slt i32 %264, %265
br i1 %266, label %267, label %271
267: ; preds = %262
%268 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%269 = load i32, i32* @EXIT_FAILURE
%270 = call i32 @exit(i32 %269)
unreachable
271: ; preds = %262
%272 = call i32 @sleep(i32 1)
%273 = call i32 @read(i32 %239, i8* %202, i32 100)
store i32 %273, i32* %7
%274 = icmp eq i32 %273, 0
br i1 %274, label %275, label %248
275: ; preds = %271, %241
store i8 43, i8* %8
%276 = call i32 (i32, ...) @write(i32 %0, i8* %8, i64 1)
%277 = icmp eq i32 %276, 0
br i1 %277, label %278, label %282
278: ; preds = %275
%279 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%280 = load i32, i32* @EXIT_FAILURE
%281 = call i32 @exit(i32 %280)
unreachable
282: ; preds = %275
%283 = call i32 @close(i32 %239)
%284 = icmp eq i32 %283, -1
br i1 %284, label %285, label %289
285: ; preds = %282
%286 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
%287 = load i32, i32* @EXIT_FAILURE
%288 = call i32 @exit(i32 %287)
unreachable
289: ; preds = %282
%290 = call i32 @free(i8* %202)
%291 = call i32 @free(i8* %194)
br label %170
292: ; preds = %181
store i8 100, i8* %9
%293 = call i32 (i32, ...) @write(i32 %0, i8* %9, i64 1)
%294 = icmp eq i32 %293, 0
br i1 %294, label %295, label %170
295: ; preds = %292
%296 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%297 = load i32, i32* @EXIT_FAILURE
%298 = call i32 @exit(i32 %297)
unreachable
299: ; preds = %170, %153
store i8 101, i8* %9
%300 = call i32 (i32, ...) @write(i32 %0, i8* %9, i64 1)
%301 = icmp eq i32 %300, 0
br i1 %301, label %302, label %306
302: ; preds = %299
%303 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%304 = load i32, i32* @EXIT_FAILURE
%305 = call i32 @exit(i32 %304)
unreachable
306: ; preds = %299
%307 = call i32 @closedir(i32* %151)
%308 = icmp eq i32 %307, -1
br i1 %308, label %309, label %313
309: ; preds = %306
%310 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%311 = load i32, i32* @EXIT_FAILURE
%312 = call i32 @exit(i32 %311)
unreachable
313: ; preds = %137, %306, %139, %25
%314 = call %struct.dirent* @readdir(i32* %14)
%315 = icmp eq %struct.dirent* %314, null
br i1 %315, label %316, label %25
316: ; preds = %313, %16
%317 = call i32 @closedir(i32* %14)
%318 = icmp eq i32 %317, -1
br i1 %318, label %319, label %323
319: ; preds = %316
%320 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%321 = load i32, i32* @EXIT_FAILURE
%322 = call i32 @exit(i32 %321)
unreachable
323: ; preds = %316
%324 = load i32, i32* @EXIT_SUCCESS
%325 = call i32 @exit(i32 %324)
unreachable
}