#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 /*<<< orphan*/ child(int *, int *);
int /*<<< orphan*/ father(int *, int *);
scalar_t__ fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ wait(void *);
int main() {
  int fd1[2], fd2[2];
  pid_t pid;
  pipe(fd1);
  pipe(fd2);
  pid = fork();
  if (pid == 0) {
    child(fd1, fd2);
  } else {
    father(fd1, fd2);
  }
  wait((void *)0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <pipe@plt>
lea    -0x14(%rbp),%rdi
call   1040 <pipe@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1199 <main+0x49>
lea    -0xc(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <child@plt>
jmp    11a6 <main+0x56>
lea    -0xc(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <father@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
call   1040 <pipe@plt>
lea    0x8(%rsp),%rdi
call   1040 <pipe@plt>
xor    %eax,%eax
call   1070 <fork@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
test   %rax,%rax
je     1185 <main+0x35>
call   1050 <father@plt>
jmp    118a <main+0x3a>
call   1030 <child@plt>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i64
store i32 0, i32* %1
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%8 = call i32 @pipe(i32* %7)
%9 = call i64 (...) @fork()
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = call i32 @child(i32* %13, i32* %14)
br label %20
16: ; preds = %0
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%19 = call i32 @father(i32* %17, i32* %18)
br label %20
20: ; preds = %16, %12
%21 = call i32 @wait(i8* null)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = bitcast [2 x i32]* %2 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%8 = call i32 @pipe(i32* %7)
%9 = call i64 (...) @fork()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @child(i32* %5, i32* %7)
br label %15
13: ; preds = %0
%14 = call i32 @father(i32* %5, i32* %7)
br label %15
15: ; preds = %13, %11
%16 = call i32 @wait(i8* null)
ret i32 0
}