#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 */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
unsigned char getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
char *update_buffer(char, int);
int parse_args(char **arguments) {
  unsigned int i = 0;
  unsigned char current_char = '\0';
  unsigned char previous_char = '\0';
  unsigned int arg_num = 0;
  bool has_forward_pipe = false;
  bool last_argument = false;
  char *arg_buffer = update_buffer('\0', true);
  current_char = getchar();
  if (current_char == '\n')
    return 0;
  do {
    if (current_char == '\t')
      current_char = ' ';
    if (current_char == '|') {
      if ((arg_num == 0 && i == 0) || (previous_char == current_char) ||
          (previous_char == ' ' && arg_num > 0 &&
           !strcmp(arguments[arg_num - 1], "|"))) {
        printf("error: syntax error unexpected token '|'\n");
        goto error;
      } else if (previous_char != ' ') {
        current_char = ' ';
        previous_char = '|';
        has_forward_pipe = true;
      } else
        previous_char = current_char;
    } else if (current_char == '\n') {
      current_char = ' ';
      previous_char = '\n';
      last_argument = true;
    } else
      previous_char = current_char;
    if (i == 0 && current_char == ' ') {
      if (last_argument)
        break;
      continue;
    } else {
      arg_buffer = update_buffer(current_char, false);
      if (arg_buffer == NULL) {
        printf("error: memory allocation failed\n");
        goto error;
      }
      i++;
    }
    if (current_char == ' ') {
      if (arg_num >= 1023) {
        printf("error: Only %d arguments are allowed", 1023);
        printf(" in this shell\n");
        goto error;
      }
      if (i == 0) {
        printf("error: Failure in ");
        printf(" parsing argument %d\n", arg_num + 1);
        goto error;
      }
      arg_buffer[i - 1] = '\0';
      if (arg_buffer[0] == '|') {
        arguments[arg_num] = (char *)malloc(sizeof(char) * (2));
        if (arguments[arg_num] == NULL) {
          printf("error: %s\n", strerror(errno));
          goto error;
        }
        arguments[arg_num][0] = '|';
        arguments[arg_num][1] = '\0';
        arg_num++;
        if (i > 2) {
          arguments[arg_num] = (char *)malloc(sizeof(char) * (i - 1));
          if (arguments[arg_num] == NULL) {
            printf("error: %s\n", strerror(errno));
            goto error;
          }
          strncpy(arguments[arg_num], arg_buffer + 1, i - 1);
          if (arguments[arg_num][i - 2] != '\0') {
            printf("error: Failure in ");
            printf(" parsing argument %d\n", arg_num + 1);
            goto error;
          }
          arg_num++;
        }
      } else {
        arguments[arg_num] = (char *)malloc(sizeof(char) * (i));
        if (arguments[arg_num] == NULL) {
          printf("error: %s\n", strerror(errno));
          goto error;
        }
        strncpy(arguments[arg_num], arg_buffer, i);
        if (arguments[arg_num][i - 1] != '\0') {
          printf("error: Failure in ");
          printf(" parsing argument %d\n", arg_num + 1);
          goto error;
        }
        arg_num++;
      }
      if (has_forward_pipe == true) {
        if (arg_num >= 1023) {
          printf("error: Only %d arguments are", 1023);
          printf(" allowed in this shell\n");
          goto error;
        }
        arguments[arg_num] = (char *)malloc(sizeof(char) * (2));
        if (arguments[arg_num] == NULL) {
          printf("error: %s\n", strerror(errno));
          goto error;
        }
        arguments[arg_num][0] = '|';
        arguments[arg_num][1] = '\0';
        arg_num++;
        has_forward_pipe = false;
      }
      i = 0;
      arg_buffer = update_buffer('\0', true);
    }
    if (last_argument)
      break;
  } while ((current_char = getchar()) != (unsigned char)EOF);
  if (previous_char == 255) {
    printf("error: unexpected end of file\n");
    goto error;
  }
  if (arg_num && arguments[arg_num - 1][0] == '|') {
    printf("error: command cannot end with pipe\n");
    goto error;
  }
  return arg_num;
error:
  for (i = 0; i < arg_num; i++) {
    if (arguments[i] != NULL) {
      free(arguments[i]);
      arguments[i] = NULL;
    }
  }
  if (previous_char != '\n' && previous_char != (unsigned char)EOF &&
      previous_char != 255) {
    while ((current_char = getchar()) != '\n' &&
           current_char != (unsigned char)EOF)
      ;
  }
  return -1;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <update_buffer@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    11e3 <parse_args+0x63>
movl   $0x0,-0x4(%rbp)
jmp    181a <parse_args+0x69a>
jmp    11e8 <parse_args+0x68>
movzbl -0x15(%rbp),%eax
cmp    $0x9,%eax
jne    11f9 <parse_args+0x79>
movb   $0x20,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0x7c,%eax
jne    12aa <parse_args+0x12a>
cmpl   $0x0,-0x1c(%rbp)
jne    121a <parse_args+0x9a>
cmpl   $0x0,-0x14(%rbp)
je     1266 <parse_args+0xe6>
movzbl -0x16(%rbp),%eax
movzbl -0x15(%rbp),%ecx
cmp    %ecx,%eax
je     1266 <parse_args+0xe6>
movzbl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    1279 <parse_args+0xf9>
cmpl   $0x0,-0x1c(%rbp)
jbe    1279 <parse_args+0xf9>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xda8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1279 <parse_args+0xf9>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
movzbl -0x16(%rbp),%eax
cmp    $0x20,%eax
je     129a <parse_args+0x11a>
movb   $0x20,-0x15(%rbp)
movb   $0x7c,-0x16(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    12a0 <parse_args+0x120>
mov    -0x15(%rbp),%al
mov    %al,-0x16(%rbp)
jmp    12a5 <parse_args+0x125>
jmp    12d6 <parse_args+0x156>
movzbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    12cb <parse_args+0x14b>
movb   $0x20,-0x15(%rbp)
movb   $0xa,-0x16(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    12d1 <parse_args+0x151>
mov    -0x15(%rbp),%al
mov    %al,-0x16(%rbp)
jmp    12d6 <parse_args+0x156>
cmpl   $0x0,-0x14(%rbp)
jne    1301 <parse_args+0x181>
movzbl -0x15(%rbp),%eax
cmp    $0x20,%eax
jne    1301 <parse_args+0x181>
cmpl   $0x0,-0x24(%rbp)
je     12fc <parse_args+0x17c>
jmp    16ce <parse_args+0x54e>
jmp    16ac <parse_args+0x52c>
xor    %esi,%esi
movsbl -0x15(%rbp),%edi
call   1090 <update_buffer@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    132e <parse_args+0x1ae>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0x20,%eax
jne    1698 <parse_args+0x518>
cmpl   $0x3ff,-0x1c(%rbp)
jb     1377 <parse_args+0x1f7>
lea    0xcf5(%rip),%rdi
mov    $0x3ff,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
cmpl   $0x0,-0x14(%rbp)
jne    13a8 <parse_args+0x228>
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x30(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
jne    1510 <parse_args+0x390>
mov    $0x2,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    1416 <parse_args+0x296>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movb   $0x7c,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movb   $0x0,0x1(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x14(%rbp)
jbe    150b <parse_args+0x38b>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    149d <parse_args+0x31d>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xc0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1040 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1502 <parse_args+0x382>
lea    0xb90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    15c9 <parse_args+0x449>
mov    -0x14(%rbp),%eax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    1562 <parse_args+0x3e2>
mov    0x2a93(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xb45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     15c0 <parse_args+0x440>
lea    0xad2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xad1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    1681 <parse_args+0x501>
cmpl   $0x3ff,-0x1c(%rbp)
jb     1606 <parse_args+0x486>
lea    0xabf(%rip),%rdi
mov    $0x3ff,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xac9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    $0x2,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    1654 <parse_args+0x4d4>
mov    0x29a1(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xa53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movb   $0x7c,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movb   $0x0,0x1(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <update_buffer@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     16a7 <parse_args+0x527>
jmp    16ce <parse_args+0x54e>
jmp    16ac <parse_args+0x52c>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x15(%rbp)
movzbl %al,%eax
mov    0x2928(%rip),%rcx
mov    (%rcx),%rcx
movzbl %cl,%ecx
cmp    %ecx,%eax
jne    11e8 <parse_args+0x68>
movzbl -0x16(%rbp),%eax
cmp    $0xff,%eax
jne    16f0 <parse_args+0x570>
lea    0x9f7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
cmpl   $0x0,-0x1c(%rbp)
je     1729 <parse_args+0x5a9>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
jne    1729 <parse_args+0x5a9>
lea    0x9dd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1734 <parse_args+0x5b4>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    181a <parse_args+0x69a>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    178b <parse_args+0x60b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
je     1778 <parse_args+0x5f8>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movq   $0x0,(%rax,%rcx,8)
jmp    177d <parse_args+0x5fd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    173b <parse_args+0x5bb>
movzbl -0x16(%rbp),%eax
cmp    $0xa,%eax
je     1813 <parse_args+0x693>
movzbl -0x16(%rbp),%eax
mov    0x2845(%rip),%rcx
mov    (%rcx),%rcx
movzbl %cl,%ecx
cmp    %ecx,%eax
je     1813 <parse_args+0x693>
movzbl -0x16(%rbp),%eax
cmp    $0xff,%eax
je     1813 <parse_args+0x693>
jmp    17c5 <parse_args+0x645>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x15(%rbp)
movzbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x31(%rbp)
je     17f9 <parse_args+0x679>
movzbl -0x15(%rbp),%eax
mov    0x27fd(%rip),%rcx
mov    (%rcx),%rcx
movzbl %cl,%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1809 <parse_args+0x689>
jmp    180e <parse_args+0x68e>
jmp    17c5 <parse_args+0x645>
jmp    1813 <parse_args+0x693>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <update_buffer@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
je     15a1 <parse_args+0x411>
mov    %rbx,0x10(%rsp)
mov    0x2e1d(%rip),%r12
xor    %r13d,%r13d
xor    %r15d,%r15d
xor    %r14d,%r14d
movl   $0x0,0x18(%rsp)
jmp    1218 <parse_args+0x88>
xchg   %ax,%ax
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <update_buffer@plt>
mov    %ebx,%r14d
movl   $0x0,0x18(%rsp)
cmpb   $0x0,0x1c(%rsp)
je     14b4 <parse_args+0x324>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %ebp,%r13d
cmp    (%r12),%al
je     14b4 <parse_args+0x324>
mov    %r15d,%ebx
cmp    $0x9,%al
movzbl %al,%r15d
mov    $0x20,%eax
cmove  %eax,%r15d
cmp    $0xa,%r15b
je     12b0 <parse_args+0x120>
cmp    $0x7c,%r15b
jne    12f0 <parse_args+0x160>
mov    %r14d,%eax
or     %r13d,%eax
sete   %al
cmp    $0x7c,%bl
je     14ed <parse_args+0x35d>
test   %al,%al
jne    14ed <parse_args+0x35d>
cmp    $0x20,%bl
jne    1283 <parse_args+0xf3>
test   %r14d,%r14d
je     1283 <parse_args+0xf3>
lea    -0x1(%r14),%eax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
lea    0xd8a(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     14ed <parse_args+0x35d>
cmp    $0x20,%bl
mov    $0x20,%ebx
mov    $0x7c,%eax
cmove  %eax,%ebx
mov    $0x1,%eax
mov    0x18(%rsp),%ecx
cmovne %eax,%ecx
mov    %ecx,0x18(%rsp)
test   %r13d,%r13d
je     12f8 <parse_args+0x168>
jmp    1303 <parse_args+0x173>
nopw   0x0(%rax,%rax,1)
test   %r13d,%r13d
je     15d3 <parse_args+0x443>
mov    %r15d,0xc(%rsp)
mov    %r14,%r15
mov    $0x20,%edi
xor    %esi,%esi
call   10a0 <update_buffer@plt>
test   %rax,%rax
je     14d1 <parse_args+0x341>
mov    %rax,%r14
lea    0x1(%r13),%ebp
xor    %ebx,%ebx
cmp    $0x3ff,%r15d
jb     133d <parse_args+0x1ad>
jmp    14fb <parse_args+0x36b>
nopl   (%rax)
mov    %r15d,%ebx
test   %r13d,%r13d
jne    1303 <parse_args+0x173>
xor    %ebp,%ebp
cmp    $0x20,%bl
je     1204 <parse_args+0x74>
mov    %r15d,0xc(%rsp)
mov    %r14,%r15
movsbl %bl,%edi
xor    %esi,%esi
call   10a0 <update_buffer@plt>
test   %rax,%rax
je     14d1 <parse_args+0x341>
lea    0x1(%r13),%ebp
cmp    $0x20,%bl
jne    145a <parse_args+0x2ca>
mov    %rax,%r14
mov    $0x1,%bl
cmp    $0x3ff,%r15d
jae    14fb <parse_args+0x36b>
test   %ebp,%ebp
je     1529 <parse_args+0x399>
mov    %r13d,%r12d
movb   $0x0,(%r14,%r12,1)
cmpb   $0x7c,(%r14)
mov    %ebx,0x1c(%rsp)
jne    1410 <parse_args+0x280>
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %r15d,%ecx
mov    0x10(%rsp),%rdx
mov    %rax,(%rdx,%rcx,8)
test   %rax,%rax
mov    0x2c6d(%rip),%r12
je     1604 <parse_args+0x474>
movb   $0x7c,(%rax)
mov    (%rdx,%rcx,8),%rax
movb   $0x0,0x1(%rax)
mov    %r15,0x20(%rsp)
lea    0x1(%r15),%ebx
cmp    $0x3,%ebp
jb     1467 <parse_args+0x2d7>
mov    %r13d,%edi
mov    %rdx,%r15
call   1090 <malloc@plt>
mov    %ebx,%ebp
mov    %r15,%r12
mov    %rax,(%r15,%rbp,8)
test   %rax,%rax
je     16eb <parse_args+0x55b>
add    $0x1,%r14
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1040 <strncpy@plt>
mov    (%r12,%rbp,8),%rax
add    $0xffffffff,%r13d
cmpb   $0x0,(%rax,%r13,1)
jne    1712 <parse_args+0x582>
mov    0x20(%rsp),%rax
add    $0x2,%eax
mov    %eax,%ebx
mov    0x10(%rsp),%r13
mov    0xc(%rsp),%r15d
mov    0x2bed(%rip),%r12
cmpl   $0x1,0x18(%rsp)
jne    11e0 <parse_args+0x50>
jmp    147a <parse_args+0x2ea>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %r15d,%ebx
mov    0x10(%rsp),%r13
mov    %rax,0x0(%r13,%rbx,8)
test   %rax,%rax
je     1634 <parse_args+0x4a4>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
mov    0x0(%r13,%rbx,8),%rax
cmpb   $0x0,(%rax,%r12,1)
jne    1668 <parse_args+0x4d8>
add    $0x1,%r15d
mov    %r15d,%ebx
mov    0x2b90(%rip),%r12
jmp    146a <parse_args+0x2da>
mov    %r15,%r14
mov    0xc(%rsp),%r15d
jmp    1204 <parse_args+0x74>
mov    %rdx,%r13
mov    0xc(%rsp),%r15d
cmpl   $0x1,0x18(%rsp)
jne    11e0 <parse_args+0x50>
cmp    $0x3ff,%ebx
jae    169d <parse_args+0x50d>
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %ebx,%ecx
mov    %rax,0x0(%r13,%rcx,8)
test   %rax,%rax
je     16c4 <parse_args+0x534>
movb   $0x7c,(%rax)
mov    0x0(%r13,%rcx,8),%rax
movb   $0x0,0x1(%rax)
add    $0x1,%ebx
jmp    11e0 <parse_args+0x50>
cmp    $0xff,%r15b
jne    15d6 <parse_args+0x446>
lea    0xbd7(%rip),%rdi
call   1050 <puts@plt>
mov    $0xff,%bl
jmp    1552 <parse_args+0x3c2>
lea    0xbf9(%rip),%rdi
call   1050 <puts@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    0x10(%rsp),%r13
mov    %r15,%r14
jmp    1557 <parse_args+0x3c7>
lea    0xbfd(%rip),%rdi
call   1050 <puts@plt>
jmp    1552 <parse_args+0x3c2>
lea    0xb00(%rip),%rdi
mov    $0x3ff,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xbad(%rip),%rdi
call   1050 <puts@plt>
mov    0x10(%rsp),%r13
mov    %r15,%r14
mov    0xc(%rsp),%r15d
jmp    155f <parse_args+0x3cf>
lea    0xaf7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%r14
lea    0x1(%r15),%esi
lea    0xaf5(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    0x10(%rsp),%r13
mov    %ebx,%r15d
test   %r14d,%r14d
je     1596 <parse_args+0x406>
mov    %r14d,%ebx
xor    %ebp,%ebp
jmp    1579 <parse_args+0x3e9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1593 <parse_args+0x403>
mov    0x0(%r13,%rbp,8),%rdi
test   %rdi,%rdi
je     1570 <parse_args+0x3e0>
call   1030 <free@plt>
movq   $0x0,0x0(%r13,%rbp,8)
jmp    1570 <parse_args+0x3e0>
mov    %r15d,%ebx
mov    $0xffffffff,%r14d
cmp    $0xa,%bl
jne    15b3 <parse_args+0x423>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0xff,%bl
je     15a1 <parse_args+0x411>
cmp    (%r12),%bl
je     15a1 <parse_args+0x411>
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
je     15a1 <parse_args+0x411>
cmp    (%r12),%al
jne    15c0 <parse_args+0x430>
jmp    15a1 <parse_args+0x411>
mov    $0xa,%r15b
mov    0x10(%rsp),%r13
test   %r14d,%r14d
je     15ff <parse_args+0x46f>
lea    -0x1(%r14),%eax
mov    0x0(%r13,%rax,8),%rax
cmpb   $0x7c,(%rax)
jne    15a1 <parse_args+0x411>
lea    0xa83(%rip),%rdi
call   1050 <puts@plt>
jmp    155f <parse_args+0x3cf>
xor    %r14d,%r14d
jmp    15a1 <parse_args+0x411>
mov    0x29cd(%rip),%rax
mov    (%rax),%edi
mov    %rdx,%r13
call   10b0 <strerror@plt>
lea    0xa34(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    %r15,%r14
jmp    1557 <parse_args+0x3c7>
mov    0x299d(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xa07(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    0x2988(%rip),%r12
mov    %r15,%r14
jmp    1557 <parse_args+0x3c7>
lea    0x9b8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%r14
lea    0x1(%r15),%esi
lea    0x9b6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    0x2950(%rip),%r12
jmp    1557 <parse_args+0x3c7>
lea    0x9b7(%rip),%rdi
mov    $0x3ff,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xa03(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,%r14d
jmp    155f <parse_args+0x3cf>
mov    0x290d(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0x977(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%r14d
jmp    155f <parse_args+0x3cf>
mov    0x28e6(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0x950(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%r14d
mov    %r12,%r13
jmp    173e <parse_args+0x5ae>
lea    0x90e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%rsi
add    $0x2,%esi
lea    0x90b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%r14d
mov    0x10(%rsp),%r13
mov    0xc(%rsp),%r15d
mov    0x289e(%rip),%r12
jmp    155f <parse_args+0x3cf>

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

LLVM IR (-O2):
@.str = [2 x i8] c"|\00"
@.str.3 = [37 x i8] c"error: Only %d arguments are allowed\00"
@.str.5 = [19 x i8] c"error: Failure in \00"
@.str.6 = [22 x i8] c" parsing argument %d\0A\00"
@.str.7 = [11 x i8] c"error: %s\0A\00"
@errno = global i32 0
@.str.8 = [29 x i8] c"error: Only %d arguments are\00"
@EOF = global i64 0
@str = [36 x i8] c"error: command cannot end with pipe\00"
@str.12 = [30 x i8] c"error: unexpected end of file\00"
@str.13 = [23 x i8] c" allowed in this shell\00"
@str.14 = [15 x i8] c" in this shell\00"
@str.15 = [32 x i8] c"error: memory allocation failed\00"
@str.16 = [41 x i8] c"error: syntax error unexpected token '|'\00"
define i32 @parse_args(i8** nocapture %0) {
%2 = tail call i8* @update_buffer(i8 signext 0, i32 1)
%3 = tail call zeroext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %222, label %5
5: ; preds = %1, %162
%6 = phi i32 [ %163, %162 ], [ 0, %1 ]
%7 = phi i8 [ %166, %162 ], [ %3, %1 ]
%8 = phi i8 [ %12, %162 ], [ 0, %1 ]
%9 = phi i32 [ %164, %162 ], [ 0, %1 ]
%10 = phi i32 [ %165, %162 ], [ 0, %1 ]
%11 = icmp eq i8 %7, 9
%12 = select i1 %11, i8 32, i8 %7
switch i8 %12, label %35 [
i8 124, label %13
i8 10, label %41
]
13: ; preds = %5
%14 = icmp eq i32 %9, 0
%15 = icmp eq i32 %6, 0
%16 = select i1 %14, i1 %15, i1 false
%17 = icmp eq i8 %8, 124
%18 = or i1 %17, %16
br i1 %18, label %30, label %19
19: ; preds = %13
%20 = icmp eq i8 %8, 32
%21 = icmp ne i32 %9, 0
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = add i32 %9, -1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %0, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %27, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %13, %23
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.16, i64 0, i64 0))
br label %188
32: ; preds = %23, %19
%33 = select i1 %20, i8 124, i8 32
%34 = select i1 %20, i32 %10, i32 1
br label %35
35: ; preds = %5, %32
%36 = phi i8 [ %33, %32 ], [ %12, %5 ]
%37 = phi i32 [ %34, %32 ], [ %10, %5 ]
%38 = icmp eq i32 %6, 0
%39 = icmp eq i8 %36, 32
%40 = and i1 %38, %39
br i1 %40, label %162, label %43
41: ; preds = %5
%42 = icmp eq i32 %6, 0
br i1 %42, label %175, label %46
43: ; preds = %35
%44 = tail call i8* @update_buffer(i8 signext %36, i32 0)
%45 = icmp eq i8* %44, null
br i1 %45, label %51, label %53
46: ; preds = %41
%47 = tail call i8* @update_buffer(i8 signext 32, i32 0)
%48 = icmp eq i8* %47, null
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = add i32 %6, 1
br label %55
51: ; preds = %46, %43
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.15, i64 0, i64 0))
br label %188
53: ; preds = %43
%54 = add i32 %6, 1
br i1 %39, label %55, label %162
55: ; preds = %49, %53
%56 = phi i32 [ %50, %49 ], [ %54, %53 ]
%57 = phi i1 [ false, %49 ], [ true, %53 ]
%58 = phi i32 [ %10, %49 ], [ %37, %53 ]
%59 = phi i8* [ %47, %49 ], [ %44, %53 ]
%60 = icmp ugt i32 %9, 1022
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 1023)
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
br label %192
64: ; preds = %55
%65 = icmp eq i32 %56, 0
br i1 %65, label %66, label %70
66: ; preds = %64
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%68 = add nuw nsw i32 %9, 1
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %68)
br label %188
70: ; preds = %64
%71 = zext i32 %6 to i64
%72 = getelementptr inbounds i8, i8* %59, i64 %71
store i8 0, i8* %72
%73 = load i8, i8* %59
%74 = icmp eq i8 %73, 124
br i1 %74, label %75, label %115
75: ; preds = %70
%76 = tail call i64 @malloc(i32 2)
%77 = inttoptr i64 %76 to i8*
%78 = zext i32 %9 to i64
%79 = getelementptr inbounds i8*, i8** %0, i64 %78
store i8* %77, i8** %79
%80 = icmp eq i64 %76, 0
br i1 %80, label %81, label %85
81: ; preds = %75
%82 = load i32, i32* @errno
%83 = tail call i8* @strerror(i32 %82)
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %83)
br label %188
85: ; preds = %75
store i8 124, i8* %77
%86 = load i8*, i8** %79
%87 = getelementptr inbounds i8, i8* %86, i64 1
store i8 0, i8* %87
%88 = add nuw nsw i32 %9, 1
%89 = icmp ugt i32 %56, 2
br i1 %89, label %90, label %137
90: ; preds = %85
%91 = tail call i64 @malloc(i32 %6)
%92 = inttoptr i64 %91 to i8*
%93 = zext i32 %88 to i64
%94 = getelementptr inbounds i8*, i8** %0, i64 %93
store i8* %92, i8** %94
%95 = icmp eq i64 %91, 0
br i1 %95, label %96, label %100
96: ; preds = %90
%97 = load i32, i32* @errno
%98 = tail call i8* @strerror(i32 %97)
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %98)
br label %192
100: ; preds = %90
%101 = getelementptr inbounds i8, i8* %59, i64 1
%102 = tail call i32 @strncpy(i8* %92, i8* %101, i32 %6)
%103 = load i8*, i8** %94
%104 = add i32 %6, -1
%105 = zext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %103, i64 %105
%107 = load i8, i8* %106
%108 = icmp eq i8 %107, 0
br i1 %108, label %113, label %109
109: ; preds = %100
%110 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%111 = add nuw nsw i32 %9, 2
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %111)
br label %192
113: ; preds = %100
%114 = add nuw nsw i32 %9, 2
br label %137
115: ; preds = %70
%116 = tail call i64 @malloc(i32 %56)
%117 = inttoptr i64 %116 to i8*
%118 = zext i32 %9 to i64
%119 = getelementptr inbounds i8*, i8** %0, i64 %118
store i8* %117, i8** %119
%120 = icmp eq i64 %116, 0
br i1 %120, label %121, label %125
121: ; preds = %115
%122 = load i32, i32* @errno
%123 = tail call i8* @strerror(i32 %122)
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %123)
br label %188
125: ; preds = %115
%126 = tail call i32 @strncpy(i8* %117, i8* %59, i32 %56)
%127 = load i8*, i8** %119
%128 = getelementptr inbounds i8, i8* %127, i64 %71
%129 = load i8, i8* %128
%130 = icmp eq i8 %129, 0
br i1 %130, label %135, label %131
131: ; preds = %125
%132 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%133 = add nuw nsw i32 %9, 1
%134 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %133)
br label %188
135: ; preds = %125
%136 = add nuw nsw i32 %9, 1
br label %137
137: ; preds = %85, %113, %135
%138 = phi i32 [ %114, %113 ], [ %88, %85 ], [ %136, %135 ]
%139 = icmp eq i32 %58, 1
br i1 %139, label %140, label %159
140: ; preds = %137
%141 = icmp ugt i32 %138, 1022
br i1 %141, label %142, label %145
142: ; preds = %140
%143 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 1023)
%144 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
br label %192
145: ; preds = %140
%146 = tail call i64 @malloc(i32 2)
%147 = inttoptr i64 %146 to i8*
%148 = zext i32 %138 to i64
%149 = getelementptr inbounds i8*, i8** %0, i64 %148
store i8* %147, i8** %149
%150 = icmp eq i64 %146, 0
br i1 %150, label %151, label %155
151: ; preds = %145
%152 = load i32, i32* @errno
%153 = tail call i8* @strerror(i32 %152)
%154 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %153)
br label %192
155: ; preds = %145
store i8 124, i8* %147
%156 = load i8*, i8** %149
%157 = getelementptr inbounds i8, i8* %156, i64 1
store i8 0, i8* %157
%158 = add nuw nsw i32 %138, 1
br label %159
159: ; preds = %137, %155
%160 = phi i32 [ %158, %155 ], [ %138, %137 ]
%161 = tail call i8* @update_buffer(i8 signext 0, i32 1)
br i1 %57, label %162, label %170
162: ; preds = %53, %35, %159
%163 = phi i32 [ 0, %159 ], [ 0, %35 ], [ %54, %53 ]
%164 = phi i32 [ %160, %159 ], [ %9, %35 ], [ %9, %53 ]
%165 = phi i32 [ 0, %159 ], [ %37, %35 ], [ %37, %53 ]
%166 = tail call zeroext i8 (...) @getchar()
%167 = load i64, i64* @EOF
%168 = trunc i64 %167 to i8
%169 = icmp eq i8 %166, %168
br i1 %169, label %170, label %5
170: ; preds = %159, %162
%171 = phi i32 [ %164, %162 ], [ %160, %159 ]
%172 = icmp eq i8 %12, -1
br i1 %172, label %173, label %175
173: ; preds = %170
%174 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
br label %188
175: ; preds = %41, %170
%176 = phi i32 [ %171, %170 ], [ %9, %41 ]
%177 = phi i8 [ %12, %170 ], [ 10, %41 ]
%178 = icmp eq i32 %176, 0
br i1 %178, label %222, label %179
179: ; preds = %175
%180 = add i32 %176, -1
%181 = zext i32 %180 to i64
%182 = getelementptr inbounds i8*, i8** %0, i64 %181
%183 = load i8*, i8** %182
%184 = load i8, i8* %183
%185 = icmp eq i8 %184, 124
br i1 %185, label %186, label %222
186: ; preds = %179
%187 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %192
188: ; preds = %173, %131, %121, %81, %66, %51, %30
%189 = phi i8 [ %8, %30 ], [ -1, %173 ], [ %12, %51 ], [ %12, %66 ], [ %12, %81 ], [ %12, %121 ], [ %12, %131 ]
%190 = phi i32 [ %9, %30 ], [ %171, %173 ], [ %9, %51 ], [ %9, %66 ], [ %9, %81 ], [ %9, %121 ], [ %9, %131 ]
%191 = icmp eq i32 %190, 0
br i1 %191, label %206, label %192
192: ; preds = %151, %142, %109, %96, %61, %186, %188
%193 = phi i32 [ %190, %188 ], [ %138, %151 ], [ %138, %142 ], [ %88, %109 ], [ %88, %96 ], [ %9, %61 ], [ %176, %186 ]
%194 = phi i8 [ %189, %188 ], [ %12, %151 ], [ %12, %142 ], [ %12, %109 ], [ %12, %96 ], [ %12, %61 ], [ %177, %186 ]
%195 = zext i32 %193 to i64
br label %196
196: ; preds = %192, %203
%197 = phi i64 [ 0, %192 ], [ %204, %203 ]
%198 = getelementptr inbounds i8*, i8** %0, i64 %197
%199 = load i8*, i8** %198
%200 = icmp eq i8* %199, null
br i1 %200, label %203, label %201
201: ; preds = %196
%202 = tail call i32 @free(i8* %199)
store i8* null, i8** %198
br label %203
203: ; preds = %196, %201
%204 = add nuw nsw i64 %197, 1
%205 = icmp eq i64 %204, %195
br i1 %205, label %206, label %196
206: ; preds = %203, %188
%207 = phi i8 [ %189, %188 ], [ %194, %203 ]
%208 = icmp eq i8 %207, 10
br i1 %208, label %222, label %209
209: ; preds = %206
%210 = load i64, i64* @EOF
%211 = trunc i64 %210 to i8
%212 = icmp ne i8 %207, %211
%213 = icmp ne i8 %207, -1
%214 = and i1 %213, %212
br i1 %214, label %215, label %222
215: ; preds = %209, %215
%216 = tail call zeroext i8 (...) @getchar()
%217 = icmp ne i8 %216, 10
%218 = load i64, i64* @EOF
%219 = trunc i64 %218 to i8
%220 = icmp ne i8 %216, %219
%221 = select i1 %217, i1 %220, i1 false
br i1 %221, label %215, label %222
222: ; preds = %215, %206, %209, %175, %179, %1
%223 = phi i32 [ 0, %1 ], [ %176, %179 ], [ 0, %175 ], [ -1, %209 ], [ -1, %206 ], [ -1, %215 ]
ret i32 %223
}