#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 int /*<<< orphan*/ pid_t;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ cd(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fork();
int open(char *, int, ...);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *strchr(char *, char);
int strlen(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ *strstr(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(void) {
  while (1) {
    char *argv_1[50] = {0}, *argv_2[50] = {0}, *temp = NULL;
    char input[100] = {0};
    int i, background = 0, work;
    char *process_1, *process_2;
    int fd[2], _fd;
    pid_t pid[2], _pid;
    char *pathname;
    printf("C_Shell:");
    fgets(input, 100, stdin);
    if (input[strlen(input) - 1] == '\n') {
      input[strlen(input) - 1] = '\0';
    }
    if (strchr(input, '&') != NULL) {
      char *p;
      p = strrchr(input, '&');
      input[(int)(p - input)] = '\0';
      background = 1;
    }
    if (strstr(input, "cd") != NULL) {
      temp = strtok(input, " ");
      for (i = 0; i <= 1; i++) {
        argv_1[i] = temp;
        temp = strtok(NULL, " ");
        cd(argv_1[1]);
      }
    }
    if (strchr(input, '|') != NULL) {
      work = 1;
      process_1 = strtok(input, "|");
      process_2 = strtok(NULL, "|");
      temp = strtok(process_1, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_1[i] = temp;
        temp = strtok(NULL, " ");
      }
      temp = strtok(process_2, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_2[i] = temp;
        temp = strtok(NULL, " ");
      }
    } else if (strchr(input, '<') != NULL) {
      work = 2;
      process_1 = strtok(input, "<");
      process_2 = strtok(NULL, "<");
      temp = strtok(process_1, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_1[i] = temp;
        temp = strtok(NULL, " ");
      }
      temp = strtok(process_2, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_2[i] = temp;
        temp = strtok(NULL, " ");
      }
    } else if (strchr(input, '>') != NULL) {
      work = 3;
      process_1 = strtok(input, ">");
      process_2 = strtok(NULL, ">");
      temp = strtok(process_1, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_1[i] = temp;
        temp = strtok(NULL, " ");
      }
      temp = strtok(process_2, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_2[i] = temp;
        temp = strtok(NULL, " ");
      }
    } else {
      work = 4;
      temp = strtok(input, " ");
      for (i = 0; i < 50 && temp != NULL; i++) {
        argv_1[i] = temp;
        temp = strtok(NULL, " ");
      }
    }
    pipe(&fd[0]);
    if ((_pid = fork()) != 0) {
      if (background == 1) {
        continue;
      }
      close(fd[0]);
      close(fd[1]);
      waitpid(_pid, NULL, 0);
    } else {
      switch (work) {
      case 1:
        if ((pid[0] = fork()) == 0) {
          close(fd[0]);
          close(1);
          dup(fd[1]);
          close(fd[1]);
          execvp(argv_1[0], argv_1);
          exit(0);
        }
        if ((pid[1] = fork()) == 0) {
          close(fd[1]);
          close(0);
          dup(fd[0]);
          close(fd[0]);
          execvp(argv_2[0], argv_2);
          exit(0);
        }
        close(fd[0]);
        close(fd[1]);
        waitpid(pid[1], NULL, 0);
        break;
      case 2:
        _fd = open(argv_2[0], O_RDONLY);
        close(0);
        dup2(_fd, 0);
        close(_fd);
        execvp(argv_1[0], argv_1);
        break;
      case 3:
        _fd = open(argv_2[0], O_WRONLY | O_CREAT | O_TRUNC, 0644);
        close(1);
        dup2(_fd, 1);
        close(_fd);
        execvp(argv_1[0], argv_1);
        break;
      case 4:
        execvp(argv_1[0], argv_1);
      }
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   10a0 <memset@plt>
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   10a0 <memset@plt>
movq   $0x0,-0x338(%rbp)
lea    -0x3a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10a0 <memset@plt>
movl   $0x0,-0x3a8(%rbp)
lea    0xd89(%rip),%rdi
call   1070 <printf@plt>
lea    -0x3a0(%rbp),%rdi
mov    0x2d36(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   10d0 <fgets@plt>
lea    -0x3a0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x3a0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12e1 <main+0xc1>
lea    -0x3a0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x3a0(%rbp,%rax,1)
lea    -0x3a0(%rbp),%rdi
mov    $0x26,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1339 <main+0x119>
lea    -0x3a0(%rbp),%rdi
mov    $0x26,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x3e8(%rbp)
mov    -0x3e8(%rbp),%rax
lea    -0x3a0(%rbp),%rcx
sub    %rcx,%rax
cltq
movb   $0x0,-0x3a0(%rbp,%rax,1)
movl   $0x1,-0x3a8(%rbp)
lea    -0x3a0(%rbp),%rdi
lea    0xcd2(%rip),%rsi
call   1140 <strstr@plt>
cmp    $0x0,%rax
je     13d9 <main+0x1b9>
lea    -0x3a0(%rbp),%rdi
lea    0xcb8(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
cmpl   $0x1,-0x3a4(%rbp)
jg     13d4 <main+0x1b4>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xc74(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x198(%rbp),%rdi
call   1030 <cd@plt>
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    137a <main+0x15a>
jmp    13d9 <main+0x1b9>
lea    -0x3a0(%rbp),%rdi
mov    $0x7c,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1570 <main+0x350>
movl   $0x1,-0x3ac(%rbp)
lea    -0x3a0(%rbp),%rdi
lea    0xc12(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3b8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbfb(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3c0(%rbp)
mov    -0x3b8(%rbp),%rdi
lea    0xbdf(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3e9(%rbp)
jge    1479 <main+0x259>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3e9(%rbp)
mov    -0x3e9(%rbp),%al
test   $0x1,%al
jne    148c <main+0x26c>
jmp    14cd <main+0x2ad>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xb6f(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    1453 <main+0x233>
mov    -0x3c0(%rbp),%rdi
lea    0xb41(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3ea(%rbp)
jge    1517 <main+0x2f7>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3ea(%rbp)
mov    -0x3ea(%rbp),%al
test   $0x1,%al
jne    152a <main+0x30a>
jmp    156b <main+0x34b>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x330(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xad1(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    14f1 <main+0x2d1>
jmp    1955 <main+0x735>
lea    -0x3a0(%rbp),%rdi
mov    $0x3c,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1707 <main+0x4e7>
movl   $0x2,-0x3ac(%rbp)
lea    -0x3a0(%rbp),%rdi
lea    0xa7d(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3b8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xa66(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3c0(%rbp)
mov    -0x3b8(%rbp),%rdi
lea    0xa48(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3eb(%rbp)
jge    1610 <main+0x3f0>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3eb(%rbp)
mov    -0x3eb(%rbp),%al
test   $0x1,%al
jne    1623 <main+0x403>
jmp    1664 <main+0x444>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0x9d8(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    15ea <main+0x3ca>
mov    -0x3c0(%rbp),%rdi
lea    0x9aa(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3ec(%rbp)
jge    16ae <main+0x48e>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3ec(%rbp)
mov    -0x3ec(%rbp),%al
test   $0x1,%al
jne    16c1 <main+0x4a1>
jmp    1702 <main+0x4e2>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x330(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0x93a(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    1688 <main+0x468>
jmp    1950 <main+0x730>
lea    -0x3a0(%rbp),%rdi
mov    $0x3e,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     189e <main+0x67e>
movl   $0x3,-0x3ac(%rbp)
lea    -0x3a0(%rbp),%rdi
lea    0x8e8(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3b8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0x8d1(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x3c0(%rbp)
mov    -0x3b8(%rbp),%rdi
lea    0x8b1(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3ed(%rbp)
jge    17a7 <main+0x587>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3ed(%rbp)
mov    -0x3ed(%rbp),%al
test   $0x1,%al
jne    17ba <main+0x59a>
jmp    17fb <main+0x5db>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0x841(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    1781 <main+0x561>
mov    -0x3c0(%rbp),%rdi
lea    0x813(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3ee(%rbp)
jge    1845 <main+0x625>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3ee(%rbp)
mov    -0x3ee(%rbp),%al
test   $0x1,%al
jne    1858 <main+0x638>
jmp    1899 <main+0x679>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x330(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0x7a3(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    181f <main+0x5ff>
jmp    194b <main+0x72b>
movl   $0x4,-0x3ac(%rbp)
lea    -0x3a0(%rbp),%rdi
lea    0x766(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
movl   $0x0,-0x3a4(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x3a4(%rbp)
mov    %al,-0x3ef(%rbp)
jge    18f2 <main+0x6d2>
cmpq   $0x0,-0x338(%rbp)
setne  %al
mov    %al,-0x3ef(%rbp)
mov    -0x3ef(%rbp),%al
test   $0x1,%al
jne    1905 <main+0x6e5>
jmp    1946 <main+0x726>
mov    -0x338(%rbp),%rcx
movslq -0x3a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0x6f6(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x338(%rbp)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
jmp    18cc <main+0x6ac>
jmp    194b <main+0x72b>
jmp    1950 <main+0x730>
jmp    1955 <main+0x735>
lea    -0x3c8(%rbp),%rdi
call   10c0 <pipe@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x3d8(%rbp)
cmp    $0x0,%eax
je     19b5 <main+0x795>
cmpl   $0x1,-0x3a8(%rbp)
jne    1989 <main+0x769>
jmp    1232 <main+0x12>
mov    -0x3c8(%rbp),%edi
call   10b0 <close@plt>
mov    -0x3c4(%rbp),%edi
call   10b0 <close@plt>
mov    -0x3d8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
jmp    1ba3 <main+0x983>
mov    -0x3ac(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x3f8(%rbp)
sub    $0x3,%eax
ja     1b9e <main+0x97e>
mov    -0x3f8(%rbp),%rax
lea    0x622(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x3d4(%rbp)
cmp    $0x0,%eax
jne    1a42 <main+0x822>
mov    -0x3c8(%rbp),%edi
call   10b0 <close@plt>
mov    $0x1,%edi
call   10b0 <close@plt>
mov    -0x3c4(%rbp),%edi
call   1090 <dup@plt>
mov    -0x3c4(%rbp),%edi
call   10b0 <close@plt>
mov    -0x1a0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1110 <execvp@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x3d0(%rbp)
cmp    $0x0,%eax
jne    1a9a <main+0x87a>
mov    -0x3c4(%rbp),%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   10b0 <close@plt>
mov    -0x3c8(%rbp),%edi
call   1090 <dup@plt>
mov    -0x3c8(%rbp),%edi
call   10b0 <close@plt>
mov    -0x330(%rbp),%rdi
lea    -0x330(%rbp),%rsi
call   1110 <execvp@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    -0x3c8(%rbp),%edi
call   10b0 <close@plt>
mov    -0x3c4(%rbp),%edi
call   10b0 <close@plt>
mov    -0x3d0(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
jmp    1b9e <main+0x97e>
mov    -0x330(%rbp),%rdi
mov    0x2504(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x3cc(%rbp)
xor    %edi,%edi
call   10b0 <close@plt>
mov    -0x3cc(%rbp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
mov    -0x3cc(%rbp),%edi
call   10b0 <close@plt>
mov    -0x1a0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1110 <execvp@plt>
jmp    1b9e <main+0x97e>
mov    -0x330(%rbp),%rdi
mov    0x2490(%rip),%rax
mov    (%rax),%esi
mov    0x24c7(%rip),%rax
or     (%rax),%esi
mov    0x24b6(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x3cc(%rbp)
mov    $0x1,%edi
call   10b0 <close@plt>
mov    -0x3cc(%rbp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    -0x3cc(%rbp),%edi
call   10b0 <close@plt>
mov    -0x1a0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1110 <execvp@plt>
jmp    1b9e <main+0x97e>
mov    -0x1a0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1110 <execvp@plt>
jmp    1ba3 <main+0x983>
jmp    1232 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3a8,%rsp
lea    0x10(%rsp),%r12
lea    0xddf(%rip),%rbp
lea    0xdda(%rip),%r15
jmp    126f <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ebx
mov    0x8(%rsp),%edi
call   10b0 <close@plt>
mov    0xc(%rsp),%edi
call   10b0 <close@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    $0x190,%edx
lea    0x80(%rsp),%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    $0x190,%edx
lea    0x210(%rsp),%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xd49(%rip),%rdi
call   1070 <printf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x64,%esi
call   10d0 <fgets@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r12,1)
jne    1304 <main+0xe4>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %r12,%rdi
mov    $0x26,%esi
call   1060 <strchr@plt>
mov    %rax,%r13
test   %rax,%rax
je     1330 <main+0x110>
mov    %r12,%rdi
mov    $0x26,%esi
call   1080 <strrchr@plt>
sub    %r12d,%eax
cltq
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r12,%rdi
lea    0xcdf(%rip),%rsi
call   1140 <strstr@plt>
test   %rax,%rax
je     1390 <main+0x170>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    %rax,0x80(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    %rax,%rbx
mov    0x88(%rsp),%rdi
call   1030 <cd@plt>
mov    %rbx,0x88(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    0x88(%rsp),%rdi
call   1030 <cd@plt>
mov    %r12,%rdi
mov    $0x7c,%esi
call   1060 <strchr@plt>
mov    %r12,%rdi
test   %rax,%rax
je     1450 <main+0x230>
mov    %r15,%rsi
call   1100 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1100 <strtok@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
test   %rax,%rax
je     1401 <main+0x1e1>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,0x80(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1401 <main+0x1e1>
add    $0x1,%rbx
test   %rax,%rax
jne    13e0 <main+0x1c0>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     1610 <main+0x3f0>
xor    %ebx,%ebx
nopl   (%rax)
mov    %rax,0x210(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1610 <main+0x3f0>
add    $0x1,%rbx
test   %rax,%rax
jne    1420 <main+0x200>
jmp    1610 <main+0x3f0>
nopw   0x0(%rax,%rax,1)
mov    $0x3c,%esi
call   1060 <strchr@plt>
mov    %r12,%rdi
test   %rax,%rax
je     150a <main+0x2ea>
lea    0xbb3(%rip),%r14
mov    %r14,%rsi
call   1100 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1100 <strtok@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
test   %rax,%rax
je     14c1 <main+0x2a1>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rax,0x80(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     14c1 <main+0x2a1>
add    $0x1,%rbx
test   %rax,%rax
jne    14a0 <main+0x280>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    $0x2,%r14d
test   %rax,%rax
je     1610 <main+0x3f0>
xor    %ebx,%ebx
nopl   (%rax)
mov    %rax,0x210(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1610 <main+0x3f0>
add    $0x1,%rbx
test   %rax,%rax
jne    14e0 <main+0x2c0>
jmp    1610 <main+0x3f0>
mov    $0x3e,%esi
call   1060 <strchr@plt>
mov    %r12,%rdi
test   %rax,%rax
je     15c3 <main+0x3a3>
lea    0xafb(%rip),%r14
mov    %r14,%rsi
call   1100 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1100 <strtok@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
test   %rax,%rax
je     1581 <main+0x361>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,0x80(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1581 <main+0x361>
add    $0x1,%rbx
test   %rax,%rax
jne    1560 <main+0x340>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    $0x3,%r14d
test   %rax,%rax
je     1610 <main+0x3f0>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %rax,0x210(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1610 <main+0x3f0>
add    $0x1,%rbx
test   %rax,%rax
jne    15a0 <main+0x380>
jmp    1610 <main+0x3f0>
mov    %rbp,%rsi
call   1100 <strtok@plt>
mov    $0x4,%r14d
test   %rax,%rax
je     1610 <main+0x3f0>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %rax,0x80(%rsp,%rbx,8)
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <strtok@plt>
cmp    $0x30,%rbx
ja     1610 <main+0x3f0>
add    $0x1,%rbx
test   %rax,%rax
jne    15e0 <main+0x3c0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x8(%rsp),%rdi
call   10c0 <pipe@plt>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1640 <main+0x420>
test   %r13,%r13
jne    126f <main+0x4f>
jmp    1250 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%r14d
cmp    $0x3,%r14d
ja     126f <main+0x4f>
lea    0x9ab(%rip),%rcx
movslq (%rcx,%r14,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1710 <main+0x4f0>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
jne    1250 <main+0x30>
jmp    1747 <main+0x527>
mov    0x210(%rsp),%rdi
mov    0x2948(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10f0 <open@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   10b0 <close@plt>
mov    %ebx,%edi
xor    %esi,%esi
jmp    16ea <main+0x4ca>
mov    0x210(%rsp),%rdi
mov    0x2941(%rip),%rax
mov    (%rax),%esi
mov    0x28f8(%rip),%rax
or     (%rax),%esi
mov    0x2927(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10f0 <open@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   10b0 <close@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    0x80(%rsp),%rdi
lea    0x80(%rsp),%rsi
call   1110 <execvp@plt>
jmp    126f <main+0x4f>
mov    0x8(%rsp),%edi
call   10b0 <close@plt>
mov    $0x1,%edi
call   10b0 <close@plt>
mov    0xc(%rsp),%edi
call   1090 <dup@plt>
mov    0xc(%rsp),%edi
call   10b0 <close@plt>
mov    0x80(%rsp),%rdi
lea    0x80(%rsp),%rsi
jmp    1779 <main+0x559>
mov    0xc(%rsp),%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   10b0 <close@plt>
mov    0x8(%rsp),%edi
call   1090 <dup@plt>
mov    0x8(%rsp),%edi
call   10b0 <close@plt>
mov    0x210(%rsp),%rdi
lea    0x210(%rsp),%rsi
call   1110 <execvp@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"C_Shell:\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"cd\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [2 x i8] c"<\00"
@.str.5 = [2 x i8] c">\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8*]
%3 = alloca [50 x i8*]
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [2 x i32]
%12 = alloca i32
%13 = alloca [2 x i32]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
store i32 0, i32* %1
br label %17
17: ; preds = %0, %252, %352
%18 = bitcast [50 x i8*]* %2 to i8*
%19 = bitcast [50 x i8*]* %3 to i8*
store i8* null, i8** %4
%20 = bitcast [100 x i8]* %5 to i8*
store i32 0, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fgets(i8* %22, i32 100, i32 %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %39
33: ; preds = %17
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %33, %17
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%41 = call i32* @strchr(i8* %40, i8 signext 38)
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %54
43: ; preds = %39
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%45 = call i8* @strrchr(i8* %44, i8 signext 38)
store i8* %45, i8** %16
%46 = load i8*, i8** %16
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%48 = ptrtoint i8* %46 to i64
%49 = ptrtoint i8* %47 to i64
%50 = sub i64 %48, %49
%51 = trunc i64 %50 to i32
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %52
store i8 0, i8* %53
store i32 1, i32* %7
br label %54
54: ; preds = %43, %39
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%56 = call i32* @strstr(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %77
58: ; preds = %54
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %60, i8** %4
store i32 0, i32* %6
br label %61
61: ; preds = %73, %58
%62 = load i32, i32* %6
%63 = icmp sle i32 %62, 1
br i1 %63, label %64, label %76
64: ; preds = %61
%65 = load i8*, i8** %4
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %67
store i8* %65, i8** %68
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %69, i8** %4
%70 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 1
%71 = load i8*, i8** %70
%72 = call i32 @cd(i8* %71)
br label %73
73: ; preds = %64
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %61
76: ; preds = %61
br label %77
77: ; preds = %76, %54
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%79 = call i32* @strchr(i8* %78, i8 signext 124)
%80 = icmp ne i32* %79, null
br i1 %80, label %81, label %125
81: ; preds = %77
store i32 1, i32* %8
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%83 = call i8* @strtok(i8* %82, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %83, i8** %9
%84 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %84, i8** %10
%85 = load i8*, i8** %9
%86 = call i8* @strtok(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %86, i8** %4
store i32 0, i32* %6
br label %87
87: ; preds = %101, %81
%88 = load i32, i32* %6
%89 = icmp slt i32 %88, 50
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i8*, i8** %4
%92 = icmp ne i8* %91, null
br label %93
93: ; preds = %90, %87
%94 = phi i1 [ false, %87 ], [ %92, %90 ]
br i1 %94, label %95, label %104
95: ; preds = %93
%96 = load i8*, i8** %4
%97 = load i32, i32* %6
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %98
store i8* %96, i8** %99
%100 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %100, i8** %4
br label %101
101: ; preds = %95
%102 = load i32, i32* %6
%103 = add nsw i32 %102, 1
store i32 %103, i32* %6
br label %87
104: ; preds = %93
%105 = load i8*, i8** %10
%106 = call i8* @strtok(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %106, i8** %4
store i32 0, i32* %6
br label %107
107: ; preds = %121, %104
%108 = load i32, i32* %6
%109 = icmp slt i32 %108, 50
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load i8*, i8** %4
%112 = icmp ne i8* %111, null
br label %113
113: ; preds = %110, %107
%114 = phi i1 [ false, %107 ], [ %112, %110 ]
br i1 %114, label %115, label %124
115: ; preds = %113
%116 = load i8*, i8** %4
%117 = load i32, i32* %6
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %118
store i8* %116, i8** %119
%120 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %120, i8** %4
br label %121
121: ; preds = %115
%122 = load i32, i32* %6
%123 = add nsw i32 %122, 1
store i32 %123, i32* %6
br label %107
124: ; preds = %113
br label %244
125: ; preds = %77
%126 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%127 = call i32* @strchr(i8* %126, i8 signext 60)
%128 = icmp ne i32* %127, null
br i1 %128, label %129, label %173
129: ; preds = %125
store i32 2, i32* %8
%130 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%131 = call i8* @strtok(i8* %130, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %131, i8** %9
%132 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %132, i8** %10
%133 = load i8*, i8** %9
%134 = call i8* @strtok(i8* %133, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %134, i8** %4
store i32 0, i32* %6
br label %135
135: ; preds = %149, %129
%136 = load i32, i32* %6
%137 = icmp slt i32 %136, 50
br i1 %137, label %138, label %141
138: ; preds = %135
%139 = load i8*, i8** %4
%140 = icmp ne i8* %139, null
br label %141
141: ; preds = %138, %135
%142 = phi i1 [ false, %135 ], [ %140, %138 ]
br i1 %142, label %143, label %152
143: ; preds = %141
%144 = load i8*, i8** %4
%145 = load i32, i32* %6
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %146
store i8* %144, i8** %147
%148 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %148, i8** %4
br label %149
149: ; preds = %143
%150 = load i32, i32* %6
%151 = add nsw i32 %150, 1
store i32 %151, i32* %6
br label %135
152: ; preds = %141
%153 = load i8*, i8** %10
%154 = call i8* @strtok(i8* %153, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %154, i8** %4
store i32 0, i32* %6
br label %155
155: ; preds = %169, %152
%156 = load i32, i32* %6
%157 = icmp slt i32 %156, 50
br i1 %157, label %158, label %161
158: ; preds = %155
%159 = load i8*, i8** %4
%160 = icmp ne i8* %159, null
br label %161
161: ; preds = %158, %155
%162 = phi i1 [ false, %155 ], [ %160, %158 ]
br i1 %162, label %163, label %172
163: ; preds = %161
%164 = load i8*, i8** %4
%165 = load i32, i32* %6
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %166
store i8* %164, i8** %167
%168 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %168, i8** %4
br label %169
169: ; preds = %163
%170 = load i32, i32* %6
%171 = add nsw i32 %170, 1
store i32 %171, i32* %6
br label %155
172: ; preds = %161
br label %243
173: ; preds = %125
%174 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%175 = call i32* @strchr(i8* %174, i8 signext 62)
%176 = icmp ne i32* %175, null
br i1 %176, label %177, label %221
177: ; preds = %173
store i32 3, i32* %8
%178 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%179 = call i8* @strtok(i8* %178, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %179, i8** %9
%180 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %180, i8** %10
%181 = load i8*, i8** %9
%182 = call i8* @strtok(i8* %181, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %182, i8** %4
store i32 0, i32* %6
br label %183
183: ; preds = %197, %177
%184 = load i32, i32* %6
%185 = icmp slt i32 %184, 50
br i1 %185, label %186, label %189
186: ; preds = %183
%187 = load i8*, i8** %4
%188 = icmp ne i8* %187, null
br label %189
189: ; preds = %186, %183
%190 = phi i1 [ false, %183 ], [ %188, %186 ]
br i1 %190, label %191, label %200
191: ; preds = %189
%192 = load i8*, i8** %4
%193 = load i32, i32* %6
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %194
store i8* %192, i8** %195
%196 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %196, i8** %4
br label %197
197: ; preds = %191
%198 = load i32, i32* %6
%199 = add nsw i32 %198, 1
store i32 %199, i32* %6
br label %183
200: ; preds = %189
%201 = load i8*, i8** %10
%202 = call i8* @strtok(i8* %201, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %202, i8** %4
store i32 0, i32* %6
br label %203
203: ; preds = %217, %200
%204 = load i32, i32* %6
%205 = icmp slt i32 %204, 50
br i1 %205, label %206, label %209
206: ; preds = %203
%207 = load i8*, i8** %4
%208 = icmp ne i8* %207, null
br label %209
209: ; preds = %206, %203
%210 = phi i1 [ false, %203 ], [ %208, %206 ]
br i1 %210, label %211, label %220
211: ; preds = %209
%212 = load i8*, i8** %4
%213 = load i32, i32* %6
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %214
store i8* %212, i8** %215
%216 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %216, i8** %4
br label %217
217: ; preds = %211
%218 = load i32, i32* %6
%219 = add nsw i32 %218, 1
store i32 %219, i32* %6
br label %203
220: ; preds = %209
br label %242
221: ; preds = %173
store i32 4, i32* %8
%222 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%223 = call i8* @strtok(i8* %222, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %223, i8** %4
store i32 0, i32* %6
br label %224
224: ; preds = %238, %221
%225 = load i32, i32* %6
%226 = icmp slt i32 %225, 50
br i1 %226, label %227, label %230
227: ; preds = %224
%228 = load i8*, i8** %4
%229 = icmp ne i8* %228, null
br label %230
230: ; preds = %227, %224
%231 = phi i1 [ false, %224 ], [ %229, %227 ]
br i1 %231, label %232, label %241
232: ; preds = %230
%233 = load i8*, i8** %4
%234 = load i32, i32* %6
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %235
store i8* %233, i8** %236
%237 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %237, i8** %4
br label %238
238: ; preds = %232
%239 = load i32, i32* %6
%240 = add nsw i32 %239, 1
store i32 %240, i32* %6
br label %224
241: ; preds = %230
br label %242
242: ; preds = %241, %220
br label %243
243: ; preds = %242, %172
br label %244
244: ; preds = %243, %124
%245 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%246 = call i32 @pipe(i32* %245)
%247 = call i32 (...) @fork()
store i32 %247, i32* %14
%248 = icmp ne i32 %247, 0
br i1 %248, label %249, label %262
249: ; preds = %244
%250 = load i32, i32* %7
%251 = icmp eq i32 %250, 1
br i1 %251, label %252, label %253
252: ; preds = %249
br label %17
253: ; preds = %249
%254 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%255 = load i32, i32* %254
%256 = call i32 @close(i32 %255)
%257 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%258 = load i32, i32* %257
%259 = call i32 @close(i32 %258)
%260 = load i32, i32* %14
%261 = call i32 @waitpid(i32 %260, i32* null, i32 0)
br label %352
262: ; preds = %244
%263 = load i32, i32* %8
switch i32 %263, label %351 [
i32 1, label %264
i32 2, label %314
i32 3, label %328
i32 4, label %346
]
264: ; preds = %262
%265 = call i32 (...) @fork()
%266 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
store i32 %265, i32* %266
%267 = icmp eq i32 %265, 0
br i1 %267, label %268, label %284
268: ; preds = %264
%269 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%270 = load i32, i32* %269
%271 = call i32 @close(i32 %270)
%272 = call i32 @close(i32 1)
%273 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%274 = load i32, i32* %273
%275 = call i32 @dup(i32 %274)
%276 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%277 = load i32, i32* %276
%278 = call i32 @close(i32 %277)
%279 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%280 = load i8*, i8** %279
%281 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%282 = call i32 @execvp(i8* %280, i8** %281)
%283 = call i32 @exit(i32 0)
unreachable
284: ; preds = %264
%285 = call i32 (...) @fork()
%286 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
store i32 %285, i32* %286
%287 = icmp eq i32 %285, 0
br i1 %287, label %288, label %304
288: ; preds = %284
%289 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%290 = load i32, i32* %289
%291 = call i32 @close(i32 %290)
%292 = call i32 @close(i32 0)
%293 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%294 = load i32, i32* %293
%295 = call i32 @dup(i32 %294)
%296 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%297 = load i32, i32* %296
%298 = call i32 @close(i32 %297)
%299 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 0
%300 = load i8*, i8** %299
%301 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 0
%302 = call i32 @execvp(i8* %300, i8** %301)
%303 = call i32 @exit(i32 0)
unreachable
304: ; preds = %284
%305 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%306 = load i32, i32* %305
%307 = call i32 @close(i32 %306)
%308 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%309 = load i32, i32* %308
%310 = call i32 @close(i32 %309)
%311 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%312 = load i32, i32* %311
%313 = call i32 @waitpid(i32 %312, i32* null, i32 0)
br label %351
314: ; preds = %262
%315 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 0
%316 = load i8*, i8** %315
%317 = load i32, i32* @O_RDONLY
%318 = call i32 (i8*, i32, ...) @open(i8* %316, i32 %317)
store i32 %318, i32* %12
%319 = call i32 @close(i32 0)
%320 = load i32, i32* %12
%321 = call i32 @dup2(i32 %320, i32 0)
%322 = load i32, i32* %12
%323 = call i32 @close(i32 %322)
%324 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%325 = load i8*, i8** %324
%326 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%327 = call i32 @execvp(i8* %325, i8** %326)
br label %351
328: ; preds = %262
%329 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 0
%330 = load i8*, i8** %329
%331 = load i32, i32* @O_WRONLY
%332 = load i32, i32* @O_CREAT
%333 = or i32 %331, %332
%334 = load i32, i32* @O_TRUNC
%335 = or i32 %333, %334
%336 = call i32 (i8*, i32, ...) @open(i8* %330, i32 %335, i32 420)
store i32 %336, i32* %12
%337 = call i32 @close(i32 1)
%338 = load i32, i32* %12
%339 = call i32 @dup2(i32 %338, i32 1)
%340 = load i32, i32* %12
%341 = call i32 @close(i32 %340)
%342 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%343 = load i8*, i8** %342
%344 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%345 = call i32 @execvp(i8* %343, i8** %344)
br label %351
346: ; preds = %262
%347 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%348 = load i8*, i8** %347
%349 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%350 = call i32 @execvp(i8* %348, i8** %349)
br label %351
351: ; preds = %346, %262, %328, %314, %304
br label %352
352: ; preds = %351, %253
br label %17
}

LLVM IR (-O2):
@.str = [9 x i8] c"C_Shell:\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"cd\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [2 x i8] c"<\00"
@.str.5 = [2 x i8] c">\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
define i32 @main() {
%1 = alloca [50 x i8*]
%2 = alloca [50 x i8*]
%3 = alloca [100 x i8]
%4 = alloca [2 x i32]
%5 = bitcast [50 x i8*]* %1 to i8*
%6 = bitcast [50 x i8*]* %2 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast [2 x i32]* %4 to i8*
%9 = ptrtoint [100 x i8]* %3 to i64
%10 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 1
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%13 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 0
%14 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
br label %15
15: ; preds = %222, %0
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %7, i32 100, i32 %17)
%19 = call i32 @strlen(i8* %7)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %30
25: ; preds = %15
%26 = call i32 @strlen(i8* %7)
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %25, %15
%31 = call i32* @strchr(i8* %7, i8 signext 38)
%32 = icmp eq i32* %31, null
br i1 %32, label %40, label %33
33: ; preds = %30
%34 = call i8* @strrchr(i8* %7, i8 signext 38)
%35 = ptrtoint i8* %34 to i64
%36 = sub i64 %35, %9
%37 = shl i64 %36, 32
%38 = ashr exact i64 %37, 32
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %33, %30
%41 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %51, label %43
43: ; preds = %40
%44 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %44, i8** %13
%45 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8*, i8** %10
%47 = call i32 @cd(i8* %46)
store i8* %45, i8** %10
%48 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = load i8*, i8** %10
%50 = call i32 @cd(i8* %49)
br label %51
51: ; preds = %43, %40
%52 = call i32* @strchr(i8* %7, i8 signext 124)
%53 = icmp eq i32* %52, null
br i1 %53, label %80, label %54
54: ; preds = %51
%55 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%56 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%57 = call i8* @strtok(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%58 = icmp eq i8* %57, null
br i1 %58, label %68, label %59
59: ; preds = %54, %59
%60 = phi i64 [ %64, %59 ], [ 0, %54 ]
%61 = phi i8* [ %63, %59 ], [ %57, %54 ]
%62 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 %60
store i8* %61, i8** %62
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%64 = add nuw nsw i64 %60, 1
%65 = icmp ult i64 %60, 49
%66 = icmp ne i8* %63, null
%67 = select i1 %65, i1 %66, i1 false
br i1 %67, label %59, label %68
68: ; preds = %59, %54
%69 = call i8* @strtok(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%70 = icmp eq i8* %69, null
br i1 %70, label %150, label %71
71: ; preds = %68, %71
%72 = phi i64 [ %76, %71 ], [ 0, %68 ]
%73 = phi i8* [ %75, %71 ], [ %69, %68 ]
%74 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %72
store i8* %73, i8** %74
%75 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%76 = add nuw nsw i64 %72, 1
%77 = icmp ult i64 %72, 49
%78 = icmp ne i8* %75, null
%79 = select i1 %77, i1 %78, i1 false
br i1 %79, label %71, label %150
80: ; preds = %51
%81 = call i32* @strchr(i8* %7, i8 signext 60)
%82 = icmp eq i32* %81, null
br i1 %82, label %109, label %83
83: ; preds = %80
%84 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%85 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%86 = call i8* @strtok(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%87 = icmp eq i8* %86, null
br i1 %87, label %97, label %88
88: ; preds = %83, %88
%89 = phi i64 [ %93, %88 ], [ 0, %83 ]
%90 = phi i8* [ %92, %88 ], [ %86, %83 ]
%91 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 %89
store i8* %90, i8** %91
%92 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%93 = add nuw nsw i64 %89, 1
%94 = icmp ult i64 %89, 49
%95 = icmp ne i8* %92, null
%96 = select i1 %94, i1 %95, i1 false
br i1 %96, label %88, label %97
97: ; preds = %88, %83
%98 = call i8* @strtok(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%99 = icmp eq i8* %98, null
br i1 %99, label %150, label %100
100: ; preds = %97, %100
%101 = phi i64 [ %105, %100 ], [ 0, %97 ]
%102 = phi i8* [ %104, %100 ], [ %98, %97 ]
%103 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %101
store i8* %102, i8** %103
%104 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%105 = add nuw nsw i64 %101, 1
%106 = icmp ult i64 %101, 49
%107 = icmp ne i8* %104, null
%108 = select i1 %106, i1 %107, i1 false
br i1 %108, label %100, label %150
109: ; preds = %80
%110 = call i32* @strchr(i8* %7, i8 signext 62)
%111 = icmp eq i32* %110, null
br i1 %111, label %138, label %112
112: ; preds = %109
%113 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%114 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%115 = call i8* @strtok(i8* %113, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%116 = icmp eq i8* %115, null
br i1 %116, label %126, label %117
117: ; preds = %112, %117
%118 = phi i64 [ %122, %117 ], [ 0, %112 ]
%119 = phi i8* [ %121, %117 ], [ %115, %112 ]
%120 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 %118
store i8* %119, i8** %120
%121 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%122 = add nuw nsw i64 %118, 1
%123 = icmp ult i64 %118, 49
%124 = icmp ne i8* %121, null
%125 = select i1 %123, i1 %124, i1 false
br i1 %125, label %117, label %126
126: ; preds = %117, %112
%127 = call i8* @strtok(i8* %114, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%128 = icmp eq i8* %127, null
br i1 %128, label %150, label %129
129: ; preds = %126, %129
%130 = phi i64 [ %134, %129 ], [ 0, %126 ]
%131 = phi i8* [ %133, %129 ], [ %127, %126 ]
%132 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 %130
store i8* %131, i8** %132
%133 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%134 = add nuw nsw i64 %130, 1
%135 = icmp ult i64 %130, 49
%136 = icmp ne i8* %133, null
%137 = select i1 %135, i1 %136, i1 false
br i1 %137, label %129, label %150
138: ; preds = %109
%139 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%140 = icmp eq i8* %139, null
br i1 %140, label %150, label %141
141: ; preds = %138, %141
%142 = phi i64 [ %146, %141 ], [ 0, %138 ]
%143 = phi i8* [ %145, %141 ], [ %139, %138 ]
%144 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 %142
store i8* %143, i8** %144
%145 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%146 = add nuw nsw i64 %142, 1
%147 = icmp ult i64 %142, 49
%148 = icmp ne i8* %145, null
%149 = select i1 %147, i1 %148, i1 false
br i1 %149, label %141, label %150
150: ; preds = %71, %100, %129, %141, %68, %97, %126, %138
%151 = phi i32 [ 4, %138 ], [ 3, %126 ], [ 2, %97 ], [ 1, %68 ], [ 4, %141 ], [ 3, %129 ], [ 2, %100 ], [ 1, %71 ]
%152 = call i32 @pipe(i32* %11)
%153 = call i32 (...) @fork()
%154 = icmp eq i32 %153, 0
br i1 %154, label %162, label %155
155: ; preds = %150
br i1 %32, label %156, label %222
156: ; preds = %155
%157 = load i32, i32* %11
%158 = call i32 @close(i32 %157)
%159 = load i32, i32* %12
%160 = call i32 @close(i32 %159)
%161 = call i32 @waitpid(i32 %153, i32* null, i32 0)
br label %222
162: ; preds = %150
switch i32 %151, label %222 [
i32 1, label %163
i32 2, label %197
i32 3, label %206
i32 4, label %219
]
163: ; preds = %162
%164 = call i32 (...) @fork()
%165 = icmp eq i32 %164, 0
br i1 %165, label %166, label %177
166: ; preds = %163
%167 = load i32, i32* %11
%168 = call i32 @close(i32 %167)
%169 = call i32 @close(i32 1)
%170 = load i32, i32* %12
%171 = call i32 @dup(i32 %170)
%172 = load i32, i32* %12
%173 = call i32 @close(i32 %172)
%174 = load i8*, i8** %13
%175 = call i32 @execvp(i8* %174, i8** %13)
%176 = call i32 @exit(i32 0)
unreachable
177: ; preds = %163
%178 = call i32 (...) @fork()
%179 = icmp eq i32 %178, 0
br i1 %179, label %180, label %191
180: ; preds = %177
%181 = load i32, i32* %12
%182 = call i32 @close(i32 %181)
%183 = call i32 @close(i32 0)
%184 = load i32, i32* %11
%185 = call i32 @dup(i32 %184)
%186 = load i32, i32* %11
%187 = call i32 @close(i32 %186)
%188 = load i8*, i8** %14
%189 = call i32 @execvp(i8* %188, i8** %14)
%190 = call i32 @exit(i32 0)
unreachable
191: ; preds = %177
%192 = load i32, i32* %11
%193 = call i32 @close(i32 %192)
%194 = load i32, i32* %12
%195 = call i32 @close(i32 %194)
%196 = call i32 @waitpid(i32 %178, i32* null, i32 0)
br label %222
197: ; preds = %162
%198 = load i8*, i8** %14
%199 = load i32, i32* @O_RDONLY
%200 = call i32 (i8*, i32, ...) @open(i8* %198, i32 %199)
%201 = call i32 @close(i32 0)
%202 = call i32 @dup2(i32 %200, i32 0)
%203 = call i32 @close(i32 %200)
%204 = load i8*, i8** %13
%205 = call i32 @execvp(i8* %204, i8** %13)
br label %222
206: ; preds = %162
%207 = load i8*, i8** %14
%208 = load i32, i32* @O_WRONLY
%209 = load i32, i32* @O_CREAT
%210 = or i32 %209, %208
%211 = load i32, i32* @O_TRUNC
%212 = or i32 %210, %211
%213 = call i32 (i8*, i32, ...) @open(i8* %207, i32 %212, i32 420)
%214 = call i32 @close(i32 1)
%215 = call i32 @dup2(i32 %213, i32 1)
%216 = call i32 @close(i32 %213)
%217 = load i8*, i8** %13
%218 = call i32 @execvp(i8* %217, i8** %13)
br label %222
219: ; preds = %162
%220 = load i8*, i8** %13
%221 = call i32 @execvp(i8* %220, i8** %13)
br label %222
222: ; preds = %156, %219, %162, %206, %197, %191, %155
br label %15
}