#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int STDOUT_FILENO;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
scalar_t__ read(int, char *, int);
int strlen(char *);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int i;
  int pfd[10][2];
  pid_t cpid[10];
  char buf;
  assert(argc == 2);
  for (i = 0; i < 10; i++) {
    if (pipe(pfd[i]) == -1) {
      perror("pipe");
      exit(EXIT_FAILURE);
    }
    cpid[i] = fork();
    if (cpid[i] == -1) {
      perror("fork");
      exit(EXIT_FAILURE);
    }
    if (cpid[i] == 0) {
      close(pfd[i][1]);
      while (read(pfd[i][0], &buf, 1) > 0)
        write(STDOUT_FILENO, &buf, 1);
      write(STDOUT_FILENO, "\n", 1);
      close(pfd[i][0]);
      _exit(EXIT_SUCCESS);
    } else {
      close(pfd[i][0]);
    }
  }
  for (i = 0; i < 10; i++) {
    write(pfd[i][1], argv[1], strlen(argv[1]));
    close(pfd[i][1]);
  }
  for (i = 0; i < 10; i++) {
    waitpid(cpid[i], NULL, 0);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1318 <main+0x168>
movslq -0x14(%rbp),%rax
lea    -0x70(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1222 <main+0x72>
lea    0xdf1(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0xa0(%rbp,%rax,4)
movslq -0x14(%rbp),%rax
cmpl   $0xffffffff,-0xa0(%rbp,%rax,4)
ff
jne    1262 <main+0xb2>
lea    0xdb6(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movslq -0x14(%rbp),%rax
cmpl   $0x0,-0xa0(%rbp,%rax,4)
jne    12f8 <main+0x148>
movslq -0x14(%rbp),%rax
mov    -0x6c(%rbp,%rax,8),%edi
call   1060 <close@plt>
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%edi
lea    -0xa1(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jle    12c3 <main+0x113>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    -0xa1(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    1281 <main+0xd1>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%edi
call   1060 <close@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%edi
call   1060 <close@plt>
jmp    130a <main+0x15a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e1 <main+0x31>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1382 <main+0x1d2>
movslq -0x14(%rbp),%rax
mov    -0x6c(%rbp,%rax,8),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
movslq -0x14(%rbp),%rax
mov    -0x6c(%rbp,%rax,8),%edi
call   1060 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    131f <main+0x16f>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    13b7 <main+0x207>
movslq -0x14(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1389 <main+0x1d9>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
mov    %eax,%edi
call   1090 <assert@plt>
lea    0x20(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    11eb <main+0x3b>
lea    0xe17(%rip),%rdi
jmp    1207 <main+0x57>
xor    %r12d,%r12d
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1252 <main+0xa2>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    121a <main+0x6a>
lea    0xdfe(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x20(%rsp),%edi
call   1060 <close@plt>
lea    0x28(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    %eax,%r14d
mov    $0x1,%r12d
test   %eax,%eax
jne    12d7 <main+0x127>
mov    0x24(%rsp,%r12,8),%edi
call   1060 <close@plt>
mov    0x0(%r13),%edi
lea    0xb(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    12a6 <main+0xf6>
mov    0x2d75(%rip),%rbp
lea    0xb(%rsp),%rbx
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0x0(%r13),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
test   %rax,%rax
jg     1280 <main+0xd0>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0x0(%r13),%edi
call   1060 <close@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    0x28(%rsp),%edi
call   1060 <close@plt>
lea    0x30(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    %eax,%r15d
mov    $0x2,%r12d
test   %eax,%eax
je     1252 <main+0xa2>
mov    0x30(%rsp),%edi
call   1060 <close@plt>
lea    0x38(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x3,%r12d
test   %eax,%eax
je     1252 <main+0xa2>
mov    %eax,0x74(%rsp)
mov    0x38(%rsp),%edi
call   1060 <close@plt>
lea    0x40(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x4,%r12d
test   %eax,%eax
je     1252 <main+0xa2>
mov    %eax,0x70(%rsp)
mov    0x40(%rsp),%edi
call   1060 <close@plt>
lea    0x48(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,0x1c(%rsp)
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x5,%r12d
cmpl   $0x0,0x1c(%rsp)
je     1252 <main+0xa2>
mov    0x48(%rsp),%edi
call   1060 <close@plt>
lea    0x50(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,0x18(%rsp)
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x6,%r12d
cmpl   $0x0,0x18(%rsp)
je     1252 <main+0xa2>
mov    0x50(%rsp),%edi
call   1060 <close@plt>
lea    0x58(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,0x14(%rsp)
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x7,%r12d
cmpl   $0x0,0x14(%rsp)
je     1252 <main+0xa2>
mov    0x58(%rsp),%edi
call   1060 <close@plt>
lea    0x60(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,0x10(%rsp)
cmp    $0xffffffff,%eax
je     1200 <main+0x50>
mov    $0x8,%r12d
cmpl   $0x0,0x10(%rsp)
je     1252 <main+0xa2>
mov    0x60(%rsp),%edi
call   1060 <close@plt>
lea    0x68(%rsp),%r13
mov    %r13,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     11e2 <main+0x32>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
mov    0x74(%rsp),%eax
je     1200 <main+0x50>
mov    $0x9,%r12d
cmpl   $0x0,0xc(%rsp)
je     1252 <main+0xa2>
mov    0x68(%rsp),%edi
mov    %eax,%r12d
call   1060 <close@plt>
mov    0x24(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x24(%rsp),%edi
call   1060 <close@plt>
mov    0x2c(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x2c(%rsp),%edi
call   1060 <close@plt>
mov    0x34(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x34(%rsp),%edi
call   1060 <close@plt>
mov    0x3c(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x3c(%rsp),%edi
call   1060 <close@plt>
mov    0x44(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x44(%rsp),%edi
call   1060 <close@plt>
mov    0x4c(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x4c(%rsp),%edi
call   1060 <close@plt>
mov    0x54(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x54(%rsp),%edi
call   1060 <close@plt>
mov    0x5c(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x5c(%rsp),%edi
call   1060 <close@plt>
mov    0x64(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x64(%rsp),%edi
call   1060 <close@plt>
mov    0x6c(%rsp),%r13d
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x6c(%rsp),%edi
call   1060 <close@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    %r12d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x70(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x1c(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x18(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x14(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x10(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    0x28a5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"fork\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x [2 x i32]]
%8 = alloca [10 x i32]
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* %6
br label %14
14: ; preds = %85, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %88
17: ; preds = %14
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %19
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %20, i64 0, i64 0
%22 = call i32 @pipe(i32* %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = call i32 (...) @fork()
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %31
store i32 %29, i32* %32
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %42
38: ; preds = %28
%39 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %28
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %77
48: ; preds = %42
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %50
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %51, i64 0, i64 1
%53 = load i32, i32* %52
%54 = call i32 @close(i32 %53)
br label %55
55: ; preds = %63, %48
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %57
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %58, i64 0, i64 0
%60 = load i32, i32* %59
%61 = call i64 @read(i32 %60, i8* %9, i32 1)
%62 = icmp sgt i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = load i32, i32* @STDOUT_FILENO
%65 = call i32 @write(i32 %64, i8* %9, i32 1)
br label %55
66: ; preds = %55
%67 = load i32, i32* @STDOUT_FILENO
%68 = call i32 @write(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %70
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %71, i64 0, i64 0
%73 = load i32, i32* %72
%74 = call i32 @close(i32 %73)
%75 = load i32, i32* @EXIT_SUCCESS
%76 = call i32 @_exit(i32 %75)
unreachable
77: ; preds = %42
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %79
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %80, i64 0, i64 0
%82 = load i32, i32* %81
%83 = call i32 @close(i32 %82)
br label %84
84: ; preds = %77
br label %85
85: ; preds = %84
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
br label %14
88: ; preds = %14
store i32 0, i32* %6
br label %89
89: ; preds = %112, %88
%90 = load i32, i32* %6
%91 = icmp slt i32 %90, 10
br i1 %91, label %92, label %115
92: ; preds = %89
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %94
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %95, i64 0, i64 1
%97 = load i32, i32* %96
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 1
%100 = load i8*, i8** %99
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 1
%103 = load i8*, i8** %102
%104 = call i32 @strlen(i8* %103)
%105 = call i32 @write(i32 %97, i8* %100, i32 %104)
%106 = load i32, i32* %6
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [10 x [2 x i32]], [10 x [2 x i32]]* %7, i64 0, i64 %107
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %108, i64 0, i64 1
%110 = load i32, i32* %109
%111 = call i32 @close(i32 %110)
br label %112
112: ; preds = %92
%113 = load i32, i32* %6
%114 = add nsw i32 %113, 1
store i32 %114, i32* %6
br label %89
115: ; preds = %89
store i32 0, i32* %6
br label %116
116: ; preds = %125, %115
%117 = load i32, i32* %6
%118 = icmp slt i32 %117, 10
br i1 %118, label %119, label %128
119: ; preds = %116
%120 = load i32, i32* %6
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %121
%123 = load i32, i32* %122
%124 = call i32 @waitpid(i32 %123, i32* null, i32 0)
br label %125
125: ; preds = %119
%126 = load i32, i32* %6
%127 = add nsw i32 %126, 1
store i32 %127, i32* %6
br label %116
128: ; preds = %116
%129 = load i32, i32* @EXIT_SUCCESS
%130 = call i32 @exit(i32 %129)
unreachable
}

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