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

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ pid_t;

/* Variables and functions */
int WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
char **alloca(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ copy(int);
int /*<<< orphan*/ die(char *, ...);
int /*<<< orphan*/ dup(int);
int /*<<< orphan*/ execv(char *, char **);
scalar_t__ fork();
int /*<<< orphan*/ memcpy(char **, char **, int);
scalar_t__ pipe(int *);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ wait(int *);
int main(int argc, char **argv) {
  int sep, nbox, nchk;
  char **abox, **achk;
  pid_t pbox, pchk;
  int inpipe[2], outpipe[2], boxepipe[2], chkepipe[2];
  int exited = 0, sbox, schk;
  for (sep = 1; sep < argc; sep++)
    if (!strcmp(argv[sep], "@@"))
      break;
  if (sep >= argc - 1)
    die("Usage: iwrapper <testee> @@ <tester>");
  nbox = sep - 1;
  abox = alloca((nbox + 1) * sizeof(char *));
  memcpy(abox, argv + 1, nbox * sizeof(char *));
  abox[nbox] = NULL;
  nchk = argc - sep - 1;
  achk = alloca((nchk + 1) * sizeof(char *));
  memcpy(achk, argv + sep + 1, nchk * sizeof(char *));
  achk[nchk] = NULL;
  if (pipe(inpipe) < 0 || pipe(outpipe) < 0 || pipe(boxepipe) < 0 ||
      pipe(chkepipe) < 0)
    die("pipe: %m");
  pbox = fork();
  if (pbox < 0)
    die("fork: %m");
  if (!pbox) {
    close(inpipe[1]);
    close(0);
    dup(inpipe[0]);
    close(inpipe[0]);
    close(outpipe[0]);
    close(1);
    dup(outpipe[1]);
    close(outpipe[1]);
    close(boxepipe[0]);
    close(2);
    dup(boxepipe[1]);
    close(boxepipe[1]);
    close(chkepipe[0]);
    close(chkepipe[1]);
    execv(abox[0], abox);
    die("exec: %m");
  }
  pchk = fork();
  if (pchk < 0)
    die("fork: %m");
  if (!pchk) {
    close(inpipe[0]);
    close(1);
    dup(inpipe[1]);
    close(inpipe[1]);
    close(outpipe[1]);
    close(0);
    dup(outpipe[0]);
    close(outpipe[0]);
    close(chkepipe[0]);
    close(2);
    dup(chkepipe[1]);
    close(chkepipe[1]);
    close(boxepipe[0]);
    close(boxepipe[1]);
    execv(achk[0], achk);
    die("exec: %m");
  }
  close(inpipe[0]);
  close(inpipe[1]);
  close(outpipe[0]);
  close(outpipe[1]);
  close(chkepipe[1]);
  close(boxepipe[1]);
  sbox = schk = 0;
  while (exited != 3) {
    int st;
    pid_t p = wait(&st);
    if (p < 0)
      die("wait: %m");
    if (p == pbox) {
      exited |= 1;
      sbox = st;
    } else if (p == pchk) {
      exited |= 2;
      schk = st;
    } else
      die("Unknown process %d died", p);
  }
  if (!WIFEXITED(sbox))
    die("Sandbox fault, status=%x", sbox);
  if (!WIFEXITED(schk) || WEXITSTATUS(schk) >= 100)
    die("Checker fault, status=%x", schk);
  if (WEXITSTATUS(sbox)) {
    copy(boxepipe[0]);
    copy(chkepipe[0]);
    return 1;
  } else if (WEXITSTATUS(schk)) {
    copy(chkepipe[0]);
    copy(boxepipe[0]);
    return 1;
  }
  copy(boxepipe[0]);
  copy(chkepipe[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123c <main+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdea(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1229 <main+0x59>
jmp    123c <main+0x6c>
jmp    122e <main+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f7 <main+0x27>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     125b <main+0x8b>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <alloca@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
sub    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
add    $0x8,%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
lea    -0x48(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jl     134b <main+0x17b>
lea    -0x50(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jl     134b <main+0x17b>
lea    -0x58(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jl     134b <main+0x17b>
lea    -0x60(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jge    1359 <main+0x189>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jge    137d <main+0x1ad>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1419 <main+0x249>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1040 <close@plt>
mov    -0x48(%rbp),%edi
call   1030 <dup@plt>
mov    -0x48(%rbp),%edi
call   1040 <close@plt>
mov    -0x50(%rbp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    -0x4c(%rbp),%edi
call   1030 <dup@plt>
mov    -0x4c(%rbp),%edi
call   1040 <close@plt>
mov    -0x58(%rbp),%edi
call   1040 <close@plt>
mov    $0x2,%edi
call   1040 <close@plt>
mov    -0x54(%rbp),%edi
call   1030 <dup@plt>
mov    -0x54(%rbp),%edi
call   1040 <close@plt>
mov    -0x60(%rbp),%edi
call   1040 <close@plt>
mov    -0x5c(%rbp),%edi
call   1040 <close@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   10e0 <execv@plt>
lea    0xc28(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jge    143d <main+0x26d>
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
cmpq   $0x0,-0x40(%rbp)
jne    14d9 <main+0x309>
mov    -0x48(%rbp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
call   1030 <dup@plt>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
mov    -0x4c(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1040 <close@plt>
mov    -0x50(%rbp),%edi
call   1030 <dup@plt>
mov    -0x50(%rbp),%edi
call   1040 <close@plt>
mov    -0x60(%rbp),%edi
call   1040 <close@plt>
mov    $0x2,%edi
call   1040 <close@plt>
mov    -0x5c(%rbp),%edi
call   1030 <dup@plt>
mov    -0x5c(%rbp),%edi
call   1040 <close@plt>
mov    -0x58(%rbp),%edi
call   1040 <close@plt>
mov    -0x54(%rbp),%edi
call   1040 <close@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rsi
call   10e0 <execv@plt>
lea    0xb68(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    -0x48(%rbp),%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
mov    -0x50(%rbp),%edi
call   1040 <close@plt>
mov    -0x4c(%rbp),%edi
call   1040 <close@plt>
mov    -0x5c(%rbp),%edi
call   1040 <close@plt>
mov    -0x54(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x3,-0x64(%rbp)
je     15a7 <main+0x3d7>
lea    -0x70(%rbp),%rdi
call   10d0 <wait@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jge    1547 <main+0x377>
lea    0xb03(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    -0x78(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    1569 <main+0x399>
mov    -0x64(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    15a2 <main+0x3d2>
mov    -0x78(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    158b <main+0x3bb>
mov    -0x64(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    159d <main+0x3cd>
mov    -0x78(%rbp),%rsi
lea    0xab6(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
jmp    15a2 <main+0x3d2>
jmp    1517 <main+0x347>
mov    -0x68(%rbp),%edi
call   10c0 <WIFEXITED@plt>
cmp    $0x0,%eax
jne    15c9 <main+0x3f9>
mov    -0x68(%rbp),%esi
lea    0xaa2(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    -0x6c(%rbp),%edi
call   10c0 <WIFEXITED@plt>
cmp    $0x0,%eax
je     15eb <main+0x41b>
mov    -0x6c(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0x64,%eax
jl     15fc <main+0x42c>
mov    -0x6c(%rbp),%esi
lea    0xa88(%rip),%rdi
mov    $0x0,%al
call   10b0 <die@plt>
mov    -0x68(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0x0,%eax
je     1629 <main+0x459>
mov    -0x58(%rbp),%edi
call   1060 <copy@plt>
mov    -0x60(%rbp),%edi
call   1060 <copy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1672 <main+0x4a2>
mov    -0x6c(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0x0,%eax
je     1656 <main+0x486>
mov    -0x60(%rbp),%edi
call   1060 <copy@plt>
mov    -0x58(%rbp),%edi
call   1060 <copy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1672 <main+0x4a2>
jmp    165b <main+0x48b>
mov    -0x58(%rbp),%edi
call   1060 <copy@plt>
mov    -0x60(%rbp),%edi
call   1060 <copy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r13
mov    %edi,%r12d
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     121e <main+0x4e>
mov    %r12d,%ebx
mov    $0x1,%ebp
lea    0xe03(%rip),%r14
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     121e <main+0x4e>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1200 <main+0x30>
mov    %ebx,%ebp
jmp    1227 <main+0x57>
lea    -0x1(%r12),%eax
cmp    %eax,%ebp
jl     1235 <main+0x65>
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
mov    %ebp,%ebx
lea    0x0(,%rbp,8),%edi
call   1080 <alloca@plt>
mov    %rax,%r15
lea    0x8(%r13),%rsi
movslq %ebp,%rbp
lea    -0x8(,%rbp,8),%edx
mov    %rax,%rdi
call   1090 <memcpy@plt>
movq   $0x0,-0x8(%r15,%rbp,8)
sub    %ebp,%r12d
lea    0x0(,%r12,8),%edi
call   1080 <alloca@plt>
mov    %rax,%r14
lea    0x8(,%rbx,8),%rsi
add    %r13,%rsi
movslq %r12d,%rbx
lea    -0x8(,%rbx,8),%edx
mov    %rax,%rdi
call   1090 <memcpy@plt>
movq   $0x0,-0x8(%r14,%rbx,8)
lea    0x24(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     12da <main+0x10a>
lea    0x1c(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     12da <main+0x10a>
lea    0x14(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     12da <main+0x10a>
lea    0xc(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
jns    12e8 <main+0x118>
lea    0xd47(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    %rax,%r12
test   %rax,%rax
js     1393 <main+0x1c3>
jne    13a1 <main+0x1d1>
mov    0x28(%rsp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1040 <close@plt>
mov    0x24(%rsp),%edi
call   1030 <dup@plt>
mov    0x24(%rsp),%edi
call   1040 <close@plt>
mov    0x1c(%rsp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    0x20(%rsp),%edi
call   1030 <dup@plt>
mov    0x20(%rsp),%edi
call   1040 <close@plt>
mov    0x14(%rsp),%edi
call   1040 <close@plt>
mov    $0x2,%edi
call   1040 <close@plt>
mov    0x18(%rsp),%edi
call   1030 <dup@plt>
mov    0x18(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    (%r15),%rdi
mov    %r15,%rsi
call   10e0 <execv@plt>
lea    0xca9(%rip),%rdi
jmp    139a <main+0x1ca>
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    %rax,0x30(%rsp)
test   %rax,%rax
js     144e <main+0x27e>
jne    145c <main+0x28c>
mov    0x24(%rsp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    0x28(%rsp),%edi
call   1030 <dup@plt>
mov    0x28(%rsp),%edi
call   1040 <close@plt>
mov    0x20(%rsp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1040 <close@plt>
mov    0x1c(%rsp),%edi
call   1030 <dup@plt>
mov    0x1c(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    $0x2,%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1030 <dup@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0x14(%rsp),%edi
call   1040 <close@plt>
mov    0x18(%rsp),%edi
call   1040 <close@plt>
mov    (%r14),%rdi
mov    %r14,%rsi
call   10e0 <execv@plt>
lea    0xbee(%rip),%rdi
jmp    1455 <main+0x285>
lea    0xbdc(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
mov    0x24(%rsp),%edi
call   1040 <close@plt>
mov    0x28(%rsp),%edi
call   1040 <close@plt>
mov    0x1c(%rsp),%edi
call   1040 <close@plt>
mov    0x20(%rsp),%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0x18(%rsp),%edi
call   1040 <close@plt>
lea    0x2c(%rsp),%rbx
xor    %r15d,%r15d
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    14be <main+0x2ee>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
or     $0x1,%r14d
mov    0x2c(%rsp),%ebp
cmp    $0x3,%r14d
je     1523 <main+0x353>
mov    %rbx,%rdi
call   10d0 <wait@plt>
mov    %rax,%r13
test   %rax,%rax
js     14e0 <main+0x310>
cmp    %r12,%r13
je     14b0 <main+0x2e0>
jmp    14f3 <main+0x323>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xb5c(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
cmp    %r12,%r13
je     14b0 <main+0x2e0>
cmp    0x30(%rsp),%r13
jne    1510 <main+0x340>
or     $0x2,%r14d
mov    0x2c(%rsp),%r15d
jmp    14b8 <main+0x2e8>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xb35(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10b0 <die@plt>
jmp    14b8 <main+0x2e8>
mov    %ebp,%edi
call   10c0 <WIFEXITED@plt>
test   %eax,%eax
jne    153e <main+0x36e>
lea    0xb2f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10b0 <die@plt>
mov    %r15d,%edi
call   10c0 <WIFEXITED@plt>
test   %eax,%eax
je     1557 <main+0x387>
mov    %r15d,%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0x64,%eax
jl     1568 <main+0x398>
lea    0xb1f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   10b0 <die@plt>
mov    %ebp,%edi
call   10a0 <WEXITSTATUS@plt>
test   %eax,%eax
je     1587 <main+0x3b7>
mov    0x14(%rsp),%edi
call   1060 <copy@plt>
mov    $0x1,%ebx
mov    0xc(%rsp),%edi
jmp    15a5 <main+0x3d5>
mov    %r15d,%edi
call   10a0 <WEXITSTATUS@plt>
test   %eax,%eax
je     15bb <main+0x3eb>
mov    0xc(%rsp),%edi
call   1060 <copy@plt>
mov    $0x1,%ebx
mov    0x14(%rsp),%edi
call   1060 <copy@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x14(%rsp),%edi
call   1060 <copy@plt>
xor    %ebx,%ebx
jmp    1581 <main+0x3b1>

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

LLVM IR (-O2):
@.str = [3 x i8] c"@@\00"
@.str.1 = [37 x i8] c"Usage: iwrapper <testee> @@ <tester>\00"
@.str.2 = [9 x i8] c"pipe: %m\00"
@.str.3 = [9 x i8] c"fork: %m\00"
@.str.4 = [9 x i8] c"exec: %m\00"
@.str.5 = [9 x i8] c"wait: %m\00"
@.str.6 = [24 x i8] c"Unknown process %d died\00"
@.str.7 = [25 x i8] c"Sandbox fault, status=%x\00"
@.str.8 = [25 x i8] c"Checker fault, status=%x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = bitcast [2 x i32]* %3 to i8*
%9 = bitcast [2 x i32]* %4 to i8*
%10 = bitcast [2 x i32]* %5 to i8*
%11 = bitcast [2 x i32]* %6 to i8*
%12 = icmp sgt i32 %0, 1
br i1 %12, label %13, label %26
13: ; preds = %2
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %21
%16 = phi i64 [ 1, %13 ], [ %22, %21 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %14
br i1 %23, label %30, label %15
24: ; preds = %15
%25 = trunc i64 %16 to i32
br label %26
26: ; preds = %24, %2
%27 = phi i32 [ 1, %2 ], [ %25, %24 ]
%28 = add nsw i32 %0, -1
%29 = icmp slt i32 %27, %28
br i1 %29, label %33, label %30
30: ; preds = %21, %26
%31 = phi i32 [ %27, %26 ], [ %0, %21 ]
%32 = tail call i32 (i8*, ...) @die(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %30, %26
%34 = phi i32 [ %31, %30 ], [ %27, %26 ]
%35 = add nsw i32 %34, -1
%36 = zext i32 %34 to i64
%37 = shl i32 %34, 3
%38 = tail call i8** @alloca(i32 %37)
%39 = getelementptr inbounds i8*, i8** %1, i64 1
%40 = sext i32 %35 to i64
%41 = shl i32 %35, 3
%42 = tail call i32 @memcpy(i8** %38, i8** %39, i32 %41)
%43 = getelementptr inbounds i8*, i8** %38, i64 %40
store i8* null, i8** %43
%44 = sub nsw i32 %0, %34
%45 = add nsw i32 %44, -1
%46 = shl i32 %44, 3
%47 = tail call i8** @alloca(i32 %46)
%48 = getelementptr inbounds i8*, i8** %1, i64 %36
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = sext i32 %45 to i64
%51 = shl i32 %45, 3
%52 = tail call i32 @memcpy(i8** %47, i8** %49, i32 %51)
%53 = getelementptr inbounds i8*, i8** %47, i64 %50
store i8* null, i8** %53
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%55 = call i64 @pipe(i32* %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %69, label %57
57: ; preds = %33
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%59 = call i64 @pipe(i32* %58)
%60 = icmp slt i64 %59, 0
br i1 %60, label %69, label %61
61: ; preds = %57
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%63 = call i64 @pipe(i32* %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%67 = call i64 @pipe(i32* %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65, %61, %57, %33
%70 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %71
71: ; preds = %69, %65
%72 = call i64 (...) @fork()
%73 = icmp slt i64 %72, 0
br i1 %73, label %111, label %74
74: ; preds = %71
%75 = icmp eq i64 %72, 0
br i1 %75, label %76, label %114
76: ; preds = %74
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = call i32 @close(i32 0)
%81 = load i32, i32* %54
%82 = call i32 @dup(i32 %81)
%83 = load i32, i32* %54
%84 = call i32 @close(i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = call i32 @close(i32 1)
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%90 = load i32, i32* %89
%91 = call i32 @dup(i32 %90)
%92 = load i32, i32* %89
%93 = call i32 @close(i32 %92)
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%95 = load i32, i32* %94
%96 = call i32 @close(i32 %95)
%97 = call i32 @close(i32 2)
%98 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%99 = load i32, i32* %98
%100 = call i32 @dup(i32 %99)
%101 = load i32, i32* %98
%102 = call i32 @close(i32 %101)
%103 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%104 = load i32, i32* %103
%105 = call i32 @close(i32 %104)
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
%109 = load i8*, i8** %38
%110 = call i32 @execv(i8* %109, i8** %38)
br label %111
111: ; preds = %71, %76
%112 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %76 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %71 ]
%113 = call i32 (i8*, ...) @die(i8* %112)
br label %114
114: ; preds = %111, %74
%115 = call i64 (...) @fork()
%116 = icmp slt i64 %115, 0
br i1 %116, label %154, label %117
117: ; preds = %114
%118 = icmp eq i64 %115, 0
br i1 %118, label %119, label %157
119: ; preds = %117
%120 = load i32, i32* %54
%121 = call i32 @close(i32 %120)
%122 = call i32 @close(i32 1)
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%124 = load i32, i32* %123
%125 = call i32 @dup(i32 %124)
%126 = load i32, i32* %123
%127 = call i32 @close(i32 %126)
%128 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%129 = load i32, i32* %128
%130 = call i32 @close(i32 %129)
%131 = call i32 @close(i32 0)
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%133 = load i32, i32* %132
%134 = call i32 @dup(i32 %133)
%135 = load i32, i32* %132
%136 = call i32 @close(i32 %135)
%137 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%138 = load i32, i32* %137
%139 = call i32 @close(i32 %138)
%140 = call i32 @close(i32 2)
%141 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%142 = load i32, i32* %141
%143 = call i32 @dup(i32 %142)
%144 = load i32, i32* %141
%145 = call i32 @close(i32 %144)
%146 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%147 = load i32, i32* %146
%148 = call i32 @close(i32 %147)
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%150 = load i32, i32* %149
%151 = call i32 @close(i32 %150)
%152 = load i8*, i8** %47
%153 = call i32 @execv(i8* %152, i8** %47)
br label %154
154: ; preds = %114, %119
%155 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %119 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %114 ]
%156 = call i32 (i8*, ...) @die(i8* %155)
br label %157
157: ; preds = %154, %117
%158 = load i32, i32* %54
%159 = call i32 @close(i32 %158)
%160 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%161 = load i32, i32* %160
%162 = call i32 @close(i32 %161)
%163 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%164 = load i32, i32* %163
%165 = call i32 @close(i32 %164)
%166 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%167 = load i32, i32* %166
%168 = call i32 @close(i32 %167)
%169 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%170 = load i32, i32* %169
%171 = call i32 @close(i32 %170)
%172 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%173 = load i32, i32* %172
%174 = call i32 @close(i32 %173)
%175 = bitcast i32* %7 to i8*
br label %176
176: ; preds = %157, %196
%177 = phi i32 [ 0, %157 ], [ %199, %196 ]
%178 = phi i32 [ 0, %157 ], [ %198, %196 ]
%179 = phi i32 [ 0, %157 ], [ %197, %196 ]
%180 = call i64 @wait(i32* %7)
%181 = icmp slt i64 %180, 0
br i1 %181, label %182, label %184
182: ; preds = %176
%183 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %184
184: ; preds = %182, %176
%185 = icmp eq i64 %180, %72
br i1 %185, label %186, label %189
186: ; preds = %184
%187 = or i32 %179, 1
%188 = load i32, i32* %7
br label %196
189: ; preds = %184
%190 = icmp eq i64 %180, %115
br i1 %190, label %191, label %194
191: ; preds = %189
%192 = or i32 %179, 2
%193 = load i32, i32* %7
br label %196
194: ; preds = %189
%195 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i64 %180)
br label %196
196: ; preds = %191, %194, %186
%197 = phi i32 [ %187, %186 ], [ %192, %191 ], [ %179, %194 ]
%198 = phi i32 [ %188, %186 ], [ %178, %191 ], [ %178, %194 ]
%199 = phi i32 [ %177, %186 ], [ %193, %191 ], [ %177, %194 ]
%200 = icmp eq i32 %197, 3
br i1 %200, label %201, label %176
201: ; preds = %196
%202 = call i32 @WIFEXITED(i32 %198)
%203 = icmp eq i32 %202, 0
br i1 %203, label %204, label %206
204: ; preds = %201
%205 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %198)
br label %206
206: ; preds = %204, %201
%207 = call i32 @WIFEXITED(i32 %199)
%208 = icmp eq i32 %207, 0
br i1 %208, label %212, label %209
209: ; preds = %206
%210 = call i32 @WEXITSTATUS(i32 %199)
%211 = icmp sgt i32 %210, 99
br i1 %211, label %212, label %214
212: ; preds = %209, %206
%213 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %199)
br label %214
214: ; preds = %212, %209
%215 = call i32 @WEXITSTATUS(i32 %198)
%216 = icmp eq i32 %215, 0
br i1 %216, label %223, label %217
217: ; preds = %214
%218 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%219 = load i32, i32* %218
%220 = call i32 @copy(i32 %219)
%221 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%222 = load i32, i32* %221
br label %238
223: ; preds = %214
%224 = call i32 @WEXITSTATUS(i32 %199)
%225 = icmp eq i32 %224, 0
br i1 %225, label %232, label %226
226: ; preds = %223
%227 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%228 = load i32, i32* %227
%229 = call i32 @copy(i32 %228)
%230 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%231 = load i32, i32* %230
br label %238
232: ; preds = %223
%233 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%234 = load i32, i32* %233
%235 = call i32 @copy(i32 %234)
%236 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%237 = load i32, i32* %236
br label %238
238: ; preds = %232, %226, %217
%239 = phi i32 [ %237, %232 ], [ %231, %226 ], [ %222, %217 ]
%240 = phi i32 [ 0, %232 ], [ 1, %226 ], [ 1, %217 ]
%241 = call i32 @copy(i32 %239)
ret i32 %240
}