#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 pid_t;

/* Variables and functions */
int close(int);
int dup2(int, int);
int execvp(char *, char **);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ free(char **);
char **malloc(int);
int /*<<< orphan*/ memcpy(char **, char **, int);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *usage =
      "jerk runs two commands and connects their stdin and stdout in a cycle\n"
      "Usage:\n"
      "    jerk <command1> [arg1 ...] ; <command2> [arg1 ...]\n";
  if (argc < 3) {
    fprintf(stderr, usage);
    return 1;
  }
  char **nargv;
  char **c1argv = NULL;
  char **c2argv = NULL;
  int err;
  nargv = malloc(sizeof(char **) * argc);
  memcpy(nargv, argv, sizeof(char **) * argc + 1);
  int i;
  for (i = 0; i < argc; ++i) {
    if (strcmp(nargv[i], ";") == 0) {
      nargv[i] = NULL;
      if (c2argv == NULL && i + 1 != argc)
        c2argv = &nargv[i + 1];
    }
  }
  c1argv = &nargv[1];
  nargv[argc] = NULL;
  if (c2argv == NULL) {
    fprintf(stderr, "Separate commands with a ';'\nMake sure to escape it from "
                    "your shell.\nSee usage for more information\n\n");
    return 1;
  }
  pid_t pid1, pid2;
  int c1toc2[2];
  int c2toc1[2];
  err = pipe(c1toc2);
  if (err) {
    perror("pipe");
    return 1;
  }
  err = pipe(c2toc1);
  if (err) {
    perror("pipe");
    return 1;
  }
  pid1 = fork();
  if (pid1 < -1) {
    perror("fork");
    return 1;
  }
  if (pid1 == 0) {
    err = dup2(c2toc1[0], 0);
    if (err == -1) {
      perror("dup2");
      return 1;
    }
    err = dup2(c1toc2[1], 1);
    if (err == -1) {
      perror("dup2");
      return 1;
    }
    err = close(c1toc2[0]);
    if (err) {
      perror("close");
      return 1;
    }
    err = close(c1toc2[1]);
    if (err) {
      perror("close");
      return 1;
    }
    err = close(c2toc1[0]);
    if (err) {
      perror("close");
      return 1;
    }
    err = close(c2toc1[1]);
    if (err) {
      perror("close");
      return 1;
    }
    err = execvp(c1argv[0], c1argv);
    if (err) {
      perror("close");
      return 1;
    }
  } else {
    pid2 = fork();
    if (pid2 < -1) {
      perror("fork");
      return 1;
    }
    if (pid2 == 0) {
      err = dup2(c1toc2[0], 0);
      if (err == -1) {
        perror("dup2");
        return 1;
      }
      err = dup2(c2toc1[1], 1);
      if (err == -1) {
        perror("dup2");
        return 1;
      }
      err = close(c1toc2[0]);
      if (err) {
        perror("close");
        return 1;
      }
      err = close(c1toc2[1]);
      if (err) {
        perror("close");
        return 1;
      }
      err = close(c2toc1[0]);
      if (err) {
        perror("close");
        return 1;
      }
      err = close(c2toc1[1]);
      if (err) {
        perror("close");
        return 1;
      }
      err = execvp(c2argv[0], c2argv);
    } else {
      close(c1toc2[0]);
      if (err) {
        perror("close");
        return 1;
      }
      close(c1toc2[1]);
      if (err) {
        perror("close");
        return 1;
      }
      close(c2toc1[0]);
      if (err) {
        perror("close");
        return 1;
      }
      close(c2toc1[1]);
      if (err) {
        perror("close");
        return 1;
      }
      free(nargv);
      wait(0);
      wait(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe23(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1209 <main+0x49>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
add    $0x1,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d6 <main+0x116>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe18(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c3 <main+0x103>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x30(%rbp)
jne    12be <main+0xfe>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     12be <main+0xfe>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    12c3 <main+0x103>
jmp    12c8 <main+0x108>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    124e <main+0x8e>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x30(%rbp)
jne    131e <main+0x15e>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
lea    -0x48(%rbp),%rdi
call   1060 <pipe@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     134c <main+0x18c>
lea    0xdb2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
lea    -0x50(%rbp),%rdi
call   1060 <pipe@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     137a <main+0x1ba>
lea    0xd84(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jge    13a6 <main+0x1e6>
lea    0xd5d(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
cmpl   $0x0,-0x3c(%rbp)
jne    14ff <main+0x33f>
mov    -0x50(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    13df <main+0x21f>
lea    0xd29(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x44(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1411 <main+0x251>
lea    0xcf7(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x48(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     143e <main+0x27e>
lea    0xccf(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x44(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     146b <main+0x2ab>
lea    0xca2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x50(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1498 <main+0x2d8>
lea    0xc75(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x4c(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     14c5 <main+0x305>
lea    0xc48(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   10c0 <execvp@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     14fa <main+0x33a>
lea    0xc13(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
jmp    1726 <main+0x566>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
jge    152b <main+0x36b>
lea    0xbd8(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
cmpl   $0x0,-0x40(%rbp)
jne    1662 <main+0x4a2>
mov    -0x48(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1564 <main+0x3a4>
lea    0xba4(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x4c(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1596 <main+0x3d6>
lea    0xb72(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x48(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     15c3 <main+0x403>
lea    0xb4a(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x44(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     15f0 <main+0x430>
lea    0xb1d(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x50(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     161d <main+0x45d>
lea    0xaf0(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x4c(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     164a <main+0x48a>
lea    0xac3(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rsi
call   10c0 <execvp@plt>
mov    %eax,-0x34(%rbp)
jmp    1721 <main+0x561>
mov    -0x48(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x34(%rbp)
je     168c <main+0x4cc>
lea    0xa81(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x44(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x34(%rbp)
je     16b6 <main+0x4f6>
lea    0xa57(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x50(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x34(%rbp)
je     16e0 <main+0x520>
lea    0xa2d(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x4c(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x34(%rbp)
je     170a <main+0x54a>
lea    0xa03(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    172d <main+0x56d>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
jmp    1726 <main+0x566>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jg     11e6 <main+0x26>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
jmp    1314 <main+0x154>
mov    %rsi,%r14
mov    %edi,%ebp
mov    %edi,%ebx
lea    0x0(,%rbp,8),%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
lea    0x1(,%rbp,8),%edx
mov    %rax,%rdi
mov    %r14,%rsi
call   1090 <memcpy@plt>
xor    %ebp,%ebp
lea    0xe6e(%rip),%r12
xor    %r14d,%r14d
jmp    1229 <main+0x69>
lea    (%r15,%rax,8),%r14
add    $0x1,%rbp
cmp    %rbx,%rbp
je     1268 <main+0xa8>
mov    (%r15,%rbp,8),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1220 <main+0x60>
movq   $0x0,(%r15,%rbp,8)
test   %r14,%r14
jne    1220 <main+0x60>
lea    0x1(%rbp),%rax
cmp    %rbx,%rax
jne    121c <main+0x5c>
mov    %rax,%rbp
mov    $0x0,%r14d
jne    1229 <main+0x69>
movq   $0x0,(%r15,%rbx,8)
jmp    1304 <main+0x144>
movq   $0x0,(%r15,%rbx,8)
test   %r14,%r14
je     1304 <main+0x144>
lea    0x8(%rsp),%rdi
call   1060 <pipe@plt>
test   %eax,%eax
jne    1423 <main+0x263>
mov    %rsp,%rdi
call   1060 <pipe@plt>
test   %eax,%eax
jne    1423 <main+0x263>
xor    %eax,%eax
call   10e0 <fork@plt>
cmp    $0xfffffffe,%eax
jle    1435 <main+0x275>
test   %eax,%eax
je     132d <main+0x16d>
xor    %eax,%eax
call   10e0 <fork@plt>
cmp    $0xfffffffe,%eax
jle    1435 <main+0x275>
mov    0x8(%rsp),%edi
test   %eax,%eax
je     13ba <main+0x1fa>
call   1050 <close@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
mov    (%rsp),%edi
call   1050 <close@plt>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %ebp,%ebp
xor    %edi,%edi
call   10d0 <wait@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
jmp    131e <main+0x15e>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
je     143e <main+0x27e>
mov    0xc(%rsp),%edi
mov    $0x1,%ebp
mov    $0x1,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
je     144f <main+0x28f>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    (%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
add    $0x8,%r15
mov    (%r15),%rdi
mov    %r15,%rsi
call   10c0 <execvp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     131e <main+0x15e>
jmp    142c <main+0x26c>
xor    %esi,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
je     143e <main+0x27e>
mov    0x4(%rsp),%edi
mov    $0x1,%ebp
mov    $0x1,%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
je     144f <main+0x28f>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    (%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
test   %eax,%eax
jne    142c <main+0x26c>
mov    (%r14),%rdi
mov    %r14,%rsi
call   10c0 <execvp@plt>
xor    %ebp,%ebp
jmp    131e <main+0x15e>
lea    0xcc3(%rip),%rdi
jmp    1445 <main+0x285>
lea    0xcc9(%rip),%rdi
jmp    1445 <main+0x285>
lea    0xcb6(%rip),%rdi
jmp    1445 <main+0x285>
lea    0xcb2(%rip),%rdi
call   10b0 <perror@plt>
jmp    1319 <main+0x159>
lea    0xca1(%rip),%rdi
call   10b0 <perror@plt>
jmp    131e <main+0x15e>

LLVM IR (-O0):
@.str = [133 x i8] c"jerk runs two commands and connects their stdin and stdout in a cycle\0AUsage:\0A jerk <command1> [arg1 ...] ; <command2> [arg1 ...]\0A\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c";\00"
@.str.2 = [102 x i8] c"Separate commands with a ';'\0AMake sure to escape it from your shell.\0ASee usage for more information\0A\0A\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [5 x i8] c"fork\00"
@.str.5 = [5 x i8] c"dup2\00"
@.str.6 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i8** %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %6
%21 = call i32 @fprintf(i32 %19, i8* %20)
store i32 1, i32* %3
br label %267
22: ; preds = %2
store i8** null, i8*** %8
store i8** null, i8*** %9
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = mul i64 8, %24
%26 = trunc i64 %25 to i32
%27 = call i8** @malloc(i32 %26)
store i8** %27, i8*** %7
%28 = load i8**, i8*** %7
%29 = load i8**, i8*** %5
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = mul i64 8, %31
%33 = add i64 %32, 1
%34 = trunc i64 %33 to i32
%35 = call i32 @memcpy(i8** %28, i8** %29, i32 %34)
store i32 0, i32* %11
br label %36
36: ; preds = %68, %22
%37 = load i32, i32* %11
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %71
40: ; preds = %36
%41 = load i8**, i8*** %7
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %67
48: ; preds = %40
%49 = load i8**, i8*** %7
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
store i8* null, i8** %52
%53 = load i8**, i8*** %9
%54 = icmp eq i8** %53, null
br i1 %54, label %55, label %66
55: ; preds = %48
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
%58 = load i32, i32* %4
%59 = icmp ne i32 %57, %58
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = load i8**, i8*** %7
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %61, i64 %64
store i8** %65, i8*** %9
br label %66
66: ; preds = %60, %55, %48
br label %67
67: ; preds = %66, %40
br label %68
68: ; preds = %67
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %36
71: ; preds = %36
%72 = load i8**, i8*** %7
%73 = getelementptr inbounds i8*, i8** %72, i64 1
store i8** %73, i8*** %8
%74 = load i8**, i8*** %7
%75 = load i32, i32* %4
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
store i8* null, i8** %77
%78 = load i8**, i8*** %9
%79 = icmp eq i8** %78, null
br i1 %79, label %80, label %83
80: ; preds = %71
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %267
83: ; preds = %71
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%85 = call i32 @pipe(i32* %84)
store i32 %85, i32* %10
%86 = load i32, i32* %10
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %83
%89 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %267
90: ; preds = %83
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%92 = call i32 @pipe(i32* %91)
store i32 %92, i32* %10
%93 = load i32, i32* %10
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %267
97: ; preds = %90
%98 = call i32 (...) @fork()
store i32 %98, i32* %12
%99 = load i32, i32* %12
%100 = icmp slt i32 %99, -1
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %267
103: ; preds = %97
%104 = load i32, i32* %12
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %165
106: ; preds = %103
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%108 = load i32, i32* %107
%109 = call i32 @dup2(i32 %108, i32 0)
store i32 %109, i32* %10
%110 = load i32, i32* %10
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %114
112: ; preds = %106
%113 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %267
114: ; preds = %106
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%116 = load i32, i32* %115
%117 = call i32 @dup2(i32 %116, i32 1)
store i32 %117, i32* %10
%118 = load i32, i32* %10
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %122
120: ; preds = %114
%121 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %267
122: ; preds = %114
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%124 = load i32, i32* %123
%125 = call i32 @close(i32 %124)
store i32 %125, i32* %10
%126 = load i32, i32* %10
%127 = icmp ne i32 %126, 0
br i1 %127, label %128, label %130
128: ; preds = %122
%129 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
130: ; preds = %122
%131 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%132 = load i32, i32* %131
%133 = call i32 @close(i32 %132)
store i32 %133, i32* %10
%134 = load i32, i32* %10
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %130
%137 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
138: ; preds = %130
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%140 = load i32, i32* %139
%141 = call i32 @close(i32 %140)
store i32 %141, i32* %10
%142 = load i32, i32* %10
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %138
%145 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
146: ; preds = %138
%147 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%148 = load i32, i32* %147
%149 = call i32 @close(i32 %148)
store i32 %149, i32* %10
%150 = load i32, i32* %10
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %154
152: ; preds = %146
%153 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
154: ; preds = %146
%155 = load i8**, i8*** %8
%156 = getelementptr inbounds i8*, i8** %155, i64 0
%157 = load i8*, i8** %156
%158 = load i8**, i8*** %8
%159 = call i32 @execvp(i8* %157, i8** %158)
store i32 %159, i32* %10
%160 = load i32, i32* %10
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %164
162: ; preds = %154
%163 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
164: ; preds = %154
br label %266
165: ; preds = %103
%166 = call i32 (...) @fork()
store i32 %166, i32* %13
%167 = load i32, i32* %13
%168 = icmp slt i32 %167, -1
br i1 %168, label %169, label %171
169: ; preds = %165
%170 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %267
171: ; preds = %165
%172 = load i32, i32* %13
%173 = icmp eq i32 %172, 0
br i1 %173, label %174, label %228
174: ; preds = %171
%175 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%176 = load i32, i32* %175
%177 = call i32 @dup2(i32 %176, i32 0)
store i32 %177, i32* %10
%178 = load i32, i32* %10
%179 = icmp eq i32 %178, -1
br i1 %179, label %180, label %182
180: ; preds = %174
%181 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %267
182: ; preds = %174
%183 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%184 = load i32, i32* %183
%185 = call i32 @dup2(i32 %184, i32 1)
store i32 %185, i32* %10
%186 = load i32, i32* %10
%187 = icmp eq i32 %186, -1
br i1 %187, label %188, label %190
188: ; preds = %182
%189 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %267
190: ; preds = %182
%191 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%192 = load i32, i32* %191
%193 = call i32 @close(i32 %192)
store i32 %193, i32* %10
%194 = load i32, i32* %10
%195 = icmp ne i32 %194, 0
br i1 %195, label %196, label %198
196: ; preds = %190
%197 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
198: ; preds = %190
%199 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%200 = load i32, i32* %199
%201 = call i32 @close(i32 %200)
store i32 %201, i32* %10
%202 = load i32, i32* %10
%203 = icmp ne i32 %202, 0
br i1 %203, label %204, label %206
204: ; preds = %198
%205 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
206: ; preds = %198
%207 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%208 = load i32, i32* %207
%209 = call i32 @close(i32 %208)
store i32 %209, i32* %10
%210 = load i32, i32* %10
%211 = icmp ne i32 %210, 0
br i1 %211, label %212, label %214
212: ; preds = %206
%213 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
214: ; preds = %206
%215 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%216 = load i32, i32* %215
%217 = call i32 @close(i32 %216)
store i32 %217, i32* %10
%218 = load i32, i32* %10
%219 = icmp ne i32 %218, 0
br i1 %219, label %220, label %222
220: ; preds = %214
%221 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
222: ; preds = %214
%223 = load i8**, i8*** %9
%224 = getelementptr inbounds i8*, i8** %223, i64 0
%225 = load i8*, i8** %224
%226 = load i8**, i8*** %9
%227 = call i32 @execvp(i8* %225, i8** %226)
store i32 %227, i32* %10
br label %265
228: ; preds = %171
%229 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%230 = load i32, i32* %229
%231 = call i32 @close(i32 %230)
%232 = load i32, i32* %10
%233 = icmp ne i32 %232, 0
br i1 %233, label %234, label %236
234: ; preds = %228
%235 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
236: ; preds = %228
%237 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%238 = load i32, i32* %237
%239 = call i32 @close(i32 %238)
%240 = load i32, i32* %10
%241 = icmp ne i32 %240, 0
br i1 %241, label %242, label %244
242: ; preds = %236
%243 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
244: ; preds = %236
%245 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%246 = load i32, i32* %245
%247 = call i32 @close(i32 %246)
%248 = load i32, i32* %10
%249 = icmp ne i32 %248, 0
br i1 %249, label %250, label %252
250: ; preds = %244
%251 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
252: ; preds = %244
%253 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%254 = load i32, i32* %253
%255 = call i32 @close(i32 %254)
%256 = load i32, i32* %10
%257 = icmp ne i32 %256, 0
br i1 %257, label %258, label %260
258: ; preds = %252
%259 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %267
260: ; preds = %252
%261 = load i8**, i8*** %7
%262 = call i32 @free(i8** %261)
%263 = call i32 @wait(i32 0)
%264 = call i32 @wait(i32 0)
br label %265
265: ; preds = %260, %222
br label %266
266: ; preds = %265, %164
store i32 0, i32* %3
br label %267
267: ; preds = %266, %258, %250, %242, %234, %220, %212, %204, %196, %188, %180, %169, %162, %152, %144, %136, %128, %120, %112, %101, %95, %88, %80, %18
%268 = load i32, i32* %3
ret i32 %268
}

LLVM IR (-O2):
@.str = [133 x i8] c"jerk runs two commands and connects their stdin and stdout in a cycle\0AUsage:\0A jerk <command1> [arg1 ...] ; <command2> [arg1 ...]\0A\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c";\00"
@.str.2 = [102 x i8] c"Separate commands with a ';'\0AMake sure to escape it from your shell.\0ASee usage for more information\0A\0A\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [5 x i8] c"fork\00"
@.str.5 = [5 x i8] c"dup2\00"
@.str.6 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0))
br label %176
9: ; preds = %2
%10 = zext i32 %0 to i64
%11 = shl i32 %0, 3
%12 = tail call i8** @malloc(i32 %11)
%13 = or i32 %11, 1
%14 = tail call i32 @memcpy(i8** %12, i8** %1, i32 %13)
br label %15
15: ; preds = %33, %9
%16 = phi i64 [ 0, %9 ], [ %34, %33 ]
%17 = phi i8** [ null, %9 ], [ %35, %33 ]
%18 = getelementptr inbounds i8*, i8** %12, i64 %16
%19 = load i8*, i8** %18
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %15
store i8* null, i8** %18
%23 = icmp eq i8** %17, null
br i1 %23, label %24, label %29
24: ; preds = %22
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, %10
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = getelementptr inbounds i8*, i8** %12, i64 %25
br label %29
29: ; preds = %15, %27, %22
%30 = phi i8** [ %28, %27 ], [ %17, %22 ], [ %17, %15 ]
%31 = add nuw nsw i64 %16, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %41, label %33
33: ; preds = %29, %36
%34 = phi i64 [ %31, %29 ], [ %37, %36 ]
%35 = phi i8** [ %30, %29 ], [ null, %36 ]
br label %15
36: ; preds = %24
%37 = add nuw nsw i64 %16, 1
%38 = icmp eq i64 %37, %10
br i1 %38, label %39, label %33
39: ; preds = %36
%40 = getelementptr inbounds i8*, i8** %12, i64 %10
store i8* null, i8** %40
br label %45
41: ; preds = %29
%42 = getelementptr inbounds i8*, i8** %12, i64 1
%43 = getelementptr inbounds i8*, i8** %12, i64 %10
store i8* null, i8** %43
%44 = icmp eq i8** %30, null
br i1 %44, label %45, label %48
45: ; preds = %39, %41
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0))
br label %176
48: ; preds = %41
%49 = bitcast [2 x i32]* %3 to i8*
%50 = bitcast [2 x i32]* %4 to i8*
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%52 = call i32 @pipe(i32* %51)
%53 = icmp eq i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %174
56: ; preds = %48
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%58 = call i32 @pipe(i32* %57)
%59 = icmp eq i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %174
62: ; preds = %56
%63 = call i32 (...) @fork()
%64 = icmp slt i32 %63, -1
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %174
67: ; preds = %62
%68 = icmp eq i32 %63, 0
br i1 %68, label %69, label %113
69: ; preds = %67
%70 = load i32, i32* %57
%71 = call i32 @dup2(i32 %70, i32 0)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %174
75: ; preds = %69
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%77 = load i32, i32* %76
%78 = call i32 @dup2(i32 %77, i32 1)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %75
%81 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %174
82: ; preds = %75
%83 = load i32, i32* %51
%84 = call i32 @close(i32 %83)
%85 = icmp eq i32 %84, 0
br i1 %85, label %88, label %86
86: ; preds = %82
%87 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
88: ; preds = %82
%89 = load i32, i32* %76
%90 = call i32 @close(i32 %89)
%91 = icmp eq i32 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %88
%93 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
94: ; preds = %88
%95 = load i32, i32* %57
%96 = call i32 @close(i32 %95)
%97 = icmp eq i32 %96, 0
br i1 %97, label %100, label %98
98: ; preds = %94
%99 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
100: ; preds = %94
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%102 = load i32, i32* %101
%103 = call i32 @close(i32 %102)
%104 = icmp eq i32 %103, 0
br i1 %104, label %107, label %105
105: ; preds = %100
%106 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
107: ; preds = %100
%108 = load i8*, i8** %42
%109 = call i32 @execvp(i8* %108, i8** %42)
%110 = icmp eq i32 %109, 0
br i1 %110, label %174, label %111
111: ; preds = %107
%112 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
113: ; preds = %67
%114 = call i32 (...) @fork()
%115 = icmp slt i32 %114, -1
br i1 %115, label %116, label %118
116: ; preds = %113
%117 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %174
118: ; preds = %113
%119 = icmp eq i32 %114, 0
%120 = load i32, i32* %51
br i1 %119, label %121, label %161
121: ; preds = %118
%122 = call i32 @dup2(i32 %120, i32 0)
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %126
124: ; preds = %121
%125 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %174
126: ; preds = %121
%127 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%128 = load i32, i32* %127
%129 = call i32 @dup2(i32 %128, i32 1)
%130 = icmp eq i32 %129, -1
br i1 %130, label %131, label %133
131: ; preds = %126
%132 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %174
133: ; preds = %126
%134 = load i32, i32* %51
%135 = call i32 @close(i32 %134)
%136 = icmp eq i32 %135, 0
br i1 %136, label %139, label %137
137: ; preds = %133
%138 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
139: ; preds = %133
%140 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%141 = load i32, i32* %140
%142 = call i32 @close(i32 %141)
%143 = icmp eq i32 %142, 0
br i1 %143, label %146, label %144
144: ; preds = %139
%145 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
146: ; preds = %139
%147 = load i32, i32* %57
%148 = call i32 @close(i32 %147)
%149 = icmp eq i32 %148, 0
br i1 %149, label %152, label %150
150: ; preds = %146
%151 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
152: ; preds = %146
%153 = load i32, i32* %127
%154 = call i32 @close(i32 %153)
%155 = icmp eq i32 %154, 0
br i1 %155, label %158, label %156
156: ; preds = %152
%157 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %174
158: ; preds = %152
%159 = load i8*, i8** %30
%160 = call i32 @execvp(i8* %159, i8** %30)
br label %174
161: ; preds = %118
%162 = call i32 @close(i32 %120)
%163 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%164 = load i32, i32* %163
%165 = call i32 @close(i32 %164)
%166 = load i32, i32* %57
%167 = call i32 @close(i32 %166)
%168 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%169 = load i32, i32* %168
%170 = call i32 @close(i32 %169)
%171 = call i32 @free(i8** %12)
%172 = call i32 @wait(i32 0)
%173 = call i32 @wait(i32 0)
br label %174
174: ; preds = %107, %161, %158, %156, %150, %144, %137, %131, %124, %116, %111, %105, %98, %92, %86, %80, %73, %65, %60, %54
%175 = phi i32 [ 1, %54 ], [ 1, %60 ], [ 1, %65 ], [ 1, %73 ], [ 1, %80 ], [ 1, %86 ], [ 1, %92 ], [ 1, %98 ], [ 1, %105 ], [ 1, %111 ], [ 1, %116 ], [ 1, %124 ], [ 1, %131 ], [ 1, %137 ], [ 1, %144 ], [ 1, %150 ], [ 1, %156 ], [ 0, %158 ], [ 0, %161 ], [ 0, %107 ]
br label %176
176: ; preds = %45, %174, %6
%177 = phi i32 [ 1, %6 ], [ 1, %45 ], [ %175, %174 ]
ret i32 %177
}