#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 put(int fd, 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(".");
  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) * 1024 + 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) * 1024 + 1);
              if (fname == NULL) {
                perror("Error malloc");
                exit(EXIT_FAILURE);
              }
              f_content = (char *)malloc(sizeof(char) * 1024 + 1);
              if (f_content == NULL) {
                perror("Error malloc");
                exit(EXIT_FAILURE);
              }
              if (strlen(de->d_name) >= 1024) {
                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):
<put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movb   $0x2d,-0x59(%rbp)
movb   $0x66,-0x5a(%rbp)
lea    0xe0c(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    128b <put+0x5b>
lea    0xd88(%rip),%rdi
call   1130 <perror@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1290 <put+0x60>
mov    -0x18(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1ac0 <put+0x890>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    1abb <put+0x88b>
movl   $0x1,-0x34(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    1301 <put+0xd1>
lea    0xd20(%rip),%rdi
call   1130 <perror@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1334 <put+0x104>
lea    0xcf9(%rip),%rdi
call   1130 <perror@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x30(%rbp),%edi
call   10f0 <S_ISREG@plt>
cmp    $0x0,%rax
je     15dc <put+0x3ac>
mov    -0x4(%rbp),%edi
lea    0xcd5(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    137f <put+0x14f>
lea    0xca2(%rip),%rdi
call   1130 <perror@plt>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x8,%rax
jae    13c7 <put+0x197>
lea    0xc5a(%rip),%rdi
call   1130 <perror@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    -0x40(%rbp),%rax
jae    13ff <put+0x1cf>
lea    0xc22(%rip),%rdi
call   1130 <perror@plt>
mov    0x2be0(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    0x2bde(%rip),%rax
mov    (%rax),%esi
call   1120 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    1438 <put+0x208>
lea    0xc04(%rip),%rdi
call   1130 <perror@plt>
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x401,%edi
call   1110 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    146b <put+0x23b>
lea    0xbe1(%rip),%rdi
call   1130 <perror@plt>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1470 <put+0x240>
mov    -0x38(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
je     1566 <put+0x336>
cmpl   $0xffffffff,-0x44(%rbp)
jne    14b1 <put+0x281>
lea    0xba8(%rip),%rdi
call   1130 <perror@plt>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x59(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    14ea <put+0x2ba>
lea    0xb37(%rip),%rdi
call   1130 <perror@plt>
mov    0x2af5(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    1523 <put+0x2f3>
lea    0xafe(%rip),%rdi
call   1130 <perror@plt>
mov    0x2abc(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    -0x44(%rbp),%eax
jge    1557 <put+0x327>
lea    0xaca(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a88(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    1470 <put+0x240>
movb   $0x2b,-0x59(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x59(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    15a3 <put+0x373>
lea    0xa7e(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a3c(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    15ce <put+0x39e>
lea    0xa96(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a11(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1ab6 <put+0x886>
mov    -0x30(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1ab1 <put+0x881>
mov    -0x4(%rbp),%edi
lea    0xa6c(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    $0x3,%eax
jge    1627 <put+0x3f7>
lea    0x9fa(%rip),%rdi
call   1130 <perror@plt>
mov    0x29b8(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1080 <chdir@plt>
lea    0xa32(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1665 <put+0x435>
lea    0x9ae(%rip),%rdi
call   1130 <perror@plt>
mov    0x297a(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    166a <put+0x43a>
mov    -0x20(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1a43 <put+0x813>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0x9da(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     16bb <put+0x48b>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0x9bc(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    16c0 <put+0x490>
jmp    166a <put+0x43a>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
jne    16f3 <put+0x4c3>
lea    0x93a(%rip),%rdi
call   1130 <perror@plt>
mov    0x28ec(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x30(%rbp),%edi
call   10f0 <S_ISREG@plt>
cmp    $0x0,%rax
je     19fc <put+0x7cc>
movb   $0x66,-0x5a(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5a(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1742 <put+0x512>
lea    0x8df(%rip),%rdi
call   1130 <perror@plt>
mov    0x289d(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x401,%edi
call   1110 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1775 <put+0x545>
lea    0x8d7(%rip),%rdi
call   1130 <perror@plt>
mov    0x286a(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x401,%edi
call   1110 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    17a8 <put+0x578>
lea    0x8a4(%rip),%rdi
call   1130 <perror@plt>
mov    0x2837(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
cmp    $0x400,%eax
jl     17d9 <put+0x5a9>
lea    0x8a5(%rip),%rdi
call   1130 <perror@plt>
mov    0x2806(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x58(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x8,%rax
jae    1831 <put+0x601>
lea    0x7f0(%rip),%rdi
call   1130 <perror@plt>
mov    0x27ae(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    -0x40(%rbp),%rax
jae    1869 <put+0x639>
lea    0x7b8(%rip),%rdi
call   1130 <perror@plt>
mov    0x2776(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    0x2774(%rip),%rax
mov    (%rax),%esi
call   1120 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    18a2 <put+0x672>
lea    0x79a(%rip),%rdi
call   1130 <perror@plt>
mov    0x273d(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    18a7 <put+0x677>
mov    -0x38(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    $0x64,%edx
call   10c0 <read@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
je     197d <put+0x74d>
movb   $0x2d,-0x59(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x59(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1901 <put+0x6d1>
lea    0x720(%rip),%rdi
call   1130 <perror@plt>
mov    0x26de(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x4,%rax
jae    193a <put+0x70a>
lea    0x6e7(%rip),%rdi
call   1130 <perror@plt>
mov    0x26a5(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    $0x0,%al
call   1050 <write@plt>
cmp    -0x44(%rbp),%eax
jge    196e <put+0x73e>
lea    0x6b3(%rip),%rdi
call   1130 <perror@plt>
mov    0x2671(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    18a7 <put+0x677>
movb   $0x2b,-0x59(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x59(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    19ba <put+0x78a>
lea    0x667(%rip),%rdi
call   1130 <perror@plt>
mov    0x2625(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    19e5 <put+0x7b5>
lea    0x6d3(%rip),%rdi
call   1130 <perror@plt>
mov    0x25fa(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
jmp    1a3e <put+0x80e>
movb   $0x64,-0x5a(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5a(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1a39 <put+0x809>
lea    0x5e8(%rip),%rdi
call   1130 <perror@plt>
mov    0x25a6(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1a3e <put+0x80e>
jmp    166a <put+0x43a>
movb   $0x65,-0x5a(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5a(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write@plt>
cltq
cmp    $0x1,%rax
jae    1a80 <put+0x850>
lea    0x5a1(%rip),%rdi
call   1130 <perror@plt>
mov    0x255f(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    1aac <put+0x87c>
lea    0x61d(%rip),%rdi
call   1130 <perror@plt>
mov    0x2533(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
jmp    1ab1 <put+0x881>
jmp    1ab6 <put+0x886>
jmp    1abb <put+0x88b>
jmp    1290 <put+0x60>
mov    -0x18(%rbp),%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    1aec <put+0x8bc>
lea    0x5ec(%rip),%rdi
call   1130 <perror@plt>
mov    0x24f3(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    0x24dd(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>

x86 assembly (clang, -O2):
<put>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbp
mov    %edi,%r15d
movl   $0x0,0x1c(%rsp)
movq   $0x0,0x10(%rsp)
movb   $0x2d,0xb(%rsp)
movb   $0x66,0xa(%rsp)
lea    0xe03(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
jne    127c <put+0x4c>
lea    0xd89(%rip),%rdi
jmp    1788 <put+0x558>
mov    %rax,%r13
mov    %rax,%rdi
call   1100 <readdir@plt>
test   %rax,%rax
jne    12a9 <put+0x79>
mov    %r13,%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
jne    179b <put+0x56b>
lea    0xe21(%rip),%rdi
jmp    1788 <put+0x558>
mov    %rax,%rbx
lea    0xb(%rsp),%r12
mov    %rbp,0x28(%rsp)
mov    %r13,0x20(%rsp)
jmp    12d8 <put+0xa8>
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1100 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     128c <put+0x5c>
mov    (%rbx),%rdi
mov    %rbp,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    12c8 <put+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 <put+0x551>
mov    (%rbx),%rdi
lea    0x18(%rsp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
je     17bb <put+0x58b>
mov    0x18(%rsp),%ebx
mov    %ebx,%edi
call   10f0 <S_ISREG@plt>
test   %rax,%rax
je     1495 <put+0x265>
mov    %r15d,%edi
lea    0xce4(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    1781 <put+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 <put+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 <put+0x551>
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1120 <open@plt>
cmp    $0xffffffff,%eax
je     17c4 <put+0x594>
mov    %eax,%r14d
mov    $0x401,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <put+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 <put+0x230>
cmp    $0xffffffff,%eax
je     17a9 <put+0x579>
mov    $0x1,%edx
mov    %r15d,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <write@plt>
test   %eax,%eax
je     1781 <put+0x551>
mov    $0x4,%edx
mov    %r15d,%edi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    1781 <put+0x551>
mov    0xc(%rsp),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    0xc(%rsp),%eax
jl     1781 <put+0x551>
mov    $0x1,%edi
call   1150 <sleep@plt>
jmp    13e0 <put+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 <put+0x551>
mov    %r14d,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    12c0 <put+0x90>
jmp    17df <put+0x5af>
mov    %ebx,%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
je     12c8 <put+0x98>
mov    %r15d,%edi
lea    0xbb5(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x2,%eax
jle    1781 <put+0x551>
mov    %rbp,%rdi
call   1080 <chdir@plt>
lea    0xb96(%rip),%r14
mov    %r14,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1270 <put+0x40>
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 <put+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 <put+0x551>
mov    %rbx,%rdi
call   10b0 <closedir@plt>
cmp    $0xffffffff,%eax
mov    0x28(%rsp),%rbp
mov    0x20(%rsp),%r13
jne    12c8 <put+0x98>
jmp    17e8 <put+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 <put+0x551>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1100 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     1503 <put+0x2d3>
mov    0x0(%r13),%rdi
mov    %r14,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1570 <put+0x340>
mov    0x0(%r13),%rdi
mov    %rbp,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1570 <put+0x340>
mov    0x0(%r13),%rdi
lea    0x18(%rsp),%rsi
call   10e0 <stat@plt>
cmp    $0xffffffff,%eax
je     17bb <put+0x58b>
mov    0x18(%rsp),%edi
call   10f0 <S_ISREG@plt>
test   %rax,%rax
je     1544 <put+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 <put+0x551>
mov    $0x401,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <put+0x582>
mov    %rax,%r14
mov    $0x401,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     17b2 <put+0x582>
mov    %rax,%rbx
mov    0x0(%r13),%rdi
call   1070 <strlen@plt>
cmp    $0x400,%eax
jge    17cd <put+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 <put+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 <put+0x551>
mov    0x295e(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1120 <open@plt>
cmp    $0xffffffff,%eax
je     17c4 <put+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 <put+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 <put+0x551>
mov    $0x4,%edx
mov    %r15d,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    $0x3,%eax
jbe    1781 <put+0x551>
mov    0xc(%rsp),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <write@plt>
cmp    0xc(%rsp),%eax
jl     1781 <put+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 <put+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 <put+0x551>
mov    %ebp,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
je     17d6 <put+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 <put+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 <put+0x558>
lea    0x880(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x858(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x85e(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x897(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x8c8(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x86b(%rip),%rdi
jmp    1788 <put+0x558>
lea    0x8c7(%rip),%rdi
jmp    1788 <put+0x558>

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

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