#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*/ execl(char *, char *, int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  int fd[2];
  pipe(fd);
  if (fork())
    ;
  else {
    if (fork()) {
      close(fd[0]);
      dup2(fd[1], 1);
      close(fd[1]);
      execl("./rnd.o", "rnd.o", NULL);
    } else {
      close(fd[1]);
      dup2(fd[0], 0);
      close(fd[0]);
      execl("./16zn.o", "16zn.o", NULL);
    }
  }
  for (int i = 0; i < 2; i++)
    wait(NULL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <pipe@plt>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
je     118e <main+0x2e>
jmp    120e <main+0xae>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
je     11d8 <main+0x78>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
lea    0xe3d(%rip),%rdi
lea    0xe38(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
jmp    1209 <main+0xa9>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
lea    0xe0f(%rip),%rdi
lea    0xe0a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
jmp    120e <main+0xae>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    1236 <main+0xd6>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1215 <main+0xb5>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
call   1050 <pipe@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11b0 <main+0x50>
mov    (%rsp),%edi
call   1040 <close@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
lea    0xe59(%rip),%rdi
lea    0xe54(%rip),%rsi
jmp    11d9 <main+0x79>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
mov    (%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    (%rsp),%edi
call   1040 <close@plt>
lea    0xe36(%rip),%rdi
lea    0xe31(%rip),%rsi
xor    %edx,%edx
call   1060 <execl@plt>
xor    %edi,%edi
call   1070 <wait@plt>
xor    %edi,%edi
call   1070 <wait@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"./rnd.o\00"
@.str.1 = [6 x i8] c"rnd.o\00"
@.str.2 = [9 x i8] c"./16zn.o\00"
@.str.3 = [7 x i8] c"16zn.o\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%5 = call i32 @pipe(i32* %4)
%6 = call i64 (...) @fork()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
br label %35
9: ; preds = %0
%10 = call i64 (...) @fork()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%14 = load i32, i32* %13
%15 = call i32 @close(i32 %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 @dup2(i32 %17, i32 1)
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%20 = load i32, i32* %19
%21 = call i32 @close(i32 %20)
%22 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %34
23: ; preds = %9
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%25 = load i32, i32* %24
%26 = call i32 @close(i32 %25)
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %27
%29 = call i32 @dup2(i32 %28, i32 0)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%31 = load i32, i32* %30
%32 = call i32 @close(i32 %31)
%33 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %34
34: ; preds = %23, %12
br label %35
35: ; preds = %34, %8
store i32 0, i32* %3
br label %36
36: ; preds = %41, %35
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 2
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = call i32 @wait(i32* null)
br label %41
41: ; preds = %39
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %36
44: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"./rnd.o\00"
@.str.1 = [6 x i8] c"rnd.o\00"
@.str.2 = [9 x i8] c"./16zn.o\00"
@.str.3 = [7 x i8] c"16zn.o\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i32 @pipe(i32* %3)
%5 = call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %0
%8 = call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = call i32 @close(i32 %11)
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%14 = load i32, i32* %13
%15 = call i32 @dup2(i32 %14, i32 1)
%16 = load i32, i32* %13
%17 = call i32 @close(i32 %16)
%18 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %28
19: ; preds = %7
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%21 = load i32, i32* %20
%22 = call i32 @close(i32 %21)
%23 = load i32, i32* %3
%24 = call i32 @dup2(i32 %23, i32 0)
%25 = load i32, i32* %3
%26 = call i32 @close(i32 %25)
%27 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %28
28: ; preds = %10, %19, %0
%29 = call i32 @wait(i32* null)
%30 = call i32 @wait(i32* null)
ret i32 0
}