#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 */
#define E2BIG 144
#define EACCES 143
#define EFAULT 142
#define EINVAL 141
#define EIO 140
#define EISDIR 139
#define ELIBBAD 138
#define ELOOP 137
#define EMFILE 136
#define ENAMETOOLONG 135
#define ENFILE 134
#define ENOENT 133
#define ENOEXEC 132
#define ENOMEM 131
#define ENOTDIR 130
#define EPERM 129
#define ETXTBSY 128
int errno;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fork();
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  char ***history;
  history = malloc(200);
  char *input = (char *)malloc(80);
  int should_run = 1;
  int lastWhiteSpace = 0;
  int currentIndex = 0;
  int count = 0;
  int historyCount = 0;
  int parallelFlag = 0;
  int previousCommandFlag = 0;
  int historyFlag = 0;
  int iterations = 0;
  while (should_run) {
    printf("osh>");
    fgets(input, 80, stdin);
    char **args;
    args = (char **)malloc(80 / 2 + 1);
    int i, j = 0;
    char *holder;
    i = lastWhiteSpace = 0;
    if (strncmp(input, "exit", 4)) {
      while (input[i]) {
        if (input[i] == ' ' || input[i] == '\n') {
          holder = malloc(80 / 2 + 1);
          while (lastWhiteSpace < i) {
            if (input[lastWhiteSpace] == ' ') {
              lastWhiteSpace++;
              currentIndex = 0;
            } else if (input[lastWhiteSpace] == '\n') {
              break;
            } else {
              if (input[lastWhiteSpace] == '!')
                previousCommandFlag = 1;
              if (input[lastWhiteSpace] == '&') {
                parallelFlag = 1;
                lastWhiteSpace++;
                currentIndex++;
                continue;
              }
              holder[currentIndex] = input[lastWhiteSpace];
              lastWhiteSpace++;
              currentIndex++;
            }
          }
          if (holder[0] != '\0') {
            if (!strncmp(holder, "history", 7)) {
              historyFlag = 1;
            }
            args[j] = malloc(80 / 2 + 1);
            args[j] = holder;
            j++;
          }
        }
        i++;
      }
      lastWhiteSpace = currentIndex = 0;
      history[historyCount] = args;
      if (historyCount < 25)
        historyCount++;
      fflush(stdout);
      if (strncmp(args[0], "history", 7)) {
        if (previousCommandFlag) {
          if (args[0][1] == '!') {
            args = history[historyCount - 2];
            i = 1;
            while (args[0][0] == '!' && args[0][1] == '!' &&
                   historyCount - (2 + i) >= 0) {
              args = history[historyCount - (2 + i)];
              i++;
            }
          } else if (args[0][1] != '!') {
            int commandNumber = args[0][1] - '0';
            args = history[commandNumber];
          }
        }
      }
      if (!strncmp(args[0], "history", 7))
        historyFlag = 1;
      errno = 0;
      pid_t pid = fork();
      if (pid == 0) {
        if (strncmp(args[0], "history", 7)) {
          execvp(args[0], args);
          switch (errno) {
          case 0:
            printf("no error\n");
            break;
          case E2BIG:
            printf("E2BIG\n");
            break;
          case EACCES:
            printf("EACCES\n");
            break;
          case EFAULT:
            printf("EFAULT\n");
            break;
          case EINVAL:
            printf("EINVAL\n");
            break;
          case EIO:
            printf("EIO\n");
            break;
          case EISDIR:
            printf("EISDIR\n");
            break;
          case ELIBBAD:
            printf("ELIBBAD\n");
            break;
          case ELOOP:
            printf("ELOOP\n");
            break;
          case EMFILE:
            printf("EMFILE\n");
            break;
          case ENFILE:
            printf("ENFILE\n");
            break;
          case ENAMETOOLONG:
            printf("ENAMETOOLONG\n");
            break;
          case ENOENT:
            printf("ENOENT\n");
            break;
          case ENOMEM:
            printf("ENOMEM\n");
            break;
          case ENOEXEC:
            printf("ENOEXEC\n");
            break;
          case ENOTDIR:
            printf("ENOTDIR\n");
            break;
          case EPERM:
            printf("EPERM\n");
            break;
          case ETXTBSY:
            printf("ETXTBSY\n");
            break;
          default:
            printf("unknown error\n");
            break;
          };
        }
        return 0;
      }
      previousCommandFlag = 0;
      if (!parallelFlag) {
        wait(NULL);
        parallelFlag = 0;
      } else {
        parallelFlag = 0;
      }
      if (historyFlag) {
        for (i = 0; i <= iterations; i++) {
          printf("command %d: %s\n", i, history[i][0]);
        }
        historyFlag = 0;
      }
      if (iterations < 25) {
        iterations++;
      } else {
        for (i = 0; i < 25; i++) {
          history[i] = history[i + 1];
        }
        history[25] = NULL;
        historyCount == 25;
      }
    } else {
      should_run = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1869 <main+0x6e9>
lea    0x1046(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dd8(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1050 <fgets@plt>
mov    $0x29,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xfff(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     185d <main+0x6dd>
jmp    1263 <main+0xe3>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     13f9 <main+0x279>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     129f <main+0x11f>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    13eb <main+0x26b>
mov    $0x29,%edi
call   1060 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    137e <main+0x1fe>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    12e3 <main+0x163>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    1379 <main+0x1f9>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12fd <main+0x17d>
jmp    137e <main+0x1fe>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x21,%eax
jne    1319 <main+0x199>
movl   $0x1,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x26,%eax
jne    134c <main+0x1cc>
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ad <main+0x12d>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x58(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1379 <main+0x1f9>
jmp    12ad <main+0x12d>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13e6 <main+0x266>
mov    -0x58(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13b4 <main+0x234>
movl   $0x1,-0x38(%rbp)
mov    $0x29,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x58(%rbp),%rdx
mov    -0x48(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13eb <main+0x26b>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1263 <main+0xe3>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpl   $0x19,-0x2c(%rbp)
jge    142a <main+0x2aa>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
lea    0xe08(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     155a <main+0x3da>
cmpl   $0x0,-0x34(%rbp)
je     1555 <main+0x3d5>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x21,%eax
jne    1516 <main+0x396>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x21,%ecx
mov    %al,-0x69(%rbp)
jne    14d9 <main+0x359>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x21,%ecx
mov    %al,-0x69(%rbp)
jne    14d9 <main+0x359>
mov    -0x2c(%rbp),%eax
mov    -0x4c(%rbp),%ecx
add    $0x2,%ecx
sub    %ecx,%eax
cmp    $0x0,%eax
setge  %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    14e9 <main+0x369>
jmp    1511 <main+0x391>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    -0x4c(%rbp),%edx
add    $0x2,%edx
sub    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1494 <main+0x314>
jmp    1550 <main+0x3d0>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x21,%eax
je     154b <main+0x3cb>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
jmp    1550 <main+0x3d0>
jmp    1555 <main+0x3d5>
jmp    155a <main+0x3da>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
lea    0xce6(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1583 <main+0x403>
movl   $0x1,-0x38(%rbp)
mov    0x2a4e(%rip),%rax
movl   $0x0,(%rax)
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1776 <main+0x5f6>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
lea    0xc9a(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     176a <main+0x5ea>
mov    -0x48(%rbp),%rsi
mov    (%rsi),%rdi
call   1080 <execvp@plt>
mov    0x29fd(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x78(%rbp)
sub    $0x90,%rax
ja     1757 <main+0x5d7>
mov    -0x78(%rbp),%rax
lea    0xa08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xc0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xbae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xb98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1765 <main+0x5e5>
lea    0xb8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    176a <main+0x5ea>
movl   $0x0,-0x4(%rbp)
jmp    1870 <main+0x6f0>
movl   $0x0,-0x34(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    179c <main+0x61c>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <wait@plt>
movl   $0x0,-0x30(%rbp)
jmp    17a3 <main+0x623>
movl   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     17f5 <main+0x675>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     17ee <main+0x66e>
mov    -0x4c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%rdx
lea    0xb22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    17b4 <main+0x634>
movl   $0x0,-0x38(%rbp)
cmpl   $0x19,-0x3c(%rbp)
jge    180d <main+0x68d>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1858 <main+0x6d8>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x19,-0x4c(%rbp)
jge    1849 <main+0x6c9>
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1814 <main+0x694>
mov    -0x10(%rbp),%rax
movq   $0x0,0xc8(%rax)
jmp    1864 <main+0x6e4>
movl   $0x0,-0x1c(%rbp)
jmp    11ed <main+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    $0xc8,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %r14,%rax
add    $0x8,%rax
mov    %rax,0x48(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
mov    %rax,0x28(%rsp)
mov    %r14,0x50(%rsp)
jmp    1209 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    0x38(%rsp),%rax
mov    %r15d,%ecx
mov    %rcx,0x28(%rsp)
test   %rax,%rax
je     16aa <main+0x50a>
lea    0x10a8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
mov    $0x29,%edi
call   1070 <malloc@plt>
mov    %rbx,%rdi
mov    %rax,%rbx
lea    0x1074(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     16aa <main+0x50a>
mov    %rax,0x38(%rsp)
mov    %rbp,0x30(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
movl   $0x0,0x10(%rsp)
xor    %r8d,%r8d
movl   $0x0,0x14(%rsp)
xor    %eax,%eax
mov    %rax,0x40(%rsp)
xor    %ecx,%ecx
mov    0x18(%rsp),%rdi
mov    %rbx,0x8(%rsp)
jmp    12b2 <main+0x112>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %al,%al
je     1400 <main+0x260>
mov    %ecx,%r14d
add    $0x1,%r15
mov    %r14d,%ecx
mov    (%rdi,%r15,1),%al
cmp    $0xa,%al
je     12be <main+0x11e>
cmp    $0x20,%al
jne    12a0 <main+0x100>
mov    %r8d,0x24(%rsp)
mov    $0x29,%edi
mov    %ecx,%ebp
call   1070 <malloc@plt>
mov    %rax,%r13
movslq %ebp,%rax
cmp    %rax,%r15
jle    1370 <main+0x1d0>
mov    0x18(%rsp),%rdi
lea    0xd16(%rip),%rbx
mov    0x24(%rsp),%r8d
movslq %ebp,%r14
jmp    1321 <main+0x181>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r8d,%edx
movslq %r12d,%rax
mov    %cl,0x0(%r13,%rax,1)
add    $0x1,%r12d
mov    %r12d,%eax
mov    %edx,%r8d
add    $0x1,%r14
mov    %eax,%r12d
cmp    %r15,%r14
jge    1390 <main+0x1f0>
movzbl (%rdi,%r14,1),%ecx
lea    -0xa(%rcx),%esi
cmp    $0x1c,%sil
ja     1300 <main+0x160>
mov    $0x1,%edx
xor    %eax,%eax
movzbl %sil,%esi
movslq (%rbx,%rsi,4),%rsi
add    %rbx,%rsi
jmp    *%rsi
lea    0x1(%r14),%ebp
add    $0x1,%r12d
movslq %ebp,%rax
movl   $0x1,0x10(%rsp)
cmp    %rax,%r15
jg     12ef <main+0x14f>
add    $0x1,%r14d
movl   $0x1,0x10(%rsp)
jmp    13a0 <main+0x200>
nopl   0x0(%rax)
mov    %ebp,%r14d
mov    0x18(%rsp),%rdi
mov    0x24(%rsp),%r8d
cmpb   $0x0,0x0(%r13)
jne    13b0 <main+0x210>
jmp    12ab <main+0x10b>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %ebp,%r15d
cmovg  %r15d,%ebp
mov    %eax,%r12d
mov    %ebp,%r14d
mov    0x8(%rsp),%rbx
cmpb   $0x0,0x0(%r13)
je     12ab <main+0x10b>
mov    %r13,%rdi
lea    0xf08(%rip),%rsi
mov    $0x7,%edx
mov    %r8d,%ebp
call   1030 <strncmp@plt>
mov    %ebp,%r8d
mov    0x18(%rsp),%rdi
test   %rax,%rax
mov    $0x1,%eax
mov    0x14(%rsp),%ecx
cmove  %eax,%ecx
mov    %ecx,0x14(%rsp)
mov    0x40(%rsp),%rax
cltq
mov    %r13,(%rbx,%rax,8)
add    $0x1,%eax
mov    %rax,0x40(%rsp)
jmp    12ab <main+0x10b>
nopw   0x0(%rax,%rax,1)
mov    %r8d,%ebp
mov    0x28(%rsp),%rcx
mov    %ecx,%eax
mov    0x50(%rsp),%r14
mov    %rbx,(%r14,%rax,8)
mov    %rbx,%r12
xor    %ebx,%ebx
cmp    $0x19,%ecx
setb   %bl
lea    (%rcx,%rbx,1),%r15d
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    (%r12),%rdi
lea    0xe87(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14d0 <main+0x330>
test   %ebp,%ebp
lea    0xe73(%rip),%r12
je     14ed <main+0x34d>
mov    0x8(%rsp),%rax
mov    (%rax),%rax
movsbq 0x1(%rax),%rax
cmp    $0x21,%rax
jne    14e0 <main+0x340>
movslq %r15d,%rax
mov    -0x10(%r14,%rax,8),%rax
mov    %rax,0x8(%rsp)
mov    (%rax),%rax
cmpb   $0x21,(%rax)
jne    14ed <main+0x34d>
cmpb   $0x21,0x1(%rax)
jne    14ed <main+0x34d>
mov    0x28(%rsp),%rax
add    %ebx,%eax
add    $0xfffffffd,%eax
cs nopw 0x0(%rax,%rax,1)
nop
test   %eax,%eax
js     14ed <main+0x34d>
mov    %eax,%ecx
mov    (%r14,%rcx,8),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rcx),%rcx
cmpb   $0x21,(%rcx)
jne    14ed <main+0x34d>
add    $0xffffffff,%eax
cmpb   $0x21,0x1(%rcx)
je     14a0 <main+0x300>
jmp    14ed <main+0x34d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xdf3(%rip),%r12
jmp    14ed <main+0x34d>
nopl   0x0(%rax)
mov    -0x180(%r14,%rax,8),%rax
ff
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rbx
mov    (%rbx),%rdi
lea    0xdc6(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
mov    %rax,%rbp
mov    0x2ac8(%rip),%rax
movl   $0x0,(%rax)
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
je     15ac <main+0x40c>
cmpl   $0x0,0x10(%rsp)
jne    1534 <main+0x394>
xor    %edi,%edi
call   10b0 <wait@plt>
test   %rbp,%rbp
setne  %al
cmpl   $0x0,0x14(%rsp)
sete   %cl
test   %cl,%al
jne    157c <main+0x3dc>
cmpl   $0x0,0x30(%rsp)
js     157c <main+0x3dc>
mov    0x30(%rsp),%rax
lea    0x1(%rax),%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rax
mov    (%rax),%rdx
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1560 <main+0x3c0>
mov    0x30(%rsp),%rbp
cmp    $0x19,%ebp
jl     11f0 <main+0x50>
mov    $0xc8,%edx
mov    %r14,%rdi
mov    0x48(%rsp),%rsi
call   1090 <memmove@plt>
movq   $0x0,0xc8(%r14)
jmp    11f3 <main+0x53>
mov    (%rbx),%rdi
lea    0xd0c(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     16aa <main+0x50a>
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   10a0 <execvp@plt>
mov    0x29fd(%rip),%rax
mov    (%rax),%eax
cmp    $0x90,%rax
ja     1608 <main+0x468>
lea    0xd69(%rip),%rdi
lea    0xa81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xcd7(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xd4f(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcc7(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcc1(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcc8(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb7(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcbd(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcc8(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb2(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcbd(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcbb(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb8(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb7(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb5(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcb0(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcae(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcac(%rip),%rdi
jmp    16a5 <main+0x505>
lea    0xcaa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"osh>\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [8 x i8] c"history\00"
@stdout = global i32 0
@errno = global i32 0
@.str.22 = [16 x i8] c"command %d: %s\0A\00"
@str = [8 x i8] c"ETXTBSY\00"
@str.23 = [6 x i8] c"EPERM\00"
@str.24 = [8 x i8] c"ENOTDIR\00"
@str.25 = [8 x i8] c"ENOEXEC\00"
@str.26 = [7 x i8] c"ENOMEM\00"
@str.27 = [7 x i8] c"ENOENT\00"
@str.28 = [13 x i8] c"ENAMETOOLONG\00"
@str.29 = [7 x i8] c"ENFILE\00"
@str.30 = [7 x i8] c"EMFILE\00"
@str.31 = [6 x i8] c"ELOOP\00"
@str.32 = [8 x i8] c"ELIBBAD\00"
@str.33 = [7 x i8] c"EISDIR\00"
@str.34 = [4 x i8] c"EIO\00"
@str.35 = [7 x i8] c"EINVAL\00"
@str.36 = [7 x i8] c"EFAULT\00"
@str.37 = [7 x i8] c"EACCES\00"
@str.38 = [6 x i8] c"E2BIG\00"
@str.39 = [9 x i8] c"no error\00"
@str.40 = [14 x i8] c"unknown error\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%2 = bitcast i8* %1 to i8***
%3 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%4 = getelementptr inbounds i8**, i8*** %2, i64 25
%5 = getelementptr i8, i8* %1, i64 8
br label %6
6: ; preds = %0, %200
%7 = phi i32 [ 0, %0 ], [ %201, %200 ]
%8 = phi i32 [ 0, %0 ], [ %93, %200 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = tail call i32 @fgets(i8* %3, i32 80, i32 %10)
%12 = tail call dereferenceable_or_null(41) i8* @malloc(i32 41)
%13 = bitcast i8* %12 to i8**
%14 = tail call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %205, label %16
16: ; preds = %6, %79
%17 = phi i64 [ %86, %79 ], [ 0, %6 ]
%18 = phi i32 [ %80, %79 ], [ 0, %6 ]
%19 = phi i32 [ %81, %79 ], [ 0, %6 ]
%20 = phi i32 [ %82, %79 ], [ 0, %6 ]
%21 = phi i32 [ %83, %79 ], [ 0, %6 ]
%22 = phi i32 [ %84, %79 ], [ 0, %6 ]
%23 = phi i32 [ %85, %79 ], [ 0, %6 ]
%24 = getelementptr inbounds i8, i8* %3, i64 %17
%25 = load i8, i8* %24
switch i8 %25, label %79 [
i8 0, label %87
i8 32, label %26
i8 10, label %26
]
26: ; preds = %16, %16
%27 = tail call dereferenceable_or_null(41) i8* @malloc(i32 41)
%28 = sext i32 %23 to i64
%29 = icmp sgt i64 %17, %28
br i1 %29, label %30, label %65
30: ; preds = %26, %42
%31 = phi i32 [ %44, %42 ], [ %23, %26 ]
%32 = phi i32 [ %38, %42 ], [ %20, %26 ]
%33 = phi i32 [ 1, %42 ], [ %19, %26 ]
%34 = phi i32 [ %45, %42 ], [ %18, %26 ]
%35 = sext i32 %31 to i64
br label %36
36: ; preds = %30, %54
%37 = phi i64 [ %35, %30 ], [ %57, %54 ]
%38 = phi i32 [ %32, %30 ], [ %56, %54 ]
%39 = phi i32 [ %34, %30 ], [ %55, %54 ]
%40 = getelementptr inbounds i8, i8* %3, i64 %37
%41 = load i8, i8* %40
switch i8 %41, label %48 [
i8 32, label %54
i8 10, label %59
i8 33, label %49
i8 38, label %42
]
42: ; preds = %36
%43 = trunc i64 %37 to i32
%44 = add nsw i32 %43, 1
%45 = add nsw i32 %39, 1
%46 = sext i32 %44 to i64
%47 = icmp sgt i64 %17, %46
br i1 %47, label %30, label %65
48: ; preds = %36
br label %49
49: ; preds = %36, %48
%50 = phi i32 [ 1, %36 ], [ %38, %48 ]
%51 = sext i32 %39 to i64
%52 = getelementptr inbounds i8, i8* %27, i64 %51
store i8 %41, i8* %52
%53 = add nsw i32 %39, 1
br label %54
54: ; preds = %36, %49
%55 = phi i32 [ %53, %49 ], [ 0, %36 ]
%56 = phi i32 [ %50, %49 ], [ %38, %36 ]
%57 = add nsw i64 %37, 1
%58 = icmp slt i64 %57, %17
br i1 %58, label %36, label %61
59: ; preds = %36
%60 = trunc i64 %37 to i32
br label %65
61: ; preds = %54
%62 = add i32 %31, 1
%63 = trunc i64 %17 to i32
%64 = call i32 @llvm.smax.i32(i32 %63, i32 %62)
br label %65
65: ; preds = %42, %59, %61, %26
%66 = phi i32 [ %19, %26 ], [ %33, %59 ], [ %33, %61 ], [ 1, %42 ]
%67 = phi i32 [ %18, %26 ], [ %39, %59 ], [ %55, %61 ], [ %45, %42 ]
%68 = phi i32 [ %20, %26 ], [ %38, %59 ], [ %56, %61 ], [ %38, %42 ]
%69 = phi i32 [ %23, %26 ], [ %60, %59 ], [ %64, %61 ], [ %44, %42 ]
%70 = load i8, i8* %27
%71 = icmp eq i8 %70, 0
br i1 %71, label %79, label %72
72: ; preds = %65
%73 = tail call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%74 = icmp eq i64 %73, 0
%75 = select i1 %74, i32 1, i32 %21
%76 = sext i32 %22 to i64
%77 = getelementptr inbounds i8*, i8** %13, i64 %76
store i8* %27, i8** %77
%78 = add nsw i32 %22, 1
br label %79
79: ; preds = %16, %65, %72
%80 = phi i32 [ %67, %72 ], [ %67, %65 ], [ %18, %16 ]
%81 = phi i32 [ %66, %72 ], [ %66, %65 ], [ %19, %16 ]
%82 = phi i32 [ %68, %72 ], [ %68, %65 ], [ %20, %16 ]
%83 = phi i32 [ %75, %72 ], [ %21, %65 ], [ %21, %16 ]
%84 = phi i32 [ %78, %72 ], [ %22, %65 ], [ %22, %16 ]
%85 = phi i32 [ %69, %72 ], [ %69, %65 ], [ %23, %16 ]
%86 = add nuw i64 %17, 1
br label %16
87: ; preds = %16
%88 = zext i32 %8 to i64
%89 = getelementptr inbounds i8**, i8*** %2, i64 %88
%90 = bitcast i8*** %89 to i8**
store i8* %12, i8** %90
%91 = icmp ult i32 %8, 25
%92 = zext i1 %91 to i32
%93 = add nuw nsw i32 %8, %92
%94 = load i32, i32* @stdout
%95 = tail call i32 @fflush(i32 %94)
%96 = load i8*, i8** %13
%97 = tail call i64 @strncmp(i8* %96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%98 = icmp ne i64 %97, 0
%99 = icmp ne i32 %20, 0
%100 = select i1 %98, i1 %99, i1 false
br i1 %100, label %101, label %141
101: ; preds = %87
%102 = load i8*, i8** %13
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = load i8, i8* %103
%105 = icmp eq i8 %104, 33
br i1 %105, label %106, label %136
106: ; preds = %101
%107 = add nsw i32 %93, -2
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8**, i8*** %2, i64 %108
%110 = load i8**, i8*** %109
%111 = load i8*, i8** %110
%112 = load i8, i8* %111
%113 = icmp eq i8 %112, 33
br i1 %113, label %114, label %141
114: ; preds = %106
%115 = getelementptr inbounds i8, i8* %111, i64 1
%116 = load i8, i8* %115
%117 = icmp eq i8 %116, 33
br i1 %117, label %130, label %141
118: ; preds = %130
%119 = zext i32 %134 to i64
%120 = getelementptr inbounds i8**, i8*** %2, i64 %119
%121 = load i8**, i8*** %120
%122 = load i8*, i8** %121
%123 = load i8, i8* %122
%124 = icmp eq i8 %123, 33
br i1 %124, label %125, label %141
125: ; preds = %118
%126 = add nuw nsw i64 %132, 1
%127 = getelementptr inbounds i8, i8* %122, i64 1
%128 = load i8, i8* %127
%129 = icmp eq i8 %128, 33
br i1 %129, label %130, label %141
130: ; preds = %114, %125
%131 = phi i8** [ %121, %125 ], [ %110, %114 ]
%132 = phi i64 [ %126, %125 ], [ 1, %114 ]
%133 = trunc i64 %132 to i32
%134 = sub i32 %107, %133
%135 = icmp sgt i32 %134, -1
br i1 %135, label %118, label %141
136: ; preds = %101
%137 = sext i8 %104 to i64
%138 = add nsw i64 %137, -48
%139 = getelementptr inbounds i8**, i8*** %2, i64 %138
%140 = load i8**, i8*** %139
br label %141
141: ; preds = %130, %125, %118, %114, %106, %136, %87
%142 = phi i8** [ %140, %136 ], [ %13, %87 ], [ %110, %106 ], [ %110, %114 ], [ %121, %118 ], [ %121, %125 ], [ %131, %130 ]
%143 = load i8*, i8** %142
%144 = tail call i64 @strncmp(i8* %143, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%145 = icmp ne i64 %144, 0
store i32 0, i32* @errno
%146 = tail call i64 (...) @fork()
%147 = icmp eq i64 %146, 0
br i1 %147, label %148, label %174
148: ; preds = %141
%149 = load i8*, i8** %142
%150 = tail call i64 @strncmp(i8* %149, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%151 = icmp eq i64 %150, 0
br i1 %151, label %205, label %152
152: ; preds = %148
%153 = load i8*, i8** %142
%154 = tail call i32 @execvp(i8* %153, i8** %142)
%155 = load i32, i32* @errno
switch i32 %155, label %173 [
i32 0, label %202
i32 144, label %156
i32 143, label %157
i32 142, label %158
i32 141, label %159
i32 140, label %160
i32 139, label %161
i32 138, label %162
i32 137, label %163
i32 136, label %164
i32 134, label %165
i32 135, label %166
i32 133, label %167
i32 131, label %168
i32 132, label %169
i32 130, label %170
i32 129, label %171
i32 128, label %172
]
156: ; preds = %152
br label %202
157: ; preds = %152
br label %202
158: ; preds = %152
br label %202
159: ; preds = %152
br label %202
160: ; preds = %152
br label %202
161: ; preds = %152
br label %202
162: ; preds = %152
br label %202
163: ; preds = %152
br label %202
164: ; preds = %152
br label %202
165: ; preds = %152
br label %202
166: ; preds = %152
br label %202
167: ; preds = %152
br label %202
168: ; preds = %152
br label %202
169: ; preds = %152
br label %202
170: ; preds = %152
br label %202
171: ; preds = %152
br label %202
172: ; preds = %152
br label %202
173: ; preds = %152
br label %202
174: ; preds = %141
%175 = icmp eq i32 %19, 0
br i1 %175, label %176, label %178
176: ; preds = %174
%177 = tail call i32 @wait(i32* null)
br label %178
178: ; preds = %174, %176
%179 = icmp eq i32 %21, 0
%180 = select i1 %145, i1 %179, i1 false
%181 = icmp slt i32 %7, 0
%182 = select i1 %180, i1 true, i1 %181
br i1 %182, label %195, label %183
183: ; preds = %178
%184 = add nuw i32 %7, 1
%185 = zext i32 %184 to i64
br label %186
186: ; preds = %183, %186
%187 = phi i64 [ 0, %183 ], [ %193, %186 ]
%188 = getelementptr inbounds i8**, i8*** %2, i64 %187
%189 = load i8**, i8*** %188
%190 = load i8*, i8** %189
%191 = trunc i64 %187 to i32
%192 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.22, i64 0, i64 0), i32 %191, i8* %190)
%193 = add nuw nsw i64 %187, 1
%194 = icmp eq i64 %193, %185
br i1 %194, label %195, label %186
195: ; preds = %186, %178
%196 = icmp slt i32 %7, 25
br i1 %196, label %198, label %197
197: ; preds = %195
store i8** null, i8*** %4
br label %200
198: ; preds = %195
%199 = add nsw i32 %7, 1
br label %200
200: ; preds = %197, %198
%201 = phi i32 [ %199, %198 ], [ %7, %197 ]
br i1 %15, label %205, label %6
202: ; preds = %152, %173, %172, %171, %170, %169, %168, %167, %166, %165, %164, %163, %162, %161, %160, %159, %158, %157, %156
%203 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.38, i64 0, i64 0), %156 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.37, i64 0, i64 0), %157 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.36, i64 0, i64 0), %158 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.35, i64 0, i64 0), %159 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.34, i64 0, i64 0), %160 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.33, i64 0, i64 0), %161 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.32, i64 0, i64 0), %162 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.31, i64 0, i64 0), %163 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.30, i64 0, i64 0), %164 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.29, i64 0, i64 0), %165 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.28, i64 0, i64 0), %166 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.27, i64 0, i64 0), %167 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.26, i64 0, i64 0), %168 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.25, i64 0, i64 0), %169 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.24, i64 0, i64 0), %170 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.23, i64 0, i64 0), %171 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %172 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.40, i64 0, i64 0), %173 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.39, i64 0, i64 0), %152 ]
%204 = tail call i32 @puts(i8* dereferenceable(1) %203)
br label %205
205: ; preds = %6, %200, %202, %148
ret i32 0
}