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

/* Forward declarations */

/* Type definitions */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, ...);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *opendir(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("Usage: %s <outdir> <tempdir>\n", argv[0]);
    exit(2);
  }
  setbuf(stdout, NULL);
  char temp_d[256];
  strcpy(temp_d, argv[2]);
  int readSortPipe[2];
  int sortParsePipe[2];
  if (pipe(readSortPipe) == -1) {
    fprintf(stderr, "Couldn't pipe\n");
  }
  if (pipe(sortParsePipe) == -1) {
    fprintf(stderr, "Couldn't pipe\n");
  }
  DIR *dp;
  struct dirent *ep;
  dp = opendir(temp_d);
  if (dp != NULL) {
    while ((ep = readdir(dp)) != NULL) {
      if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) {
        continue;
      }
      char temp[80];
      strcpy(temp, ep->d_name);
      char dired[80];
      strcpy(dired, temp_d);
      strcat(dired, ep->d_name);
      printf("+-------------------------------\n");
      printf("|Dired: %s\n", dired);
      printf("+-------------------------------\n");
      printf("| printing file contents to pipe\n");
      if (fork() == 0) {
        dup2(readSortPipe[1], STDOUT_FILENO);
        close(readSortPipe[1]);
        close(readSortPipe[0]);
        close(sortParsePipe[1]);
        close(sortParsePipe[0]);
        execlp("cat", "cat", dired, NULL);
        fprintf(stderr, "**ERROR** cat not executed **ERROR**\n");
        exit(3);
      }
      wait(NULL);
    }
    printf("+-------------------------------\n");
    (void)closedir(dp);
  } else
    fprintf(stderr, "Couldn't open the directory");
  if (fork() == 0) {
    dup2(readSortPipe[0], STDIN_FILENO);
    dup2(sortParsePipe[1], STDOUT_FILENO);
    close(readSortPipe[1]);
    close(readSortPipe[1]);
    close(sortParsePipe[1]);
    close(sortParsePipe[0]);
    execlp("sort", "sort", "-t:", "-k1,1d", "-k2,2V", NULL);
    fprintf(stderr, "**ERROR** sort not executed **ERROR**\n");
    exit(3);
  }
  close(readSortPipe[0]);
  close(readSortPipe[1]);
  wait(NULL);
  if (fork() == 0) {
    close(sortParsePipe[1]);
    dup2(sortParsePipe[0], STDIN_FILENO);
    char buf[BUFSIZ];
    char currentWord[80];
    int firstTime = 1;
    char index_d[80];
    strcpy(index_d, argv[1]);
    strcat(index_d, "index.txt");
    FILE *indexFile = fopen(index_d, "w");
    fprintf(indexFile, "INDEX\n");
    while (fgets(buf, sizeof(buf), stdin) != NULL) {
      if (buf[strlen(buf) - 1] == '\n') {
        char str[80];
        strcpy(str, buf);
        char *word;
        word = strtok(str, ":");
        strcpy(str, buf);
        char *number;
        number = strtok(str, ":");
        number = strtok(NULL, "#");
        if (strcmp(word, currentWord) == 0) {
          if (firstTime) {
            fprintf(indexFile, "%s: %s", word, number);
            firstTime = 0;
          }
          fprintf(indexFile, ", %s", number);
        } else {
          fprintf(indexFile, "\n\n%s: %s", word, number);
          strcpy(currentWord, word);
          firstTime = 0;
        }
      }
    }
    fprintf(indexFile, "\n");
    fclose(indexFile);
    close(sortParsePipe[0]);
    exit(0);
  }
  close(sortParsePipe[1]);
  close(sortParsePipe[0]);
  wait(NULL);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1292 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x2,%edi
call   1140 <exit@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <setbuf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x118(%rbp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    12e5 <main+0x95>
mov    0x2cfc(%rip),%rax
mov    (%rax),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
lea    -0x120(%rbp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1312 <main+0xc2>
mov    0x2ccf(%rip),%rax
mov    (%rax),%rdi
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     14d4 <main+0x284>
jmp    1338 <main+0xe8>
mov    -0x128(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
je     14b5 <main+0x265>
mov    -0x130(%rbp),%rax
mov    (%rax),%rdi
lea    0xcc8(%rip),%rsi
call   10e0 <strcmp@plt>
cmp    $0x0,%rax
je     1395 <main+0x145>
mov    -0x130(%rbp),%rax
mov    (%rax),%rdi
lea    0xca7(%rip),%rsi
call   10e0 <strcmp@plt>
cmp    $0x0,%rax
jne    139a <main+0x14a>
jmp    1338 <main+0xe8>
lea    -0x180(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x1d0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1d0(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    (%rax),%rsi
call   1130 <strcat@plt>
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x1d0(%rbp),%rsi
lea    0xc5d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xc2d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1170 <fork@plt>
cmp    $0x0,%rax
jne    14a7 <main+0x257>
mov    -0x114(%rbp),%edi
mov    0x2bba(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    -0x114(%rbp),%edi
call   10a0 <close@plt>
mov    -0x118(%rbp),%edi
call   10a0 <close@plt>
mov    -0x11c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x120(%rbp),%edi
call   10a0 <close@plt>
lea    -0x1d0(%rbp),%rdx
lea    0xc09(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1150 <execlp@plt>
mov    0x2b44(%rip),%rax
mov    (%rax),%rdi
lea    0xbee(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    $0x3,%edi
call   1140 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1160 <wait@plt>
jmp    1338 <main+0xe8>
lea    0xb74(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x128(%rbp),%rdi
call   10c0 <closedir@plt>
jmp    14ec <main+0x29c>
mov    0x2af5(%rip),%rax
mov    (%rax),%rdi
lea    0xbc5(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    $0x0,%al
call   1170 <fork@plt>
cmp    $0x0,%rax
jne    159e <main+0x34e>
mov    -0x118(%rbp),%edi
mov    0x2aae(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    -0x11c(%rbp),%edi
mov    0x2ad2(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    -0x114(%rbp),%edi
call   10a0 <close@plt>
mov    -0x114(%rbp),%edi
call   10a0 <close@plt>
mov    -0x11c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x120(%rbp),%edi
call   10a0 <close@plt>
lea    0xb6e(%rip),%rsi
lea    0xb6c(%rip),%rdx
lea    0xb69(%rip),%rcx
lea    0xb69(%rip),%r8
xor    %eax,%eax
mov    %eax,%r9d
mov    %rsi,%rdi
mov    $0x0,%al
call   1150 <execlp@plt>
mov    0x2a4d(%rip),%rax
mov    (%rax),%rdi
lea    0xb50(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    $0x3,%edi
call   1140 <exit@plt>
mov    -0x118(%rbp),%edi
call   10a0 <close@plt>
mov    -0x114(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1160 <wait@plt>
mov    $0x0,%al
call   1170 <fork@plt>
cmp    $0x0,%rax
jne    183f <main+0x5ef>
mov    -0x11c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x120(%rbp),%edi
mov    0x29d2(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    0x29d4(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x310(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x1d8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x308(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x1e0(%rbp)
movl   $0x1,-0x234(%rbp)
lea    -0x290(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x290(%rbp),%rdi
lea    0xaaf(%rip),%rsi
call   1130 <strcat@plt>
lea    -0x290(%rbp),%rdi
lea    0xaa6(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x298(%rbp)
mov    -0x298(%rbp),%rdi
lea    0xa8e(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    -0x308(%rbp),%rdi
mov    -0x310(%rbp),%rax
mov    %eax,%esi
mov    0x2940(%rip),%rax
mov    (%rax),%edx
call   10d0 <fgets@plt>
cmp    $0x0,%rax
je     180c <main+0x5bc>
mov    -0x308(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x308(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1807 <main+0x5b7>
mov    -0x308(%rbp),%rsi
lea    -0x2f0(%rbp),%rdi
call   1030 <strcpy@plt>
lea    -0x2f0(%rbp),%rdi
lea    0x9d3(%rip),%rsi
call   1120 <strtok@plt>
mov    -0x308(%rbp),%rsi
mov    %rax,-0x2f8(%rbp)
lea    -0x2f0(%rbp),%rdi
call   1030 <strcpy@plt>
lea    -0x2f0(%rbp),%rdi
lea    0x9a6(%rip),%rsi
call   1120 <strtok@plt>
mov    %rax,-0x300(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0x9d9(%rip),%rsi
call   1120 <strtok@plt>
mov    %rax,-0x300(%rbp)
mov    -0x2f8(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   10e0 <strcmp@plt>
cmp    $0x0,%rax
jne    17c2 <main+0x572>
cmpl   $0x0,-0x234(%rbp)
je     17a1 <main+0x551>
mov    -0x298(%rbp),%rdi
mov    -0x2f8(%rbp),%rdx
mov    -0x300(%rbp),%rcx
lea    0x990(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x0,-0x234(%rbp)
mov    -0x298(%rbp),%rdi
mov    -0x300(%rbp),%rdx
lea    0x963(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    1802 <main+0x5b2>
mov    -0x298(%rbp),%rdi
mov    -0x2f8(%rbp),%rdx
mov    -0x300(%rbp),%rcx
lea    0x940(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
lea    -0x230(%rbp),%rdi
mov    -0x2f8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x234(%rbp)
jmp    1807 <main+0x5b7>
jmp    1689 <main+0x439>
mov    -0x298(%rbp),%rdi
lea    0x88e(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    -0x298(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x120(%rbp),%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x11c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x120(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1160 <wait@plt>
xor    %edi,%edi
call   1140 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    134f <main+0xcf>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1080 <setbuf@plt>
mov    0x10(%r14),%rsi
lea    -0x240(%rbp),%rdi
call   1030 <strcpy@plt>
lea    -0x38(%rbp),%rdi
call   10c0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    12ee <main+0x6e>
mov    0x2cfb(%rip),%rax
mov    (%rax),%rcx
lea    0xd3f(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
lea    -0x30(%rbp),%rdi
call   10c0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    131c <main+0x9c>
mov    0x2ccd(%rip),%rax
mov    (%rax),%rcx
lea    0xd11(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
lea    -0x240(%rbp),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
jne    136a <main+0xea>
mov    0x2c9c(%rip),%rax
mov    (%rax),%rcx
lea    0xd28(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
jmp    139a <main+0x11a>
mov    (%r14),%rsi
lea    0xca7(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x2,%edi
call   1160 <exit@plt>
mov    %rax,%rbx
mov    %r14,-0x40(%rbp)
mov    %rax,%rdi
call   1120 <readdir@plt>
test   %rax,%rax
jne    152b <main+0x2ab>
lea    0xd5a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10d0 <closedir@plt>
mov    -0x40(%rbp),%r14
xor    %eax,%eax
call   11a0 <fork@plt>
mov    -0x38(%rbp),%edi
test   %rax,%rax
jne    143f <main+0x1bf>
mov    0x2c04(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
mov    -0x2c(%rbp),%edi
mov    0x2c2b(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x30(%rbp),%edi
call   10b0 <close@plt>
lea    0xc8f(%rip),%rdi
lea    0xc8d(%rip),%rdx
lea    0xc8a(%rip),%rcx
lea    0xc8a(%rip),%r8
mov    %rdi,%rsi
xor    %r9d,%r9d
xor    %eax,%eax
call   1180 <execlp@plt>
mov    0x2bb4(%rip),%rax
mov    (%rax),%rcx
lea    0xc73(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    $0x3,%edi
call   1160 <exit@plt>
call   10b0 <close@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   1190 <wait@plt>
xor    %eax,%eax
call   11a0 <fork@plt>
mov    %rax,%rbx
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x30(%rbp),%edi
test   %rbx,%rbx
jne    15fe <main+0x37e>
mov    0x2b40(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
mov    0x2b42(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%r15
mov    %r13,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x8(%r14),%rsi
lea    -0xa0(%rbp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xc09(%rip),%rsi
mov    %r14,%rdi
call   1150 <strcat@plt>
lea    0xc04(%rip),%rsi
mov    %r14,%rdi
call   1130 <fopen@plt>
mov    %rax,%r14
lea    0xbf4(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1170 <fwrite@plt>
mov    0x2aef(%rip),%rbx
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %r13d,%esi
call   10f0 <fgets@plt>
test   %rax,%rax
jne    1611 <main+0x391>
mov    $0xa,%edi
mov    %r14,%rsi
call   10e0 <fputc@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   1160 <exit@plt>
mov    %rax,%r12
lea    0xaf9(%rip),%r15
lea    -0xa0(%rbp),%r14
lea    0xba0(%rip),%r13
jmp    1564 <main+0x2e4>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1120 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     1382 <main+0x102>
mov    (%r12),%rdi
mov    %r15,%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1550 <main+0x2d0>
mov    (%r12),%rdi
lea    0xaad(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1550 <main+0x2d0>
mov    (%r12),%rsi
lea    -0xf0(%rbp),%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
lea    -0x240(%rbp),%rsi
call   1030 <strcpy@plt>
mov    (%r12),%rsi
mov    %r14,%rdi
call   1150 <strcat@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    0xa6c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    0xb27(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   11a0 <fork@plt>
test   %rax,%rax
je     1746 <main+0x4c6>
xor    %edi,%edi
call   1190 <wait@plt>
jmp    1550 <main+0x2d0>
call   10b0 <close@plt>
xor    %edi,%edi
call   1190 <wait@plt>
xor    %edi,%edi
call   1160 <exit@plt>
movl   $0x1,-0x40(%rbp)
lea    -0xf0(%rbp),%r12
mov    %r13,-0x50(%rbp)
mov    %r14,-0x48(%rbp)
jmp    1681 <main+0x401>
nopl   0x0(%rax)
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdi
lea    0xa9c(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%r14
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%r13
mov    0x297c(%rip),%rbx
movl   $0x0,-0x40(%rbp)
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %r13d,%esi
call   10f0 <fgets@plt>
test   %rax,%rax
je     1507 <main+0x287>
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r15,1)
jne    166b <main+0x3eb>
lea    -0x140(%rbp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
lea    0x9da(%rip),%r13
mov    %r13,%rsi
call   1140 <strtok@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1140 <strtok@plt>
xor    %edi,%edi
lea    0x9fa(%rip),%rsi
call   1140 <strtok@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %r12,%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
jne    1630 <main+0x3b0>
mov    %r12,%rbx
cmpl   $0x0,-0x40(%rbp)
mov    -0x48(%rbp),%r12
je     1719 <main+0x499>
mov    %r12,%rdi
lea    0x9d0(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    %r12,%rdi
lea    0x9b2(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    -0x50(%rbp),%r13
mov    %r12,%r14
mov    0x28a5(%rip),%rax
mov    %rbx,%r12
mov    %rax,%rbx
jmp    1664 <main+0x3e4>
mov    -0x34(%rbp),%edi
mov    0x28a0(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    -0x38(%rbp),%edi
call   10b0 <close@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x30(%rbp),%edi
call   10b0 <close@plt>
lea    0x8be(%rip),%rdi
lea    -0xa0(%rbp),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1180 <execlp@plt>
mov    0x2838(%rip),%rax
mov    (%rax),%rcx
lea    0x89e(%rip),%rdi
mov    $0x25,%esi
jmp    142b <main+0x1ab>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [30 x i8] c"Usage: %s <outdir> <tempdir>\0A\00"
@stdout = global i32 0
@stderr = global i32* null
@.str.1 = [15 x i8] c"Couldn't pipe\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [34 x i8] c"+-------------------------------\0A\00"
@.str.5 = [12 x i8] c"|Dired: %s\0A\00"
@.str.6 = [34 x i8] c"| printing file contents to pipe\0A\00"
@STDOUT_FILENO = global i32 0
@.str.7 = [4 x i8] c"cat\00"
@.str.8 = [38 x i8] c"**ERROR** cat not executed **ERROR**\0A\00"
@.str.9 = [28 x i8] c"Couldn't open the directory\00"
@STDIN_FILENO = global i32 0
@.str.10 = [5 x i8] c"sort\00"
@.str.11 = [4 x i8] c"-t:\00"
@.str.12 = [7 x i8] c"-k1,1d\00"
@.str.13 = [7 x i8] c"-k2,2V\00"
@.str.14 = [39 x i8] c"**ERROR** sort not executed **ERROR**\0A\00"
@BUFSIZ = global i32 0
@.str.15 = [10 x i8] c"index.txt\00"
@.str.16 = [2 x i8] c"w\00"
@.str.17 = [7 x i8] c"INDEX\0A\00"
@stdin = global i32 0
@.str.18 = [2 x i8] c":\00"
@.str.19 = [2 x i8] c"#\00"
@.str.20 = [7 x i8] c"%s: %s\00"
@.str.21 = [5 x i8] c", %s\00"
@.str.22 = [9 x i8] c"\0A\0A%s: %s\00"
@.str.23 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [2 x i32]
%8 = alloca [2 x i32]
%9 = alloca i32*
%10 = alloca %struct.dirent*
%11 = alloca [80 x i8]
%12 = alloca [80 x i8]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca [80 x i8]
%16 = alloca i32
%17 = alloca [80 x i8]
%18 = alloca i32*
%19 = alloca [80 x i8]
%20 = alloca i8*
%21 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 3
br i1 %23, label %24, label %30
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 2)
unreachable
30: ; preds = %2
%31 = load i32, i32* @stdout
%32 = call i32 @setbuf(i32 %31, i32* null)
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%39 = call i32 @pipe(i32* %38)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %30
%42 = load i32*, i32** @stderr
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %41, %30
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%46 = call i32 @pipe(i32* %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32*, i32** @stderr
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %48, %44
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%53 = call i32* @opendir(i8* %52)
store i32* %53, i32** %9
%54 = load i32*, i32** %9
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %123
56: ; preds = %51
br label %57
57: ; preds = %117, %73, %56
%58 = load i32*, i32** %9
%59 = call %struct.dirent* @readdir(i32* %58)
store %struct.dirent* %59, %struct.dirent** %10
%60 = icmp ne %struct.dirent* %59, null
br i1 %60, label %61, label %119
61: ; preds = %57
%62 = load %struct.dirent*, %struct.dirent** %10
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 0
%64 = load i8*, i8** %63
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %73, label %67
67: ; preds = %61
%68 = load %struct.dirent*, %struct.dirent** %10
%69 = getelementptr inbounds %struct.dirent, %struct.dirent* %68, i32 0, i32 0
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %67, %61
br label %57
74: ; preds = %67
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%76 = load %struct.dirent*, %struct.dirent** %10
%77 = getelementptr inbounds %struct.dirent, %struct.dirent* %76, i32 0, i32 0
%78 = load i8*, i8** %77
%79 = call i32 @strcpy(i8* %75, i8* %78)
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%82 = call i32 @strcpy(i8* %80, i8* %81)
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%84 = load %struct.dirent*, %struct.dirent** %10
%85 = getelementptr inbounds %struct.dirent, %struct.dirent* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = call i32 @strcat(i8* %83, i8* %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%89 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %89)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%93 = call i64 (...) @fork()
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %117
95: ; preds = %74
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%97 = load i32, i32* %96
%98 = load i32, i32* @STDOUT_FILENO
%99 = call i32 @dup2(i32 %97, i32 %98)
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @close(i32 %101)
%103 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%104 = load i32, i32* %103
%105 = call i32 @close(i32 %104)
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%110 = load i32, i32* %109
%111 = call i32 @close(i32 %110)
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%113 = call i32 (i8*, i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %112, i8* null)
%114 = load i32*, i32** @stderr
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%116 = call i32 @exit(i32 3)
unreachable
117: ; preds = %74
%118 = call i32 @wait(i32* null)
br label %57
119: ; preds = %57
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%121 = load i32*, i32** %9
%122 = call i32 @closedir(i32* %121)
br label %126
123: ; preds = %51
%124 = load i32*, i32** @stderr
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %124, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %126
126: ; preds = %123, %119
%127 = call i64 (...) @fork()
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %154
129: ; preds = %126
%130 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%131 = load i32, i32* %130
%132 = load i32, i32* @STDIN_FILENO
%133 = call i32 @dup2(i32 %131, i32 %132)
%134 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%135 = load i32, i32* %134
%136 = load i32, i32* @STDOUT_FILENO
%137 = call i32 @dup2(i32 %135, i32 %136)
%138 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%139 = load i32, i32* %138
%140 = call i32 @close(i32 %139)
%141 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%142 = load i32, i32* %141
%143 = call i32 @close(i32 %142)
%144 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%145 = load i32, i32* %144
%146 = call i32 @close(i32 %145)
%147 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%148 = load i32, i32* %147
%149 = call i32 @close(i32 %148)
%150 = call i32 (i8*, i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* null)
%151 = load i32*, i32** @stderr
%152 = call i32 (i32*, i8*, ...) @fprintf(i32* %151, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0))
%153 = call i32 @exit(i32 3)
unreachable
154: ; preds = %126
%155 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%156 = load i32, i32* %155
%157 = call i32 @close(i32 %156)
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%159 = load i32, i32* %158
%160 = call i32 @close(i32 %159)
%161 = call i32 @wait(i32* null)
%162 = call i64 (...) @fork()
%163 = icmp eq i64 %162, 0
br i1 %163, label %164, label %245
164: ; preds = %154
%165 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%166 = load i32, i32* %165
%167 = call i32 @close(i32 %166)
%168 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%169 = load i32, i32* %168
%170 = load i32, i32* @STDIN_FILENO
%171 = call i32 @dup2(i32 %169, i32 %170)
%172 = load i32, i32* @BUFSIZ
%173 = zext i32 %172 to i64
%174 = call i8* @llvm.stacksave()
store i8* %174, i8** %13
%175 = alloca i8, i64 %173
store i64 %173, i64* %14
store i32 1, i32* %16
%176 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%177 = load i8**, i8*** %5
%178 = getelementptr inbounds i8*, i8** %177, i64 1
%179 = load i8*, i8** %178
%180 = call i32 @strcpy(i8* %176, i8* %179)
%181 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%182 = call i32 @strcat(i8* %181, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%183 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%184 = call i32* @fopen(i8* %183, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %184, i32** %18
%185 = load i32*, i32** %18
%186 = call i32 (i32*, i8*, ...) @fprintf(i32* %185, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
br label %187
187: ; preds = %235, %164
%188 = trunc i64 %173 to i32
%189 = load i32, i32* @stdin
%190 = call i32* @fgets(i8* %175, i32 %188, i32 %189)
%191 = icmp ne i32* %190, null
br i1 %191, label %192, label %236
192: ; preds = %187
%193 = call i32 @strlen(i8* %175)
%194 = sub nsw i32 %193, 1
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds i8, i8* %175, i64 %195
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = icmp eq i32 %198, 10
br i1 %199, label %200, label %235
200: ; preds = %192
%201 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%202 = call i32 @strcpy(i8* %201, i8* %175)
%203 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%204 = call i8* @strtok(i8* %203, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i8* %204, i8** %20
%205 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%206 = call i32 @strcpy(i8* %205, i8* %175)
%207 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%208 = call i8* @strtok(i8* %207, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i8* %208, i8** %21
%209 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i64 0, i64 0))
store i8* %209, i8** %21
%210 = load i8*, i8** %20
%211 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%212 = call i64 @strcmp(i8* %210, i8* %211)
%213 = icmp eq i64 %212, 0
br i1 %213, label %214, label %226
214: ; preds = %200
%215 = load i32, i32* %16
%216 = icmp ne i32 %215, 0
br i1 %216, label %217, label %222
217: ; preds = %214
%218 = load i32*, i32** %18
%219 = load i8*, i8** %20
%220 = load i8*, i8** %21
%221 = call i32 (i32*, i8*, ...) @fprintf(i32* %218, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0), i8* %219, i8* %220)
store i32 0, i32* %16
br label %222
222: ; preds = %217, %214
%223 = load i32*, i32** %18
%224 = load i8*, i8** %21
%225 = call i32 (i32*, i8*, ...) @fprintf(i32* %223, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i8* %224)
br label %234
226: ; preds = %200
%227 = load i32*, i32** %18
%228 = load i8*, i8** %20
%229 = load i8*, i8** %21
%230 = call i32 (i32*, i8*, ...) @fprintf(i32* %227, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0), i8* %228, i8* %229)
%231 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%232 = load i8*, i8** %20
%233 = call i32 @strcpy(i8* %231, i8* %232)
store i32 0, i32* %16
br label %234
234: ; preds = %226, %222
br label %235
235: ; preds = %234, %192
br label %187
236: ; preds = %187
%237 = load i32*, i32** %18
%238 = call i32 (i32*, i8*, ...) @fprintf(i32* %237, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
%239 = load i32*, i32** %18
%240 = call i32 @fclose(i32* %239)
%241 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%242 = load i32, i32* %241
%243 = call i32 @close(i32 %242)
%244 = call i32 @exit(i32 0)
unreachable
245: ; preds = %154
%246 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%247 = load i32, i32* %246
%248 = call i32 @close(i32 %247)
%249 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%250 = load i32, i32* %249
%251 = call i32 @close(i32 %250)
%252 = call i32 @wait(i32* null)
%253 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [30 x i8] c"Usage: %s <outdir> <tempdir>\0A\00"
@stdout = global i32 0
@stderr = global i32* null
@.str.1 = [15 x i8] c"Couldn't pipe\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.5 = [12 x i8] c"|Dired: %s\0A\00"
@STDOUT_FILENO = global i32 0
@.str.7 = [4 x i8] c"cat\00"
@.str.8 = [38 x i8] c"**ERROR** cat not executed **ERROR**\0A\00"
@.str.9 = [28 x i8] c"Couldn't open the directory\00"
@STDIN_FILENO = global i32 0
@.str.10 = [5 x i8] c"sort\00"
@.str.11 = [4 x i8] c"-t:\00"
@.str.12 = [7 x i8] c"-k1,1d\00"
@.str.13 = [7 x i8] c"-k2,2V\00"
@.str.14 = [39 x i8] c"**ERROR** sort not executed **ERROR**\0A\00"
@BUFSIZ = global i32 0
@.str.15 = [10 x i8] c"index.txt\00"
@.str.16 = [2 x i8] c"w\00"
@.str.17 = [7 x i8] c"INDEX\0A\00"
@stdin = global i32 0
@.str.18 = [2 x i8] c":\00"
@.str.19 = [2 x i8] c"#\00"
@.str.20 = [7 x i8] c"%s: %s\00"
@.str.21 = [5 x i8] c", %s\00"
@.str.22 = [9 x i8] c"\0A\0A%s: %s\00"
@str.25 = [33 x i8] c"+-------------------------------\00"
@str.26 = [33 x i8] c"| printing file contents to pipe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca [80 x i8]
%11 = icmp eq i32 %0, 3
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 2)
unreachable
16: ; preds = %2
%17 = load i32, i32* @stdout
%18 = tail call i32 @setbuf(i32 %17, i32* null)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %19, i8* %21)
%23 = bitcast [2 x i32]* %4 to i8*
%24 = bitcast [2 x i32]* %5 to i8*
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%26 = call i32 @pipe(i32* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %16
%29 = load i32*, i32** @stderr
%30 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14, i64 1, i32* %29)
br label %31
31: ; preds = %28, %16
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%33 = call i32 @pipe(i32* %32)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i32*, i32** @stderr
%37 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14, i64 1, i32* %36)
br label %38
38: ; preds = %35, %31
%39 = call i32* @opendir(i8* %19)
%40 = icmp eq i32* %39, null
br i1 %40, label %95, label %41
41: ; preds = %38
%42 = call %struct.dirent* @readdir(i32* %39)
%43 = icmp eq %struct.dirent* %42, null
br i1 %43, label %92, label %44
44: ; preds = %41
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
br label %47
47: ; preds = %44, %57
%48 = phi %struct.dirent* [ %42, %44 ], [ %58, %57 ]
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i64 0, i32 0
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %47
%54 = load i8*, i8** %49
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %47, %53, %90
%58 = call %struct.dirent* @readdir(i32* %39)
%59 = icmp eq %struct.dirent* %58, null
br i1 %59, label %92, label %47
60: ; preds = %53
%61 = load i8*, i8** %49
%62 = call i32 @strcpy(i8* %45, i8* %61)
%63 = call i32 @strcpy(i8* %46, i8* %19)
%64 = load i8*, i8** %49
%65 = call i32 @strcat(i8* %46, i8* %64)
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.25, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.25, i64 0, i64 0))
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.26, i64 0, i64 0))
%70 = call i64 (...) @fork()
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %90
72: ; preds = %60
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%74 = load i32, i32* %73
%75 = load i32, i32* @STDOUT_FILENO
%76 = call i32 @dup2(i32 %74, i32 %75)
%77 = load i32, i32* %73
%78 = call i32 @close(i32 %77)
%79 = load i32, i32* %25
%80 = call i32 @close(i32 %79)
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%82 = load i32, i32* %81
%83 = call i32 @close(i32 %82)
%84 = load i32, i32* %32
%85 = call i32 @close(i32 %84)
%86 = call i32 (i8*, i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %46, i8* null)
%87 = load i32*, i32** @stderr
%88 = call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i64 37, i64 1, i32* %87)
%89 = call i32 @exit(i32 3)
unreachable
90: ; preds = %60
%91 = call i32 @wait(i32* null)
br label %57
92: ; preds = %57, %41
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.25, i64 0, i64 0))
%94 = call i32 @closedir(i32* %39)
br label %98
95: ; preds = %38
%96 = load i32*, i32** @stderr
%97 = call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i64 27, i64 1, i32* %96)
br label %98
98: ; preds = %95, %92
%99 = call i64 (...) @fork()
%100 = icmp eq i64 %99, 0
%101 = load i32, i32* %25
br i1 %100, label %102, label %122
102: ; preds = %98
%103 = load i32, i32* @STDIN_FILENO
%104 = call i32 @dup2(i32 %101, i32 %103)
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%106 = load i32, i32* %105
%107 = load i32, i32* @STDOUT_FILENO
%108 = call i32 @dup2(i32 %106, i32 %107)
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%110 = load i32, i32* %109
%111 = call i32 @close(i32 %110)
%112 = load i32, i32* %109
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* %105
%115 = call i32 @close(i32 %114)
%116 = load i32, i32* %32
%117 = call i32 @close(i32 %116)
%118 = call i32 (i8*, i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* null)
%119 = load i32*, i32** @stderr
%120 = call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i64 38, i64 1, i32* %119)
%121 = call i32 @exit(i32 3)
unreachable
122: ; preds = %98
%123 = call i32 @close(i32 %101)
%124 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%125 = load i32, i32* %124
%126 = call i32 @close(i32 %125)
%127 = call i32 @wait(i32* null)
%128 = call i64 (...) @fork()
%129 = icmp eq i64 %128, 0
%130 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%131 = load i32, i32* %130
%132 = call i32 @close(i32 %131)
%133 = load i32, i32* %32
br i1 %129, label %134, label %190
134: ; preds = %122
%135 = load i32, i32* @STDIN_FILENO
%136 = call i32 @dup2(i32 %133, i32 %135)
%137 = load i32, i32* @BUFSIZ
%138 = zext i32 %137 to i64
%139 = alloca i8, i64 %138
%140 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%141 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%142 = getelementptr inbounds i8*, i8** %1, i64 1
%143 = load i8*, i8** %142
%144 = call i32 @strcpy(i8* %141, i8* %143)
%145 = call i32 @strcat(i8* %141, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%146 = call i32* @fopen(i8* %141, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%147 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0), i64 6, i64 1, i32* %146)
%148 = load i32, i32* @stdin
%149 = call i32* @fgets(i8* %139, i32 %137, i32 %148)
%150 = icmp eq i32* %149, null
br i1 %150, label %184, label %151
151: ; preds = %134
%152 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
br label %153
153: ; preds = %151, %179
%154 = phi i32 [ 1, %151 ], [ %180, %179 ]
%155 = call i32 @strlen(i8* %139)
%156 = add nsw i32 %155, -1
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8, i8* %139, i64 %157
%159 = load i8, i8* %158
%160 = icmp eq i8 %159, 10
br i1 %160, label %161, label %179
161: ; preds = %153
%162 = call i32 @strcpy(i8* %152, i8* %139)
%163 = call i8* @strtok(i8* %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%164 = call i32 @strcpy(i8* %152, i8* %139)
%165 = call i8* @strtok(i8* %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%166 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i64 0, i64 0))
%167 = call i64 @strcmp(i8* %163, i8* %140)
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %175
169: ; preds = %161
%170 = icmp eq i32 %154, 0
br i1 %170, label %173, label %171
171: ; preds = %169
%172 = call i32 (i32*, i8*, ...) @fprintf(i32* %146, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0), i8* %163, i8* %166)
br label %173
173: ; preds = %171, %169
%174 = call i32 (i32*, i8*, ...) @fprintf(i32* %146, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i8* %166)
br label %178
175: ; preds = %161
%176 = call i32 (i32*, i8*, ...) @fprintf(i32* %146, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0), i8* %163, i8* %166)
%177 = call i32 @strcpy(i8* %140, i8* %163)
br label %178
178: ; preds = %175, %173
br label %179
179: ; preds = %178, %153
%180 = phi i32 [ 0, %178 ], [ %154, %153 ]
%181 = load i32, i32* @stdin
%182 = call i32* @fgets(i8* %139, i32 %137, i32 %181)
%183 = icmp eq i32* %182, null
br i1 %183, label %184, label %153
184: ; preds = %179, %134
%185 = call i32 @fputc(i32 10, i32* %146)
%186 = call i32 @fclose(i32* %146)
%187 = load i32, i32* %32
%188 = call i32 @close(i32 %187)
%189 = call i32 @exit(i32 0)
unreachable
190: ; preds = %122
%191 = call i32 @close(i32 %133)
%192 = call i32 @wait(i32* null)
%193 = call i32 @exit(i32 0)
unreachable
}