#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*/ client(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ server(int, int);
int /*<<< orphan*/ wait(int *);
int main() {
  int pipe1[2], pipe2[2];
  int childpid, status;
  pipe(pipe1);
  pipe(pipe2);
  childpid = fork();
  if (childpid > 0) {
    close(pipe1[0]);
    close(pipe2[1]);
    client(pipe2[0], pipe1[1]);
    wait(&status);
    exit(0);
  } else {
    close(pipe1[1]);
    close(pipe2[0]);
    server(pipe1[0], pipe2[1]);
    exit(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   1090 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11d0 <main+0x60>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <client@plt>
lea    -0x1c(%rbp),%rdi
call   1080 <wait@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <server@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdi
call   1040 <pipe@plt>
lea    0x4(%rsp),%rdi
call   1040 <pipe@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jle    11c3 <main+0x53>
mov    0xc(%rsp),%edi
call   1030 <close@plt>
mov    0x8(%rsp),%edi
call   1030 <close@plt>
mov    0x4(%rsp),%edi
mov    0x10(%rsp),%esi
call   1060 <client@plt>
lea    0x14(%rsp),%rdi
call   1080 <wait@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x10(%rsp),%edi
call   1030 <close@plt>
mov    0x4(%rsp),%edi
call   1030 <close@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1050 <server@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = call i32 @pipe(i32* %6)
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%9 = call i32 @pipe(i32* %8)
%10 = call i32 (...) @fork()
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%15 = load i32, i32* %14
%16 = call i32 @close(i32 %15)
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%18 = load i32, i32* %17
%19 = call i32 @close(i32 %18)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%23 = load i32, i32* %22
%24 = call i32 @client(i32 %21, i32 %23)
%25 = call i32 @wait(i32* %5)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %0
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%32 = load i32, i32* %31
%33 = call i32 @close(i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%35 = load i32, i32* %34
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%37 = load i32, i32* %36
%38 = call i32 @server(i32 %35, i32 %37)
%39 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = bitcast [2 x i32]* %1 to i8*
%5 = bitcast [2 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i32 @pipe(i32* %7)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
%11 = call i32 (...) @fork()
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %0
%14 = load i32, i32* %7
%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 @close(i32 %17)
%19 = load i32, i32* %9
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%21 = load i32, i32* %20
%22 = call i32 @client(i32 %19, i32 %21)
%23 = call i32 @wait(i32* %3)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %0
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %9
%30 = call i32 @close(i32 %29)
%31 = load i32, i32* %7
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @server(i32 %31, i32 %33)
%35 = call i32 @exit(i32 0)
unreachable
}