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

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int st, pid;
  int fd1[2], fd2[2];
  if (pipe(fd1) < 0 || pipe(fd2) < 0) {
    fprintf(stderr, "pipe failed\n");
    exit(0);
  }
  if ((pid = fork()) == 0) {
    dup2(fd2[0], 0);
    close(fd2[0]);
    close(fd2[1]);
    close(fd1[0]);
    close(fd1[1]);
    execlp(argv[4], argv[4], NULL);
    fprintf(stderr, "exec in pr4 failed\n");
    exit(0);
  } else if (pid == -1) {
    fprintf(stderr, "first fork failed\n");
    exit(0);
  }
  if ((pid = fork()) == 0) {
    dup2(fd1[1], 1);
    close(fd1[0]);
    close(fd1[1]);
    close(fd2[0]);
    close(fd2[1]);
    execlp(argv[1], argv[1], NULL);
    fprintf(stderr, "exec in pr1 failed\n");
    exit(0);
  } else if (pid == -1) {
    fprintf(stderr, "second fork failed\n");
    exit(0);
  }
  if ((pid = fork()) == 0) {
    dup2(fd2[1], 1);
    dup2(fd1[0], 0);
    close(fd2[0]);
    close(fd2[1]);
    close(fd1[0]);
    close(fd1[1]);
    execlp(argv[2], argv[2], NULL);
    fprintf(stderr, "exec in pr2 failed\n");
    exit(0);
  } else if (pid == -1) {
    fprintf(stderr, "third fork failed\n");
    exit(0);
  }
  if ((pid = fork()) == 0) {
    dup2(fd2[1], 1);
    dup2(fd1[0], 0);
    close(fd2[0]);
    close(fd2[1]);
    close(fd1[0]);
    close(fd1[1]);
    execlp(argv[3], argv[3], NULL);
    fprintf(stderr, "exec in pr3 failed\n");
    exit(0);
  } else if (pid == -1) {
    fprintf(stderr, "fourth fork failed\n");
    exit(0);
  }
  close(fd1[0]);
  close(fd1[1]);
  close(fd2[0]);
  close(fd2[1]);
  wait(&st);
  wait(&st);
  wait(&st);
  wait(&st);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jl     11bc <main+0x3c>
lea    -0x28(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jge    11d8 <main+0x58>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    124a <main+0xca>
mov    -0x28(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1270 <main+0xf0>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1275 <main+0xf5>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    12ea <main+0x16a>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1310 <main+0x190>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1315 <main+0x195>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    1394 <main+0x214>
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x20(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
lea    0xcd4(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    13ba <main+0x23a>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    13bf <main+0x23f>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    143e <main+0x2be>
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x20(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
lea    0xc51(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1464 <main+0x2e4>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
lea    0xc3f(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1469 <main+0x2e9>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
lea    -0x14(%rbp),%rdi
call   1090 <wait@plt>
lea    -0x14(%rbp),%rdi
call   1090 <wait@plt>
lea    -0x14(%rbp),%rdi
call   1090 <wait@plt>
lea    -0x14(%rbp),%rdi
call   1090 <wait@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0x14(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     125f <main+0xdf>
lea    0xc(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     125f <main+0xdf>
xor    %eax,%eax
call   10a0 <fork@plt>
cmp    $0xffffffff,%eax
je     1274 <main+0xf4>
test   %eax,%eax
je     1289 <main+0x109>
xor    %eax,%eax
call   10a0 <fork@plt>
cmp    $0xffffffff,%eax
je     12db <main+0x15b>
test   %eax,%eax
je     12f0 <main+0x170>
xor    %eax,%eax
call   10a0 <fork@plt>
cmp    $0xffffffff,%eax
je     1345 <main+0x1c5>
test   %eax,%eax
je     135a <main+0x1da>
xor    %eax,%eax
call   10a0 <fork@plt>
cmp    $0xffffffff,%eax
je     13b7 <main+0x237>
test   %eax,%eax
je     13c9 <main+0x249>
mov    0x14(%rsp),%edi
call   1040 <close@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>
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <wait@plt>
mov    %rbx,%rdi
call   1090 <wait@plt>
mov    %rbx,%rdi
call   1090 <wait@plt>
mov    %rbx,%rdi
call   1090 <wait@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    0xc(%rsp),%edi
call   1040 <close@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    0x20(%rbx),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x18(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x14(%rsp),%edi
call   1040 <close@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    0x8(%rbx),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x10(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x14(%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    0xc(%rsp),%edi
call   1040 <close@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    0x10(%rbx),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xca7(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
lea    0xcd0(%rip),%rsi
jmp    1424 <main+0x2a4>
mov    0x10(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x14(%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    0xc(%rsp),%edi
call   1040 <close@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    0x18(%rbx),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    0xc5f(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"pipe failed\0A\00"
@.str.1 = [20 x i8] c"exec in pr4 failed\0A\00"
@.str.2 = [19 x i8] c"first fork failed\0A\00"
@.str.3 = [20 x i8] c"exec in pr1 failed\0A\00"
@.str.4 = [20 x i8] c"second fork failed\0A\00"
@.str.5 = [20 x i8] c"exec in pr2 failed\0A\00"
@.str.6 = [19 x i8] c"third fork failed\0A\00"
@.str.7 = [20 x i8] c"exec in pr3 failed\0A\00"
@.str.8 = [20 x i8] c"fourth fork failed\0A\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 [2 x i32]
%9 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%11 = call i64 @pipe(i32* %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%15 = call i64 @pipe(i32* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13, %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %13
%22 = call i32 (...) @fork()
store i32 %22, i32* %7
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %50
24: ; preds = %21
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%26 = load i32, i32* %25
%27 = call i32 @dup2(i32 %26, i32 0)
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%32 = load i32, i32* %31
%33 = call i32 @close(i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%35 = load i32, i32* %34
%36 = call i32 @close(i32 %35)
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%38 = load i32, i32* %37
%39 = call i32 @close(i32 %38)
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 4
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 4
%45 = load i8*, i8** %44
%46 = call i32 @execlp(i8* %42, i8* %45, i32* null)
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %21
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %50
br label %58
58: ; preds = %57
%59 = call i32 (...) @fork()
store i32 %59, i32* %7
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %87
61: ; preds = %58
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%63 = load i32, i32* %62
%64 = call i32 @dup2(i32 %63, i32 1)
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%66 = load i32, i32* %65
%67 = call i32 @close(i32 %66)
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 1
%82 = load i8*, i8** %81
%83 = call i32 @execlp(i8* %79, i8* %82, i32* null)
%84 = load i32, i32* @stderr
%85 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%86 = call i32 @exit(i32 0)
unreachable
87: ; preds = %58
%88 = load i32, i32* %7
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = call i32 @fprintf(i32 %91, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%93 = call i32 @exit(i32 0)
unreachable
94: ; preds = %87
br label %95
95: ; preds = %94
%96 = call i32 (...) @fork()
store i32 %96, i32* %7
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %127
98: ; preds = %95
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%100 = load i32, i32* %99
%101 = call i32 @dup2(i32 %100, i32 1)
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%103 = load i32, i32* %102
%104 = call i32 @dup2(i32 %103, i32 0)
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%106 = load i32, i32* %105
%107 = call i32 @close(i32 %106)
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%109 = load i32, i32* %108
%110 = call i32 @close(i32 %109)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
%117 = load i8**, i8*** %5
%118 = getelementptr inbounds i8*, i8** %117, i64 2
%119 = load i8*, i8** %118
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 2
%122 = load i8*, i8** %121
%123 = call i32 @execlp(i8* %119, i8* %122, i32* null)
%124 = load i32, i32* @stderr
%125 = call i32 @fprintf(i32 %124, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%126 = call i32 @exit(i32 0)
unreachable
127: ; preds = %95
%128 = load i32, i32* %7
%129 = icmp eq i32 %128, -1
br i1 %129, label %130, label %134
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = call i32 @fprintf(i32 %131, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%133 = call i32 @exit(i32 0)
unreachable
134: ; preds = %127
br label %135
135: ; preds = %134
%136 = call i32 (...) @fork()
store i32 %136, i32* %7
%137 = icmp eq i32 %136, 0
br i1 %137, label %138, label %167
138: ; preds = %135
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%140 = load i32, i32* %139
%141 = call i32 @dup2(i32 %140, i32 1)
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%143 = load i32, i32* %142
%144 = call i32 @dup2(i32 %143, i32 0)
%145 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%146 = load i32, i32* %145
%147 = call i32 @close(i32 %146)
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%149 = load i32, i32* %148
%150 = call i32 @close(i32 %149)
%151 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%152 = load i32, i32* %151
%153 = call i32 @close(i32 %152)
%154 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%155 = load i32, i32* %154
%156 = call i32 @close(i32 %155)
%157 = load i8**, i8*** %5
%158 = getelementptr inbounds i8*, i8** %157, i64 3
%159 = load i8*, i8** %158
%160 = load i8**, i8*** %5
%161 = getelementptr inbounds i8*, i8** %160, i64 3
%162 = load i8*, i8** %161
%163 = call i32 @execlp(i8* %159, i8* %162, i32* null)
%164 = load i32, i32* @stderr
%165 = call i32 @fprintf(i32 %164, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%166 = call i32 @exit(i32 0)
unreachable
167: ; preds = %135
%168 = load i32, i32* %7
%169 = icmp eq i32 %168, -1
br i1 %169, label %170, label %174
170: ; preds = %167
%171 = load i32, i32* @stderr
%172 = call i32 @fprintf(i32 %171, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%173 = call i32 @exit(i32 0)
unreachable
174: ; preds = %167
br label %175
175: ; preds = %174
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%177 = load i32, i32* %176
%178 = call i32 @close(i32 %177)
%179 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%180 = load i32, i32* %179
%181 = call i32 @close(i32 %180)
%182 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%183 = load i32, i32* %182
%184 = call i32 @close(i32 %183)
%185 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%186 = load i32, i32* %185
%187 = call i32 @close(i32 %186)
%188 = call i32 @wait(i32* %6)
%189 = call i32 @wait(i32* %6)
%190 = call i32 @wait(i32* %6)
%191 = call i32 @wait(i32* %6)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"pipe failed\0A\00"
@.str.1 = [20 x i8] c"exec in pr4 failed\0A\00"
@.str.2 = [19 x i8] c"first fork failed\0A\00"
@.str.3 = [20 x i8] c"exec in pr1 failed\0A\00"
@.str.4 = [20 x i8] c"second fork failed\0A\00"
@.str.5 = [20 x i8] c"exec in pr2 failed\0A\00"
@.str.6 = [19 x i8] c"third fork failed\0A\00"
@.str.7 = [20 x i8] c"exec in pr3 failed\0A\00"
@.str.8 = [20 x i8] c"fourth fork failed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [2 x i32]* %4 to i8*
%8 = bitcast [2 x i32]* %5 to i8*
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%10 = call i64 @pipe(i32* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%14 = call i64 @pipe(i32* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12, %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %12
%21 = call i32 (...) @fork()
switch i32 %21, label %45 [
i32 0, label %22
i32 -1, label %41
]
22: ; preds = %20
%23 = load i32, i32* %13
%24 = call i32 @dup2(i32 %23, i32 0)
%25 = load i32, i32* %13
%26 = call i32 @close(i32 %25)
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* %9
%31 = call i32 @close(i32 %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @execlp(i8* %36, i8* %36, i32* null)
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %20
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %20
%46 = call i32 (...) @fork()
switch i32 %46, label %70 [
i32 0, label %47
i32 -1, label %66
]
47: ; preds = %45
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%49 = load i32, i32* %48
%50 = call i32 @dup2(i32 %49, i32 1)
%51 = load i32, i32* %9
%52 = call i32 @close(i32 %51)
%53 = load i32, i32* %48
%54 = call i32 @close(i32 %53)
%55 = load i32, i32* %13
%56 = call i32 @close(i32 %55)
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%58 = load i32, i32* %57
%59 = call i32 @close(i32 %58)
%60 = getelementptr inbounds i8*, i8** %1, i64 1
%61 = load i8*, i8** %60
%62 = call i32 @execlp(i8* %61, i8* %61, i32* null)
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %45
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %45
%71 = call i32 (...) @fork()
switch i32 %71, label %97 [
i32 0, label %72
i32 -1, label %93
]
72: ; preds = %70
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%74 = load i32, i32* %73
%75 = call i32 @dup2(i32 %74, i32 1)
%76 = load i32, i32* %9
%77 = call i32 @dup2(i32 %76, i32 0)
%78 = load i32, i32* %13
%79 = call i32 @close(i32 %78)
%80 = load i32, i32* %73
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %9
%83 = call i32 @close(i32 %82)
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%85 = load i32, i32* %84
%86 = call i32 @close(i32 %85)
%87 = getelementptr inbounds i8*, i8** %1, i64 2
%88 = load i8*, i8** %87
%89 = call i32 @execlp(i8* %88, i8* %88, i32* null)
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%92 = call i32 @exit(i32 0)
unreachable
93: ; preds = %70
%94 = load i32, i32* @stderr
%95 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%96 = call i32 @exit(i32 0)
unreachable
97: ; preds = %70
%98 = call i32 (...) @fork()
switch i32 %98, label %124 [
i32 0, label %99
i32 -1, label %120
]
99: ; preds = %97
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @dup2(i32 %101, i32 1)
%103 = load i32, i32* %9
%104 = call i32 @dup2(i32 %103, i32 0)
%105 = load i32, i32* %13
%106 = call i32 @close(i32 %105)
%107 = load i32, i32* %100
%108 = call i32 @close(i32 %107)
%109 = load i32, i32* %9
%110 = call i32 @close(i32 %109)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds i8*, i8** %1, i64 3
%115 = load i8*, i8** %114
%116 = call i32 @execlp(i8* %115, i8* %115, i32* null)
%117 = load i32, i32* @stderr
%118 = call i32 @fprintf(i32 %117, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%119 = call i32 @exit(i32 0)
unreachable
120: ; preds = %97
%121 = load i32, i32* @stderr
%122 = call i32 @fprintf(i32 %121, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%123 = call i32 @exit(i32 0)
unreachable
124: ; preds = %97
%125 = load i32, i32* %9
%126 = call i32 @close(i32 %125)
%127 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%128 = load i32, i32* %127
%129 = call i32 @close(i32 %128)
%130 = load i32, i32* %13
%131 = call i32 @close(i32 %130)
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%133 = load i32, i32* %132
%134 = call i32 @close(i32 %133)
%135 = call i32 @wait(i32* %3)
%136 = call i32 @wait(i32* %3)
%137 = call i32 @wait(i32* %3)
%138 = call i32 @wait(i32* %3)
ret i32 0
}