#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ close(int);
int dup2(int, int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int fileno(int /*<<< orphan*/);
scalar_t__ fork();
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  char buf[2048];
  while (1) {
    dup2(1, 1);
    dup2(2, 2);
    dup2(0, 0);
    printf("netdom> ");
    fgets(buf, 2048, stdin);
    buf[strlen(buf) - 1] = '\0';
    if (strcmp(buf, "exit") == 0) {
      exit(0);
    }
    int isBackgroundProc = 0;
    int stdout_redir = 0;
    int stderr_redir = 0;
    int stdin_redir = 0;
    int isPipe = 0;
    char *tokenLocation;
    int fd;
    int pipe_fd[2];
    if (strstr(buf, "&")) {
      tokenLocation = strstr(buf, "&");
      *tokenLocation = 0;
      isBackgroundProc = 1;
    }
    if (strstr(buf, " > ")) {
      tokenLocation = strstr(buf, " > ");
      char *file = tokenLocation + 3;
      fd = open(file, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU);
      if (fd < 0) {
        perror("Error opening file!\n");
        exit(1);
      }
      stdout_redir = 1;
      *tokenLocation = 0;
    }
    if (strstr(buf, " >> ")) {
      tokenLocation = strstr(buf, " >> ");
      char *file = tokenLocation + 4;
      fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRWXU);
      if (fd < 0) {
        perror("Error opening file!\n");
        exit(1);
      }
      stdout_redir = 1;
      *tokenLocation = 0;
    }
    if (strstr(buf, " 2> ")) {
      tokenLocation = strstr(buf, " 2> ");
      char *file = tokenLocation + 4;
      fd = open(file, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU);
      if (fd < 0) {
        perror("Error opening file!\n");
        exit(1);
      }
      stderr_redir = 1;
      *tokenLocation = 0;
    }
    if (strstr(buf, " 2>> ")) {
      tokenLocation = strstr(buf, " 2>> ");
      char *file = tokenLocation + 5;
      fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRWXU);
      if (fd < 0) {
        perror("Error opening file!\n");
        exit(1);
      }
      stderr_redir = 1;
      *tokenLocation = 0;
    }
    if (strstr(buf, " < ")) {
      tokenLocation = strstr(buf, " < ");
      char *file = tokenLocation + 3;
      fd = open(file, O_RDONLY);
      if (fd < 0) {
        perror("Error opening file!\n");
        exit(1);
      }
      stdin_redir = 1;
      *tokenLocation = 0;
    }
    int pipeMade = 0;
    char *threadName;
    char *myargv[2048];
    char temp_argv[2048][1024];
    int myargc = 0;
    if (strstr(buf, " | ")) {
      isPipe = 1;
      pipeMade = 1;
      tokenLocation = strstr(buf, " | ");
      pipe(pipe_fd);
      threadName = tokenLocation + 3;
      *tokenLocation = 0;
      int j = 0;
      while (threadName[j]) {
        int k = 0;
        while (threadName[j] && threadName[j] != ' ') {
          temp_argv[myargc][k] = threadName[j];
          j++;
          k++;
        }
        temp_argv[myargc][k] = 0;
        myargv[myargc] = temp_argv[myargc];
        myargc++;
        if (threadName[j])
          j++;
      }
      myargv[myargc] = NULL;
    }
    char *myargv2[2048];
    char temp_argv2[2048][1024];
    int myargc2 = 0;
    int j = 0;
    while (buf[j]) {
      int k = 0;
      while (buf[j] && buf[j] != ' ') {
        temp_argv2[myargc2][k] = buf[j];
        j++;
        k++;
      }
      temp_argv2[myargc2][k] = 0;
      myargv2[myargc2] = temp_argv2[myargc2];
      myargc2++;
      if (buf[j])
        j++;
    }
    myargv2[myargc2] = NULL;
    pid_t cpid;
    cpid = fork();
    if (cpid == 0) {
      if (stdout_redir) {
        if (dup2(fd, 1) == -1) {
          perror("Error redirecting stdout!\n");
          exit(1);
        }
      }
      if (stderr_redir) {
        if (dup2(fd, 2) == -1) {
          perror("Error redirecting stderr!\n");
          exit(1);
        }
      }
      if (stdin_redir) {
        if (dup2(fd, 0) == -1) {
          perror("Error redirecting stdin!\n");
          exit(1);
        }
      }
      if (isPipe) {
        if (dup2(pipe_fd[1], 1) == -1) {
          perror("Error creating pipe!\n");
          exit(1);
        }
      }
      execvp(myargv2[0], myargv2);
      if (isPipe) {
        close(pipe_fd[1]);
      }
      exit(1);
    } else {
      if (cpid < 0) {
        perror("Error sporking process o_O\n");
        exit(1);
      } else if (!isBackgroundProc) {
        waitpid(cpid, 0, 0);
      }
      if (isPipe) {
        close(pipe_fd[1]);
      }
    }
    if (pipeMade) {
      cpid = fork();
      if (cpid == 0) {
        if (dup2(pipe_fd[0], fileno(stdin)) == -1) {
          perror("Error redirecting stdin!\n");
          exit(1);
        }
        execvp(myargv[0], myargv);
        exit(1);
      } else {
        if (cpid < 0) {
          printf("Error sporking parent o_O\n");
          exit(1);
        } else {
          waitpid(cpid, 0, 0);
          close(pipe_fd[0]);
        }
      }
    }
    if (fd > 0) {
      close(fd);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4088b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <dup2@plt>
mov    $0x2,%esi
mov    %esi,%edi
call   1040 <dup2@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <dup2@plt>
lea    0xdd6(%rip),%rdi
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1080 <fgets@plt>
lea    -0x810(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x810(%rbp,%rax,1)
lea    -0x810(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1286 <main+0x96>
xor    %edi,%edi
call   10f0 <exit@plt>
movl   $0x0,-0x814(%rbp)
movl   $0x0,-0x818(%rbp)
movl   $0x0,-0x81c(%rbp)
movl   $0x0,-0x820(%rbp)
movl   $0x0,-0x824(%rbp)
lea    -0x810(%rbp),%rdi
lea    0xd48(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     1303 <main+0x113>
lea    -0x810(%rbp),%rdi
lea    0xd2b(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x814(%rbp)
lea    -0x810(%rbp),%rdi
lea    0xcff(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     13bb <main+0x1cb>
lea    -0x810(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x848(%rbp)
mov    -0x848(%rbp),%rdi
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
mov    0x2c8d(%rip),%rax
or     (%rax),%esi
mov    0x2c44(%rip),%rax
or     (%rax),%esi
mov    0x2c63(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jge    13a7 <main+0x1b7>
lea    0xc7c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x1,-0x818(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
lea    0xc60(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     1473 <main+0x283>
lea    -0x810(%rbp),%rdi
lea    0xc43(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x850(%rbp)
mov    -0x850(%rbp),%rdi
mov    0x2be6(%rip),%rax
mov    (%rax),%esi
mov    0x2b8d(%rip),%rax
or     (%rax),%esi
mov    0x2b8c(%rip),%rax
or     (%rax),%esi
mov    0x2bab(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jge    145f <main+0x26f>
lea    0xbc4(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x1,-0x818(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
lea    0xbad(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     152b <main+0x33b>
lea    -0x810(%rbp),%rdi
lea    0xb90(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x858(%rbp)
mov    -0x858(%rbp),%rdi
mov    0x2b2e(%rip),%rax
mov    (%rax),%esi
mov    0x2b1d(%rip),%rax
or     (%rax),%esi
mov    0x2ad4(%rip),%rax
or     (%rax),%esi
mov    0x2af3(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jge    1517 <main+0x327>
lea    0xb0c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x1,-0x81c(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
lea    0xafa(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     15e3 <main+0x3f3>
lea    -0x810(%rbp),%rdi
lea    0xadd(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x860(%rbp)
mov    -0x860(%rbp),%rdi
mov    0x2a76(%rip),%rax
mov    (%rax),%esi
mov    0x2a1d(%rip),%rax
or     (%rax),%esi
mov    0x2a1c(%rip),%rax
or     (%rax),%esi
mov    0x2a3b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jge    15cf <main+0x3df>
lea    0xa54(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x1,-0x81c(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
lea    0xa48(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     1680 <main+0x490>
lea    -0x810(%rbp),%rdi
lea    0xa2b(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x868(%rbp)
mov    -0x868(%rbp),%rdi
mov    0x2996(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jge    166c <main+0x47c>
lea    0x9b7(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x1,-0x820(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x86c(%rbp)
movl   $0x0,-0x204884(%rbp)
lea    -0x810(%rbp),%rdi
lea    0x99b(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     186c <main+0x67c>
movl   $0x1,-0x824(%rbp)
movl   $0x1,-0x86c(%rbp)
lea    -0x810(%rbp),%rdi
lea    0x96a(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x830(%rbp)
lea    -0x83c(%rbp),%rdi
call   1070 <pipe@plt>
mov    -0x830(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x878(%rbp)
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x204888(%rbp)
mov    -0x878(%rbp),%rax
movslq -0x204888(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1859 <main+0x669>
movl   $0x0,-0x20488c(%rbp)
mov    -0x878(%rbp),%rax
movslq -0x204888(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x4088a9(%rbp)
je     1774 <main+0x584>
mov    -0x878(%rbp),%rax
movslq -0x204888(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x4088a9(%rbp)
mov    -0x4088a9(%rbp),%al
test   $0x1,%al
jne    1787 <main+0x597>
jmp    17da <main+0x5ea>
mov    -0x878(%rbp),%rax
movslq -0x204888(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x204884(%rbp),%rcx
lea    -0x204880(%rbp),%rax
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x20488c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x204888(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204888(%rbp)
mov    -0x20488c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20488c(%rbp)
jmp    1733 <main+0x543>
movslq -0x204884(%rbp),%rcx
lea    -0x204880(%rbp),%rax
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x20488c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movslq -0x204884(%rbp),%rax
lea    -0x204880(%rbp),%rcx
shl    $0xa,%rax
add    %rax,%rcx
movslq -0x204884(%rbp),%rax
mov    %rcx,-0x4880(%rbp,%rax,8)
ff
mov    -0x204884(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204884(%rbp)
mov    -0x878(%rbp),%rax
movslq -0x204888(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1854 <main+0x664>
mov    -0x204888(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204888(%rbp)
jmp    1711 <main+0x521>
movslq -0x204884(%rbp),%rax
movq   $0x0,-0x4880(%rbp,%rax,8)
movl   $0x0,-0x408894(%rbp)
movl   $0x0,-0x408898(%rbp)
movslq -0x408898(%rbp),%rax
cmpb   $0x0,-0x810(%rbp,%rax,1)
je     19b9 <main+0x7c9>
movl   $0x0,-0x40889c(%rbp)
movslq -0x408898(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x4088aa(%rbp)
je     18da <main+0x6ea>
movslq -0x408898(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
setne  %al
mov    %al,-0x4088aa(%rbp)
mov    -0x4088aa(%rbp),%al
test   $0x1,%al
jne    18ed <main+0x6fd>
jmp    193d <main+0x74d>
movslq -0x408898(%rbp),%rax
mov    -0x810(%rbp,%rax,1),%dl
movslq -0x408894(%rbp),%rcx
lea    -0x408890(%rbp),%rax
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x40889c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x408898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408898(%rbp)
mov    -0x40889c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40889c(%rbp)
jmp    189f <main+0x6af>
movslq -0x408894(%rbp),%rcx
lea    -0x408890(%rbp),%rax
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x40889c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movslq -0x408894(%rbp),%rax
lea    -0x408890(%rbp),%rcx
shl    $0xa,%rax
add    %rax,%rcx
movslq -0x408894(%rbp),%rax
mov    %rcx,-0x208890(%rbp,%rax,8)
ff
mov    -0x408894(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408894(%rbp)
movslq -0x408898(%rbp),%rax
cmpb   $0x0,-0x810(%rbp,%rax,1)
je     19b4 <main+0x7c4>
mov    -0x408898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408898(%rbp)
jmp    1880 <main+0x690>
movslq -0x408894(%rbp),%rax
movq   $0x0,-0x208890(%rbp,%rax,8)
mov    $0x0,%al
call   1100 <fork@plt>
mov    %rax,-0x4088a8(%rbp)
cmpq   $0x0,-0x4088a8(%rbp)
jne    1b1e <main+0x92e>
cmpl   $0x0,-0x818(%rbp)
je     1a29 <main+0x839>
mov    -0x834(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1a24 <main+0x834>
lea    0x62c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1a29 <main+0x839>
cmpl   $0x0,-0x81c(%rbp)
je     1a6a <main+0x87a>
mov    -0x834(%rbp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1a65 <main+0x875>
lea    0x606(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1a6a <main+0x87a>
cmpl   $0x0,-0x820(%rbp)
je     1aa8 <main+0x8b8>
mov    -0x834(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1aa3 <main+0x8b3>
lea    0x5e3(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1aa8 <main+0x8b8>
cmpl   $0x0,-0x824(%rbp)
je     1ae9 <main+0x8f9>
mov    -0x838(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1ae4 <main+0x8f4>
lea    0x5bc(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1ae9 <main+0x8f9>
mov    -0x208890(%rbp),%rdi
lea    -0x208890(%rbp),%rsi
call   10e0 <execvp@plt>
cmpl   $0x0,-0x824(%rbp)
je     1b14 <main+0x924>
mov    -0x838(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpq   $0x0,-0x4088a8(%rbp)
jge    1b42 <main+0x952>
lea    0x574(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x814(%rbp)
jne    1b5f <main+0x96f>
mov    -0x4088a8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10b0 <waitpid@plt>
jmp    1b64 <main+0x974>
cmpl   $0x0,-0x824(%rbp)
je     1b7c <main+0x98c>
mov    -0x838(%rbp),%edi
call   1060 <close@plt>
jmp    1b81 <main+0x991>
cmpl   $0x0,-0x86c(%rbp)
je     1c56 <main+0xa66>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %rax,-0x4088a8(%rbp)
cmpq   $0x0,-0x4088a8(%rbp)
jne    1c0d <main+0xa1d>
mov    -0x83c(%rbp),%eax
mov    %eax,-0x4088b0(%rbp)
mov    0x240b(%rip),%rax
mov    (%rax),%edi
call   10a0 <fileno@plt>
mov    -0x4088b0(%rbp),%edi
mov    %eax,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1bf0 <main+0xa00>
lea    0x496(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x4880(%rbp),%rdi
lea    -0x4880(%rbp),%rsi
call   10e0 <execvp@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpq   $0x0,-0x4088a8(%rbp)
jge    1c31 <main+0xa41>
lea    0x4a1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x4088a8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10b0 <waitpid@plt>
mov    -0x83c(%rbp),%edi
call   1060 <close@plt>
jmp    1c51 <main+0xa61>
jmp    1c56 <main+0xa66>
cmpl   $0x0,-0x834(%rbp)
jle    1c6e <main+0xa7e>
mov    -0x834(%rbp),%edi
call   1060 <close@plt>
jmp    1202 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408828,%rsp
lea    0x20(%rsp),%r12
mov    0x2dcb(%rip),%r14
mov    0x2d7c(%rip),%r15
mov    0x2d9d(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    $0x2,%edi
mov    $0x2,%esi
call   1050 <dup2@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <dup2@plt>
lea    0xd92(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x800,%esi
call   10a0 <fgets@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %r12,%rdi
lea    0xd66(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     165a <main+0x44a>
mov    %r12,%rdi
mov    $0x26,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12c6 <main+0xb6>
movb   $0x0,(%rax)
mov    %rax,0x18(%rsp)
mov    %r12,%rdi
lea    0xd39(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     1320 <main+0x110>
mov    %rax,%rbp
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
or     (%r14),%esi
lea    0x3(%rbp),%rdi
or     (%r15),%esi
mov    (%rbx),%edx
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
js     164e <main+0x43e>
mov    %eax,%r13d
movb   $0x0,0x0(%rbp)
movl   $0x1,0xc(%rsp)
jmp    1328 <main+0x118>
nopw   0x0(%rax,%rax,1)
movl   $0x0,0xc(%rsp)
mov    %r12,%rdi
lea    0xcf5(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     1372 <main+0x162>
mov    %rax,%rbp
mov    0x2c62(%rip),%rax
mov    (%rax),%esi
or     (%r14),%esi
lea    0x4(%rbp),%rdi
or     (%r15),%esi
mov    (%rbx),%edx
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
js     164e <main+0x43e>
mov    %eax,%r13d
movb   $0x0,0x0(%rbp)
movl   $0x1,0xc(%rsp)
mov    %r12,%rdi
lea    0xcb0(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     13c0 <main+0x1b0>
mov    %rax,%rbp
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
or     (%r14),%esi
lea    0x4(%rbp),%rdi
or     (%r15),%esi
mov    (%rbx),%edx
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
js     164e <main+0x43e>
mov    %eax,%r13d
movb   $0x0,0x0(%rbp)
movl   $0x1,0x8(%rsp)
jmp    13c8 <main+0x1b8>
xchg   %ax,%ax
movl   $0x0,0x8(%rsp)
mov    %r12,%rdi
lea    0xc5f(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     1412 <main+0x202>
mov    %rax,%rbp
mov    0x2bc2(%rip),%rax
mov    (%rax),%esi
or     (%r14),%esi
lea    0x5(%rbp),%rdi
or     (%r15),%esi
mov    (%rbx),%edx
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
js     164e <main+0x43e>
mov    %eax,%r13d
movb   $0x0,0x0(%rbp)
movl   $0x1,0x8(%rsp)
mov    %r12,%rdi
lea    0xc1b(%rip),%rsi
call   1130 <strstr@plt>
mov    %rax,%r15
test   %rax,%rax
je     144c <main+0x23c>
lea    0x3(%r15),%rdi
mov    0x2b9c(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
js     164e <main+0x43e>
mov    %eax,%r13d
movb   $0x0,(%r15)
mov    %r12,%rdi
lea    0xbe5(%rip),%rsi
call   1130 <strstr@plt>
mov    %rax,%r14
test   %rax,%rax
je     1520 <main+0x310>
lea    0x10(%rsp),%rdi
call   1090 <pipe@plt>
movb   $0x0,(%r14)
cmpb   $0x0,0x3(%r14)
je     1510 <main+0x300>
lea    0x3(%r14),%r8
xor    %ecx,%ecx
lea    0x208820(%rsp),%rdx
xor    %esi,%esi
jmp    14e2 <main+0x2d2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%ebx
mov    %rcx,%rax
shl    $0xa,%rax
add    %rsp,%rax
add    $0x208820,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rax,0x4820(%rsp,%rcx,8)
add    $0x1,%rcx
cmpb   $0x1,0x0(%rbp,%rdi,1)
mov    %esi,%esi
sbb    $0xffffffffffffffff,%rsi
add    %rbp,%rsi
movslq %esi,%rax
add    $0x400,%rdx
cmpb   $0x0,0x3(%r14,%rax,1)
je     1512 <main+0x302>
movslq %esi,%rdi
add    %r8,%rdi
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%rdi,%rbp,1),%ebx
test   $0xdf,%bl
je     14a0 <main+0x290>
mov    %bl,(%rdx,%rbp,1)
add    $0x1,%rbp
jmp    14f0 <main+0x2e0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ecx,%ecx
mov    %ecx,%eax
movq   $0x0,0x4820(%rsp,%rax,8)
cmpb   $0x0,0x20(%rsp)
je     15b0 <main+0x3a0>
xor    %ebp,%ebp
lea    0x8820(%rsp),%rcx
xor    %edx,%edx
jmp    157f <main+0x36f>
nopl   0x0(%rax)
mov    %esi,%edi
mov    %rbp,%rax
shl    $0xa,%rax
add    %rsp,%rax
add    $0x8820,%rax
movb   $0x0,(%rdi,%rax,1)
mov    %rax,0x820(%rsp,%rbp,8)
add    $0x1,%rbp
mov    %edx,%edx
cmp    $0x1,%bl
sbb    $0xffffffffffffffff,%rdx
add    %rsi,%rdx
movslq %edx,%rax
add    $0x400,%rcx
cmpb   $0x0,0x20(%rsp,%rax,1)
je     15b2 <main+0x3a2>
movslq %edx,%rsi
lea    (%rsp,%rsi,1),%rdi
add    $0x20,%rdi
xor    %esi,%esi
nopl   0x0(%rax)
movzbl (%rdi,%rsi,1),%ebx
test   $0xdf,%bl
je     1540 <main+0x330>
mov    %bl,(%rcx,%rsi,1)
add    $0x1,%rsi
jmp    1590 <main+0x380>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %ebp,%eax
movq   $0x0,0x820(%rsp,%rax,8)
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
je     1661 <main+0x451>
js     1686 <main+0x476>
cmpq   $0x0,0x18(%rsp)
jne    15ea <main+0x3da>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
test   %r14,%r14
mov    0x2a04(%rip),%r14
mov    0x29b5(%rip),%r15
mov    0x29d6(%rip),%rbx
je     1638 <main+0x428>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
je     16b7 <main+0x4a7>
js     16e9 <main+0x4d9>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
mov    0x10(%rsp),%edi
call   1080 <close@plt>
test   %r13d,%r13d
jle    1240 <main+0x30>
mov    %r13d,%edi
call   1080 <close@plt>
jmp    1240 <main+0x30>
lea    0x9bd(%rip),%rdi
jmp    175a <main+0x54a>
xor    %edi,%edi
call   1110 <exit@plt>
cmpl   $0x0,0xc(%rsp)
je     1692 <main+0x482>
mov    %r13d,%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1692 <main+0x482>
lea    0x9be(%rip),%rdi
jmp    175a <main+0x54a>
lea    0xa18(%rip),%rdi
jmp    175a <main+0x54a>
cmpl   $0x0,0x8(%rsp)
je     16ff <main+0x4ef>
mov    %r13d,%edi
mov    $0x2,%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    16ff <main+0x4ef>
lea    0x9a8(%rip),%rdi
jmp    175a <main+0x54a>
mov    0x10(%rsp),%ebx
mov    0x2906(%rip),%rax
mov    (%rax),%edi
call   10c0 <fileno@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
je     1713 <main+0x503>
mov    0x4820(%rsp),%rdi
lea    0x4820(%rsp),%rsi
jmp    1731 <main+0x521>
lea    0x9d1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
test   %r15,%r15
je     171c <main+0x50c>
mov    %r13d,%edi
xor    %esi,%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    171c <main+0x50c>
lea    0x95b(%rip),%rdi
jmp    175a <main+0x54a>
test   %r14,%r14
jne    1740 <main+0x530>
mov    0x820(%rsp),%rdi
lea    0x820(%rsp),%rsi
call   1100 <execvp@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x14(%rsp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1769 <main+0x559>
lea    0x935(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x820(%rsp),%rdi
lea    0x820(%rsp),%rsi
call   1100 <execvp@plt>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

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

LLVM IR (-O2):
@.str = [9 x i8] c"netdom> \00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
@.str.3 = [4 x i8] c" > \00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@S_IRWXU = global i32 0
@.str.4 = [21 x i8] c"Error opening file!\0A\00"
@.str.5 = [5 x i8] c" >> \00"
@O_APPEND = global i32 0
@.str.6 = [5 x i8] c" 2> \00"
@.str.7 = [6 x i8] c" 2>> \00"
@.str.8 = [4 x i8] c" < \00"
@O_RDONLY = global i32 0
@.str.9 = [4 x i8] c" | \00"
@.str.10 = [27 x i8] c"Error redirecting stdout!\0A\00"
@.str.11 = [27 x i8] c"Error redirecting stderr!\0A\00"
@.str.12 = [26 x i8] c"Error redirecting stdin!\0A\00"
@.str.13 = [22 x i8] c"Error creating pipe!\0A\00"
@.str.14 = [28 x i8] c"Error sporking process o_O\0A\00"
@str = [26 x i8] c"Error sporking parent o_O\00"
define i32 @main() {
%1 = alloca [2048 x i8]
%2 = alloca [2 x i32]
%3 = alloca [2048 x i8*]
%4 = alloca [2048 x [1024 x i8]]
%5 = alloca [2048 x i8*]
%6 = alloca [2048 x [1024 x i8]]
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%8 = bitcast [2 x i32]* %2 to i8*
%9 = bitcast [2048 x i8*]* %3 to i8*
%10 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %4, i64 0, i64 0, i64 0
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = bitcast [2048 x i8*]* %5 to i8*
%13 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %6, i64 0, i64 0, i64 0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
br label %15
15: ; preds = %285, %0
%16 = phi i32 [ undef, %0 ], [ %124, %285 ]
%17 = call i32 @dup2(i32 1, i32 1)
%18 = call i32 @dup2(i32 2, i32 2)
%19 = call i32 @dup2(i32 0, i32 0)
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @stdin
%22 = call i32 @fgets(i8* %7, i32 2048, i32 %21)
%23 = call i32 @strlen(i8* %7)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %15
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %15
%32 = call i8* @strchr(i8* %7, i32 38)
%33 = icmp eq i8* %32, null
br i1 %33, label %35, label %34
34: ; preds = %31
store i8 0, i8* %32
br label %35
35: ; preds = %34, %31
%36 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %52, label %38
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %36, i64 3
%40 = load i32, i32* @O_CREAT
%41 = load i32, i32* @O_TRUNC
%42 = or i32 %41, %40
%43 = load i32, i32* @O_WRONLY
%44 = or i32 %42, %43
%45 = load i32, i32* @S_IRWXU
%46 = call i32 (i8*, i32, ...) @open(i8* %39, i32 %44, i32 %45)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %38
store i8 0, i8* %36
br label %52
52: ; preds = %51, %35
%53 = phi i32 [ %46, %51 ], [ %16, %35 ]
%54 = phi i32 [ 1, %51 ], [ 0, %35 ]
%55 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i8* %55, null
br i1 %56, label %71, label %57
57: ; preds = %52
%58 = getelementptr inbounds i8, i8* %55, i64 4
%59 = load i32, i32* @O_CREAT
%60 = load i32, i32* @O_APPEND
%61 = or i32 %60, %59
%62 = load i32, i32* @O_WRONLY
%63 = or i32 %61, %62
%64 = load i32, i32* @S_IRWXU
%65 = call i32 (i8*, i32, ...) @open(i8* %58, i32 %63, i32 %64)
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %57
%68 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %57
store i8 0, i8* %55
br label %71
71: ; preds = %70, %52
%72 = phi i32 [ %65, %70 ], [ %53, %52 ]
%73 = phi i32 [ 1, %70 ], [ %54, %52 ]
%74 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%75 = icmp eq i8* %74, null
br i1 %75, label %90, label %76
76: ; preds = %71
%77 = getelementptr inbounds i8, i8* %74, i64 4
%78 = load i32, i32* @O_CREAT
%79 = load i32, i32* @O_TRUNC
%80 = or i32 %79, %78
%81 = load i32, i32* @O_WRONLY
%82 = or i32 %80, %81
%83 = load i32, i32* @S_IRWXU
%84 = call i32 (i8*, i32, ...) @open(i8* %77, i32 %82, i32 %83)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %76
%87 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %76
store i8 0, i8* %74
br label %90
90: ; preds = %89, %71
%91 = phi i32 [ %84, %89 ], [ %72, %71 ]
%92 = phi i32 [ 1, %89 ], [ 0, %71 ]
%93 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%94 = icmp eq i8* %93, null
br i1 %94, label %109, label %95
95: ; preds = %90
%96 = getelementptr inbounds i8, i8* %93, i64 5
%97 = load i32, i32* @O_CREAT
%98 = load i32, i32* @O_APPEND
%99 = or i32 %98, %97
%100 = load i32, i32* @O_WRONLY
%101 = or i32 %99, %100
%102 = load i32, i32* @S_IRWXU
%103 = call i32 (i8*, i32, ...) @open(i8* %96, i32 %101, i32 %102)
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %95
%106 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %95
store i8 0, i8* %93
br label %109
109: ; preds = %108, %90
%110 = phi i32 [ %103, %108 ], [ %91, %90 ]
%111 = phi i32 [ 1, %108 ], [ %92, %90 ]
%112 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%113 = icmp eq i8* %112, null
br i1 %113, label %123, label %114
114: ; preds = %109
%115 = getelementptr inbounds i8, i8* %112, i64 3
%116 = load i32, i32* @O_RDONLY
%117 = call i32 (i8*, i32, ...) @open(i8* %115, i32 %116)
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %114
%120 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%121 = call i32 @exit(i32 1)
unreachable
122: ; preds = %114
store i8 0, i8* %112
br label %123
123: ; preds = %122, %109
%124 = phi i32 [ %117, %122 ], [ %110, %109 ]
%125 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%126 = icmp eq i8* %125, null
br i1 %126, label %165, label %127
127: ; preds = %123
%128 = call i32 @pipe(i32* %11)
%129 = getelementptr inbounds i8, i8* %125, i64 3
store i8 0, i8* %125
%130 = load i8, i8* %129
%131 = icmp eq i8 %130, 0
br i1 %131, label %161, label %132
132: ; preds = %127, %145
%133 = phi i64 [ %152, %145 ], [ 0, %127 ]
%134 = phi i32 [ %156, %145 ], [ 0, %127 ]
%135 = sext i32 %134 to i64
br label %136
136: ; preds = %132, %141
%137 = phi i64 [ 0, %132 ], [ %144, %141 ]
%138 = phi i64 [ %135, %132 ], [ %143, %141 ]
%139 = getelementptr inbounds i8, i8* %129, i64 %138
%140 = load i8, i8* %139
switch i8 %140, label %141 [
i8 0, label %145
i8 32, label %145
]
141: ; preds = %136
%142 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %4, i64 0, i64 %133, i64 %137
store i8 %140, i8* %142
%143 = add i64 %138, 1
%144 = add nuw i64 %137, 1
br label %136
145: ; preds = %136, %136
%146 = getelementptr inbounds i8, i8* %129, i64 %138
%147 = trunc i64 %138 to i32
%148 = and i64 %137, 4294967295
%149 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %4, i64 0, i64 %133, i64 %148
store i8 0, i8* %149
%150 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %4, i64 0, i64 %133, i64 0
%151 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %3, i64 0, i64 %133
store i8* %150, i8** %151
%152 = add nuw i64 %133, 1
%153 = load i8, i8* %146
%154 = icmp ne i8 %153, 0
%155 = zext i1 %154 to i32
%156 = add nsw i32 %147, %155
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8, i8* %129, i64 %157
%159 = load i8, i8* %158
%160 = icmp eq i8 %159, 0
br i1 %160, label %161, label %132
161: ; preds = %145, %127
%162 = phi i64 [ 0, %127 ], [ %152, %145 ]
%163 = and i64 %162, 4294967295
%164 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %3, i64 0, i64 %163
store i8* null, i8** %164
br label %165
165: ; preds = %161, %123
%166 = load i8, i8* %7
%167 = icmp eq i8 %166, 0
br i1 %167, label %195, label %168
168: ; preds = %165, %181
%169 = phi i64 [ %187, %181 ], [ 0, %165 ]
%170 = phi i32 [ %190, %181 ], [ 0, %165 ]
%171 = sext i32 %170 to i64
br label %172
172: ; preds = %168, %177
%173 = phi i64 [ 0, %168 ], [ %180, %177 ]
%174 = phi i64 [ %171, %168 ], [ %179, %177 ]
%175 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %174
%176 = load i8, i8* %175
switch i8 %176, label %177 [
i8 0, label %181
i8 32, label %181
]
177: ; preds = %172
%178 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %6, i64 0, i64 %169, i64 %173
store i8 %176, i8* %178
%179 = add i64 %174, 1
%180 = add nuw i64 %173, 1
br label %172
181: ; preds = %172, %172
%182 = trunc i64 %174 to i32
%183 = and i64 %173, 4294967295
%184 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %6, i64 0, i64 %169, i64 %183
store i8 0, i8* %184
%185 = getelementptr inbounds [2048 x [1024 x i8]], [2048 x [1024 x i8]]* %6, i64 0, i64 %169, i64 0
%186 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %5, i64 0, i64 %169
store i8* %185, i8** %186
%187 = add nuw i64 %169, 1
%188 = icmp ne i8 %176, 0
%189 = zext i1 %188 to i32
%190 = add nsw i32 %182, %189
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %191
%193 = load i8, i8* %192
%194 = icmp eq i8 %193, 0
br i1 %194, label %195, label %168
195: ; preds = %181, %165
%196 = phi i64 [ 0, %165 ], [ %187, %181 ]
%197 = and i64 %196, 4294967295
%198 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %5, i64 0, i64 %197
store i8* null, i8** %198
%199 = call i64 (...) @fork()
%200 = icmp eq i64 %199, 0
br i1 %200, label %201, label %244
201: ; preds = %195
%202 = icmp eq i32 %73, 0
br i1 %202, label %209, label %203
203: ; preds = %201
%204 = call i32 @dup2(i32 %124, i32 1)
%205 = icmp eq i32 %204, -1
br i1 %205, label %206, label %209
206: ; preds = %203
%207 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%208 = call i32 @exit(i32 1)
unreachable
209: ; preds = %203, %201
%210 = icmp eq i32 %111, 0
br i1 %210, label %217, label %211
211: ; preds = %209
%212 = call i32 @dup2(i32 %124, i32 2)
%213 = icmp eq i32 %212, -1
br i1 %213, label %214, label %217
214: ; preds = %211
%215 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%216 = call i32 @exit(i32 1)
unreachable
217: ; preds = %211, %209
br i1 %113, label %224, label %218
218: ; preds = %217
%219 = call i32 @dup2(i32 %124, i32 0)
%220 = icmp eq i32 %219, -1
br i1 %220, label %221, label %224
221: ; preds = %218
%222 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%223 = call i32 @exit(i32 1)
unreachable
224: ; preds = %218, %217
br i1 %126, label %238, label %225
225: ; preds = %224
%226 = load i32, i32* %14
%227 = call i32 @dup2(i32 %226, i32 1)
%228 = icmp eq i32 %227, -1
br i1 %228, label %229, label %232
229: ; preds = %225
%230 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
%231 = call i32 @exit(i32 1)
unreachable
232: ; preds = %225
%233 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %5, i64 0, i64 0
%234 = load i8*, i8** %233
%235 = call i32 @execvp(i8* %234, i8** %233)
%236 = load i32, i32* %14
%237 = call i32 @close(i32 %236)
br label %242
238: ; preds = %224
%239 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %5, i64 0, i64 0
%240 = load i8*, i8** %239
%241 = call i32 @execvp(i8* %240, i8** %239)
br label %242
242: ; preds = %238, %232
%243 = call i32 @exit(i32 1)
unreachable
244: ; preds = %195
%245 = icmp slt i64 %199, 0
br i1 %245, label %246, label %249
246: ; preds = %244
%247 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%248 = call i32 @exit(i32 1)
unreachable
249: ; preds = %244
br i1 %33, label %250, label %252
250: ; preds = %249
%251 = call i32 @waitpid(i64 %199, i32 0, i32 0)
br label %252
252: ; preds = %249, %250
br i1 %126, label %281, label %253
253: ; preds = %252
%254 = load i32, i32* %14
%255 = call i32 @close(i32 %254)
%256 = call i64 (...) @fork()
%257 = icmp eq i64 %256, 0
br i1 %257, label %258, label %272
258: ; preds = %253
%259 = load i32, i32* %11
%260 = load i32, i32* @stdin
%261 = call i32 @fileno(i32 %260)
%262 = call i32 @dup2(i32 %259, i32 %261)
%263 = icmp eq i32 %262, -1
br i1 %263, label %264, label %267
264: ; preds = %258
%265 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%266 = call i32 @exit(i32 1)
unreachable
267: ; preds = %258
%268 = getelementptr inbounds [2048 x i8*], [2048 x i8*]* %3, i64 0, i64 0
%269 = load i8*, i8** %268
%270 = call i32 @execvp(i8* %269, i8** %268)
%271 = call i32 @exit(i32 1)
unreachable
272: ; preds = %253
%273 = icmp slt i64 %256, 0
br i1 %273, label %274, label %277
274: ; preds = %272
%275 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%276 = call i32 @exit(i32 1)
unreachable
277: ; preds = %272
%278 = call i32 @waitpid(i64 %256, i32 0, i32 0)
%279 = load i32, i32* %11
%280 = call i32 @close(i32 %279)
br label %281
281: ; preds = %252, %277
%282 = icmp sgt i32 %124, 0
br i1 %282, label %283, label %285
283: ; preds = %281
%284 = call i32 @close(i32 %124)
br label %285
285: ; preds = %283, %281
br label %15
}