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

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ wordexp_t;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ WNOHANG;
int WRDE_NOSPACE;
int WRDE_SHOWERR;
int WRDE_SYNTAX;
char *alloca(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exec_comm_child(char *, int *, int, int);
scalar_t__ fork();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
scalar_t__ pipe(int *);
int read(int, char *, int);
int /*<<< orphan*/ *strchr(char const *, char);
char *w_addchar(char *, size_t *, size_t *, char);
char *w_addmem(char *, size_t *, size_t *, char *, int);
int w_addword(int /*<<< orphan*/ *, char *);
char *w_newword(size_t *, size_t *);
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int exec_comm(char *comm, char **word, size_t *word_length, size_t *max_length,
              int flags, wordexp_t *pwordexp, const char *ifs,
              const char *ifs_white) {
  int fildes[2];
  int bufsize = 128;
  int buflen;
  int i;
  int status = 0;
  size_t maxnewlines = 0;
  char *buffer;
  pid_t pid;
  if (!comm || !*comm)
    return 0;
  if (pipe(fildes))
    return WRDE_NOSPACE;
  if ((pid = fork()) < 0) {
    close(fildes[0]);
    close(fildes[1]);
    return WRDE_NOSPACE;
  }
  if (pid == 0)
    exec_comm_child(comm, fildes, (flags & WRDE_SHOWERR), 0);
  close(fildes[1]);
  buffer = alloca(bufsize);
  if (!pwordexp) {
    while (1) {
      if ((buflen = read(fildes[0], buffer, bufsize)) < 1) {
        if (waitpid(pid, &status, WNOHANG) == 0)
          continue;
        if ((buflen = read(fildes[0], buffer, bufsize)) < 1)
          break;
      }
      maxnewlines += buflen;
      *word = w_addmem(*word, word_length, max_length, buffer, buflen);
      if (*word == NULL)
        goto no_space;
    }
  } else {
    int copying = 0;
    while (1) {
      if ((buflen = read(fildes[0], buffer, bufsize)) < 1) {
        if (waitpid(pid, &status, WNOHANG) == 0)
          continue;
        if ((buflen = read(fildes[0], buffer, bufsize)) < 1)
          break;
      }
      for (i = 0; i < buflen; ++i) {
        if (strchr(ifs, buffer[i]) != NULL) {
          if (strchr(ifs_white, buffer[i]) == NULL) {
            if (copying == 2) {
              copying = 0;
              continue;
            }
            copying = 0;
          } else {
            if (buffer[i] == '\n') {
              if (copying == 1)
                copying = 3;
              continue;
            } else {
              if (copying != 1 && copying != 3)
                continue;
              copying = 2;
            }
          }
          if (w_addword(pwordexp, *word) == WRDE_NOSPACE)
            goto no_space;
          *word = w_newword(word_length, max_length);
          maxnewlines = 0;
        } else {
          if (copying == 3) {
            if (w_addword(pwordexp, *word) == WRDE_NOSPACE)
              goto no_space;
            *word = w_newword(word_length, max_length);
          }
          copying = 1;
          if (buffer[i] == '\n')
            maxnewlines++;
          else
            maxnewlines = 0;
          *word = w_addchar(*word, word_length, max_length, buffer[i]);
          if (*word == NULL)
            goto no_space;
        }
      }
    }
  }
  while (maxnewlines-- != 0 && *word_length > 0 &&
         (*word)[*word_length - 1] == '\n') {
    (*word)[--*word_length] = '\0';
    if (*word_length == 0) {
      free(*word);
      *word = w_newword(word_length, max_length);
      break;
    }
  }
  close(fildes[0]);
  if (buflen < 1 && status != 0) {
    if ((pid = fork()) < 0) {
      return WRDE_NOSPACE;
    }
    if (pid == 0) {
      fildes[0] = fildes[1] = -1;
      exec_comm_child(comm, fildes, 0, 1);
    }
    if (waitpid(pid, &status, 0) == pid && status != 0)
      return WRDE_SYNTAX;
  }
  return 0;
no_space:
  kill(pid, SIGKILL);
  waitpid(pid, NULL, 0);
  close(fildes[0]);
  return WRDE_NOSPACE;
}


x86 assembly (clang, -O0):
<exec_comm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x80,-0x44(%rbp)
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1236 <exec_comm+0x56>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1242 <exec_comm+0x62>
movl   $0x0,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
lea    -0x40(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0x0,%rax
je     1266 <exec_comm+0x86>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jge    129c <exec_comm+0xbc>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
cmpq   $0x0,-0x68(%rbp)
jne    12c2 <exec_comm+0xe2>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    0x2d2f(%rip),%rax
and    (%rax),%edx
xor    %ecx,%ecx
call   10a0 <exec_comm_child@plt>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    -0x44(%rbp),%edi
call   10b0 <alloca@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    139a <exec_comm+0x1ba>
jmp    12e6 <exec_comm+0x106>
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x1,%eax
jge    134b <exec_comm+0x16b>
mov    -0x68(%rbp),%rdi
mov    0x2ccc(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rsi
call   10e0 <waitpid@plt>
cmp    $0x0,%rax
jne    1326 <exec_comm+0x146>
jmp    12e6 <exec_comm+0x106>
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x1,%eax
jge    1346 <exec_comm+0x166>
jmp    1395 <exec_comm+0x1b5>
jmp    134b <exec_comm+0x16b>
movslq -0x48(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x48(%rbp),%r8d
call   1030 <w_addmem@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1390 <exec_comm+0x1b0>
jmp    175b <exec_comm+0x57b>
jmp    12e6 <exec_comm+0x106>
jmp    15ea <exec_comm+0x40a>
movl   $0x0,-0x6c(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x1,%eax
jge    1406 <exec_comm+0x226>
mov    -0x68(%rbp),%rdi
mov    0x2c11(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rsi
call   10e0 <waitpid@plt>
cmp    $0x0,%rax
jne    13e1 <exec_comm+0x201>
jmp    13a1 <exec_comm+0x1c1>
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x1,%eax
jge    1401 <exec_comm+0x221>
jmp    15e5 <exec_comm+0x405>
jmp    1406 <exec_comm+0x226>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    15e0 <exec_comm+0x400>
mov    0x10(%rbp),%rdi
mov    -0x60(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1511 <exec_comm+0x331>
mov    0x18(%rbp),%rdi
mov    -0x60(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
jne    1479 <exec_comm+0x299>
cmpl   $0x2,-0x6c(%rbp)
jne    146d <exec_comm+0x28d>
movl   $0x0,-0x6c(%rbp)
jmp    15d2 <exec_comm+0x3f2>
movl   $0x0,-0x6c(%rbp)
jmp    14c9 <exec_comm+0x2e9>
mov    -0x60(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    14a4 <exec_comm+0x2c4>
cmpl   $0x1,-0x6c(%rbp)
jne    149f <exec_comm+0x2bf>
movl   $0x3,-0x6c(%rbp)
jmp    15d2 <exec_comm+0x3f2>
cmpl   $0x1,-0x6c(%rbp)
je     14bd <exec_comm+0x2dd>
cmpl   $0x3,-0x6c(%rbp)
je     14bd <exec_comm+0x2dd>
jmp    15d2 <exec_comm+0x3f2>
movl   $0x2,-0x6c(%rbp)
jmp    14c9 <exec_comm+0x2e9>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   10f0 <w_addword@plt>
mov    0x2af0(%rip),%rcx
cmp    (%rcx),%eax
jne    14ed <exec_comm+0x30d>
jmp    175b <exec_comm+0x57b>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10d0 <w_newword@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x58(%rbp)
jmp    15cd <exec_comm+0x3ed>
cmpl   $0x3,-0x6c(%rbp)
jne    1556 <exec_comm+0x376>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   10f0 <w_addword@plt>
mov    0x2a9e(%rip),%rcx
cmp    (%rcx),%eax
jne    153f <exec_comm+0x35f>
jmp    175b <exec_comm+0x57b>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10d0 <w_newword@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1583 <exec_comm+0x3a3>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    158b <exec_comm+0x3ab>
movq   $0x0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x60(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
call   1050 <w_addchar@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    15c8 <exec_comm+0x3e8>
jmp    175b <exec_comm+0x57b>
jmp    15cd <exec_comm+0x3ed>
jmp    15d2 <exec_comm+0x3f2>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    140d <exec_comm+0x22d>
jmp    13a1 <exec_comm+0x1c1>
jmp    15ea <exec_comm+0x40a>
jmp    15ef <exec_comm+0x40f>
mov    -0x58(%rbp),%rcx
mov    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x6d(%rbp)
je     163f <exec_comm+0x45f>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x6d(%rbp)
jbe    163f <exec_comm+0x45f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x6d(%rbp)
mov    -0x6d(%rbp),%al
test   $0x1,%al
jne    164f <exec_comm+0x46f>
jmp    16a7 <exec_comm+0x4c7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rdx
mov    (%rdx),%rcx
mov    %rcx,%rsi
add    $0xffffffffffffffff,%rsi
mov    %rsi,(%rdx)
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    16a2 <exec_comm+0x4c2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10d0 <w_newword@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    16a7 <exec_comm+0x4c7>
jmp    15ef <exec_comm+0x40f>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x1,-0x48(%rbp)
jge    174f <exec_comm+0x56f>
cmpl   $0x0,-0x50(%rbp)
je     174f <exec_comm+0x56f>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jge    16e9 <exec_comm+0x509>
mov    0x28f1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
cmpq   $0x0,-0x68(%rbp)
jne    1716 <exec_comm+0x536>
movl   $0xffffffff,-0x3c(%rbp)
movl   $0xffffffff,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   10a0 <exec_comm_child@plt>
mov    -0x68(%rbp),%rdi
lea    -0x50(%rbp),%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
cmp    -0x68(%rbp),%rax
jne    174a <exec_comm+0x56a>
cmpl   $0x0,-0x50(%rbp)
je     174a <exec_comm+0x56a>
mov    0x28a0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
jmp    174f <exec_comm+0x56f>
movl   $0x0,-0x4(%rbp)
jmp    1790 <exec_comm+0x5b0>
mov    -0x68(%rbp),%rdi
mov    0x285a(%rip),%rax
mov    (%rax),%esi
call   10c0 <kill@plt>
mov    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    0x2845(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_comm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movl   $0x0,0xc(%rsp)
xor    %ebp,%ebp
test   %rdi,%rdi
je     14b3 <exec_comm+0x2d3>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     14b3 <exec_comm+0x2d3>
mov    %r9,%r13
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %rsi,%r15
mov    %rdx,0x18(%rsp)
lea    0x4(%rsp),%rdi
call   1080 <pipe@plt>
test   %rax,%rax
jne    14aa <exec_comm+0x2ca>
xor    %eax,%eax
call   1100 <fork@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
js     1498 <exec_comm+0x2b8>
jne    1264 <exec_comm+0x84>
mov    0x2d99(%rip),%rax
and    (%rax),%r14d
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
xor    %ecx,%ecx
call   10a0 <exec_comm_child@plt>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    $0x80,%edi
call   10b0 <alloca@plt>
mov    %rax,%rbp
test   %r13,%r13
mov    %r15,0x10(%rsp)
mov    %rbx,0x38(%rsp)
mov    %r12,0x20(%rsp)
je     14c4 <exec_comm+0x2e4>
mov    %r13,0x30(%rsp)
xor    %r12d,%r12d
xor    %r13d,%r13d
mov    0x2d34(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   1090 <read@plt>
test   %eax,%eax
jg     12f7 <exec_comm+0x117>
mov    (%r15),%edx
mov    0x28(%rsp),%rdi
mov    %rbx,%rsi
call   10e0 <waitpid@plt>
test   %rax,%rax
je     12b0 <exec_comm+0xd0>
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   1090 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
jg     12fa <exec_comm+0x11a>
jmp    1624 <exec_comm+0x444>
mov    %eax,%r14d
mov    %r14d,%eax
mov    %rax,0x40(%rsp)
xor    %r15d,%r15d
mov    0x80(%rsp),%rbx
jmp    132b <exec_comm+0x14b>
cmp    $0x1,%r13d
mov    $0x3,%eax
cmove  %eax,%r13d
add    $0x1,%r15
cmp    %r15,0x40(%rsp)
je     129d <exec_comm+0xbd>
movsbl 0x0(%rbp,%r15,1),%esi
mov    %rbx,%rdi
call   1060 <strchr@plt>
test   %rax,%rax
je     1380 <exec_comm+0x1a0>
movsbl 0x0(%rbp,%r15,1),%esi
mov    0x88(%rsp),%rdi
call   1060 <strchr@plt>
test   %rax,%rax
je     13d0 <exec_comm+0x1f0>
cmpb   $0xa,0x0(%rbp,%r15,1)
je     130f <exec_comm+0x12f>
mov    %r13d,%eax
and    $0xfffffffd,%eax
mov    $0x2,%r14d
cmp    $0x1,%eax
jne    131c <exec_comm+0x13c>
jmp    13e3 <exec_comm+0x203>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax),%rsi
cmp    $0x3,%r13d
jne    1422 <exec_comm+0x242>
mov    0x30(%rsp),%rdi
call   10f0 <w_addword@plt>
mov    0x2c2d(%rip),%rcx
cmp    (%rcx),%eax
je     1470 <exec_comm+0x290>
mov    0x18(%rsp),%r14
mov    %r14,%rdi
mov    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   10d0 <w_newword@plt>
mov    %rax,%rsi
mov    0x10(%rsp),%r13
mov    %rax,0x0(%r13)
jmp    1431 <exec_comm+0x251>
xchg   %ax,%ax
xor    %r14d,%r14d
cmp    $0x2,%r13d
mov    $0x0,%r13d
je     131c <exec_comm+0x13c>
mov    0x10(%rsp),%rax
mov    (%rax),%rsi
mov    0x30(%rsp),%rdi
call   10f0 <w_addword@plt>
mov    0x2bd4(%rip),%rcx
cmp    (%rcx),%eax
je     1470 <exec_comm+0x290>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
call   10d0 <w_newword@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
xor    %r12d,%r12d
mov    %r14d,%r13d
jmp    131c <exec_comm+0x13c>
mov    0x10(%rsp),%r13
mov    0x20(%rsp),%rbx
mov    0x18(%rsp),%r14
movsbl 0x0(%rbp,%r15,1),%ecx
add    $0x1,%r12
cmp    $0xa,%ecx
mov    $0x0,%eax
cmovne %rax,%r12
mov    %rsi,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <w_addchar@plt>
mov    %rax,0x0(%r13)
mov    $0x1,%r13d
test   %rax,%rax
mov    0x80(%rsp),%rbx
jne    131c <exec_comm+0x13c>
mov    0x2b49(%rip),%rax
mov    (%rax),%esi
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <kill@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    0x4(%rsp),%edi
jmp    14a5 <exec_comm+0x2c5>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0x2b1f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
mov    0x2b0a(%rip),%rbx
lea    0xc(%rsp),%r15
mov    0x10(%rsp),%r13
jmp    1510 <exec_comm+0x330>
mov    %eax,%r14d
mov    0x18(%rsp),%rsi
mov    %r14d,%eax
add    %rax,%r12
mov    0x0(%r13),%rdi
mov    0x20(%rsp),%rdx
mov    %rbp,%rcx
mov    %r14d,%r8d
call   1030 <w_addmem@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     1470 <exec_comm+0x290>
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   1090 <read@plt>
test   %eax,%eax
jg     14da <exec_comm+0x2fa>
mov    (%rbx),%edx
mov    0x28(%rsp),%rdi
mov    %r15,%rsi
call   10e0 <waitpid@plt>
test   %rax,%rax
je     1510 <exec_comm+0x330>
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   1090 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
mov    0x18(%rsp),%rsi
jg     14e2 <exec_comm+0x302>
add    $0x1,%r12
add    $0xffffffffffffffff,%r12
je     15a1 <exec_comm+0x3c1>
mov    (%rsi),%rax
test   %rax,%rax
je     15a1 <exec_comm+0x3c1>
mov    0x0(%r13),%rcx
cmpb   $0xa,-0x1(%rcx,%rax,1)
jne    15a1 <exec_comm+0x3c1>
add    $0xffffffffffffffff,%rax
mov    %rax,(%rsi)
movb   $0x0,(%rcx,%rax,1)
cmpq   $0x0,(%rsi)
jne    155a <exec_comm+0x37a>
mov    0x0(%r13),%rdi
mov    %rsi,%rbx
call   1040 <free@plt>
mov    %rbx,%rdi
mov    0x20(%rsp),%rsi
call   10d0 <w_newword@plt>
mov    %rax,0x0(%r13)
mov    0x4(%rsp),%edi
call   1070 <close@plt>
xor    %ebp,%ebp
test   %r14d,%r14d
jg     14b3 <exec_comm+0x2d3>
cmpl   $0x0,0xc(%rsp)
mov    0x38(%rsp),%r14
je     14b3 <exec_comm+0x2d3>
xor    %eax,%eax
call   1100 <fork@plt>
test   %rax,%rax
js     14aa <exec_comm+0x2ca>
mov    %rax,%rbx
jne    15f7 <exec_comm+0x417>
movq   $0xffffffffffffffff,0x4(%rsp)
ff ff
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   10a0 <exec_comm_child@plt>
lea    0xc(%rsp),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1619 <exec_comm+0x439>
mov    0x29c9(%rip),%rcx
mov    (%rcx),%ecx
cmp    %rbx,%rax
cmove  %ecx,%ebp
jmp    14b3 <exec_comm+0x2d3>
mov    0x10(%rsp),%r13
mov    0x18(%rsp),%rsi
jmp    1556 <exec_comm+0x376>

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

LLVM IR (-O2):
@WRDE_NOSPACE = global i32 0
@WRDE_SHOWERR = global i32 0
@WNOHANG = global i32 0
@WRDE_SYNTAX = global i32 0
@SIGKILL = global i32 0
define i32 @exec_comm(i8* %0, i8** nocapture %1, i64* %2, i64* %3, i32 %4, i32* %5, i8* %6, i8* %7) {
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = bitcast [2 x i32]* %9 to i8*
%12 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%13 = icmp eq i8* %0, null
br i1 %13, label %191, label %14
14: ; preds = %8
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 0
br i1 %16, label %191, label %17
17: ; preds = %14
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%19 = call i64 @pipe(i32* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = load i32, i32* @WRDE_NOSPACE
br label %191
23: ; preds = %17
%24 = call i64 (...) @fork()
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* %18
%28 = call i32 @close(i32 %27)
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 @close(i32 %30)
%32 = load i32, i32* @WRDE_NOSPACE
br label %191
33: ; preds = %23
%34 = icmp eq i64 %24, 0
br i1 %34, label %35, label %39
35: ; preds = %33
%36 = load i32, i32* @WRDE_SHOWERR
%37 = and i32 %36, %4
%38 = call i32 @exec_comm_child(i8* %0, i32* %18, i32 %37, i32 0)
br label %39
39: ; preds = %35, %33
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = call i8* @alloca(i32 128)
%44 = icmp eq i32* %5, null
br i1 %44, label %45, label %66
45: ; preds = %39, %59
%46 = phi i64 [ %62, %59 ], [ 0, %39 ]
br label %47
47: ; preds = %45, %51
%48 = load i32, i32* %18
%49 = call i32 @read(i32 %48, i8* %43, i32 128)
%50 = icmp slt i32 %49, 1
br i1 %50, label %51, label %59
51: ; preds = %47
%52 = load i32, i32* @WNOHANG
%53 = call i64 @waitpid(i64 %24, i32* %10, i32 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %47, label %55
55: ; preds = %51
%56 = load i32, i32* %18
%57 = call i32 @read(i32 %56, i8* %43, i32 128)
%58 = icmp slt i32 %57, 1
br i1 %58, label %137, label %59
59: ; preds = %47, %55
%60 = phi i32 [ %57, %55 ], [ %49, %47 ]
%61 = zext i32 %60 to i64
%62 = add i64 %46, %61
%63 = load i8*, i8** %1
%64 = call i8* @w_addmem(i8* %63, i64* %2, i64* %3, i8* %43, i32 %60)
store i8* %64, i8** %1
%65 = icmp eq i8* %64, null
br i1 %65, label %184, label %45
66: ; preds = %132, %39
%67 = phi i64 [ 0, %39 ], [ %133, %132 ]
%68 = phi i32 [ 0, %39 ], [ %134, %132 ]
br label %69
69: ; preds = %66, %73
%70 = load i32, i32* %18
%71 = call i32 @read(i32 %70, i8* %43, i32 128)
%72 = icmp slt i32 %71, 1
br i1 %72, label %73, label %81
73: ; preds = %69
%74 = load i32, i32* @WNOHANG
%75 = call i64 @waitpid(i64 %24, i32* %10, i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %69, label %77
77: ; preds = %73
%78 = load i32, i32* %18
%79 = call i32 @read(i32 %78, i8* %43, i32 128)
%80 = icmp slt i32 %79, 1
br i1 %80, label %137, label %81
81: ; preds = %69, %77
%82 = phi i32 [ %79, %77 ], [ %71, %69 ]
%83 = zext i32 %82 to i64
br label %84
84: ; preds = %81, %132
%85 = phi i64 [ 0, %81 ], [ %135, %132 ]
%86 = phi i32 [ %68, %81 ], [ %134, %132 ]
%87 = phi i64 [ %67, %81 ], [ %133, %132 ]
%88 = getelementptr inbounds i8, i8* %43, i64 %85
%89 = load i8, i8* %88
%90 = call i32* @strchr(i8* %6, i8 signext %89)
%91 = icmp eq i32* %90, null
br i1 %91, label %115, label %92
92: ; preds = %84
%93 = load i8, i8* %88
%94 = call i32* @strchr(i8* %7, i8 signext %93)
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %98
96: ; preds = %92
%97 = icmp eq i32 %86, 2
br i1 %97, label %132, label %107
98: ; preds = %92
%99 = load i8, i8* %88
%100 = icmp eq i8 %99, 10
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = icmp eq i32 %86, 1
%103 = select i1 %102, i32 3, i32 %86
br label %132
104: ; preds = %98
%105 = and i32 %86, -3
%106 = icmp eq i32 %105, 1
br i1 %106, label %107, label %132
107: ; preds = %104, %96
%108 = phi i32 [ 0, %96 ], [ 2, %104 ]
%109 = load i8*, i8** %1
%110 = call i32 @w_addword(i32* %5, i8* %109)
%111 = load i32, i32* @WRDE_NOSPACE
%112 = icmp eq i32 %110, %111
br i1 %112, label %184, label %113
113: ; preds = %107
%114 = call i8* @w_newword(i64* %2, i64* %3)
store i8* %114, i8** %1
br label %132
115: ; preds = %84
%116 = icmp eq i32 %86, 3
%117 = load i8*, i8** %1
br i1 %116, label %118, label %124
118: ; preds = %115
%119 = call i32 @w_addword(i32* %5, i8* %117)
%120 = load i32, i32* @WRDE_NOSPACE
%121 = icmp eq i32 %119, %120
br i1 %121, label %184, label %122
122: ; preds = %118
%123 = call i8* @w_newword(i64* %2, i64* %3)
store i8* %123, i8** %1
br label %124
124: ; preds = %115, %122
%125 = phi i8* [ %123, %122 ], [ %117, %115 ]
%126 = load i8, i8* %88
%127 = icmp eq i8 %126, 10
%128 = add i64 %87, 1
%129 = select i1 %127, i64 %128, i64 0
%130 = call i8* @w_addchar(i8* %125, i64* %2, i64* %3, i8 signext %126)
store i8* %130, i8** %1
%131 = icmp eq i8* %130, null
br i1 %131, label %184, label %132
132: ; preds = %96, %113, %124, %104, %101
%133 = phi i64 [ 0, %113 ], [ %87, %101 ], [ %87, %104 ], [ %129, %124 ], [ %87, %96 ]
%134 = phi i32 [ %108, %113 ], [ %103, %101 ], [ %86, %104 ], [ 1, %124 ], [ 0, %96 ]
%135 = add nuw nsw i64 %85, 1
%136 = icmp eq i64 %135, %83
br i1 %136, label %66, label %84
137: ; preds = %77, %55
%138 = phi i32 [ %57, %55 ], [ %79, %77 ]
%139 = phi i64 [ %46, %55 ], [ %67, %77 ]
br label %140
140: ; preds = %153, %137
%141 = phi i64 [ %139, %137 ], [ %142, %153 ]
%142 = add i64 %141, -1
%143 = icmp eq i64 %141, 0
br i1 %143, label %160, label %144
144: ; preds = %140
%145 = load i64, i64* %2
%146 = icmp eq i64 %145, 0
br i1 %146, label %160, label %147
147: ; preds = %144
%148 = load i8*, i8** %1
%149 = add i64 %145, -1
%150 = getelementptr inbounds i8, i8* %148, i64 %149
%151 = load i8, i8* %150
%152 = icmp eq i8 %151, 10
br i1 %152, label %153, label %160
153: ; preds = %147
store i64 %149, i64* %2
store i8 0, i8* %150
%154 = load i64, i64* %2
%155 = icmp eq i64 %154, 0
br i1 %155, label %156, label %140
156: ; preds = %153
%157 = load i8*, i8** %1
%158 = call i32 @free(i8* %157)
%159 = call i8* @w_newword(i64* %2, i64* %3)
store i8* %159, i8** %1
br label %160
160: ; preds = %140, %144, %147, %156
%161 = load i32, i32* %18
%162 = call i32 @close(i32 %161)
%163 = icmp slt i32 %138, 1
%164 = load i32, i32* %10
%165 = icmp ne i32 %164, 0
%166 = select i1 %163, i1 %165, i1 false
br i1 %166, label %167, label %191
167: ; preds = %160
%168 = call i64 (...) @fork()
%169 = icmp slt i64 %168, 0
br i1 %169, label %170, label %172
170: ; preds = %167
%171 = load i32, i32* @WRDE_NOSPACE
br label %191
172: ; preds = %167
%173 = icmp eq i64 %168, 0
br i1 %173, label %174, label %176
174: ; preds = %172
store i32 -1, i32* %40
store i32 -1, i32* %18
%175 = call i32 @exec_comm_child(i8* %0, i32* %18, i32 0, i32 1)
br label %176
176: ; preds = %174, %172
%177 = call i64 @waitpid(i64 %168, i32* %10, i32 0)
%178 = icmp eq i64 %177, %168
%179 = load i32, i32* %10
%180 = icmp ne i32 %179, 0
%181 = select i1 %178, i1 %180, i1 false
%182 = load i32, i32* @WRDE_SYNTAX
%183 = select i1 %181, i32 %182, i32 0
br label %191
184: ; preds = %124, %118, %107, %59
%185 = load i32, i32* @SIGKILL
%186 = call i32 @kill(i64 %24, i32 %185)
%187 = call i64 @waitpid(i64 %24, i32* null, i32 0)
%188 = load i32, i32* %18
%189 = call i32 @close(i32 %188)
%190 = load i32, i32* @WRDE_NOSPACE
br label %191
191: ; preds = %176, %160, %8, %14, %184, %170, %26, %21
%192 = phi i32 [ %22, %21 ], [ %32, %26 ], [ %190, %184 ], [ %171, %170 ], [ 0, %14 ], [ 0, %8 ], [ 0, %160 ], [ %183, %176 ]
ret i32 %192
}