#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*/ AF_UNIX;
int EXIT_SUCCESS;
int /*<<< orphan*/ PF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ be_bc(int *);
int /*<<< orphan*/ be_dc(int *);
scalar_t__ fork();
int /*<<< orphan*/ socketpair(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  int p[2];
  socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p);
  if (fork() == 0) {
    be_dc(p);
  } else {
    be_bc(p);
    wait(NULL);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
call   1040 <socketpair@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    11a2 <main+0x52>
lea    -0xc(%rbp),%rdi
call   1050 <be_dc@plt>
jmp    11b4 <main+0x64>
lea    -0xc(%rbp),%rdi
call   1030 <be_bc@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
call   1040 <socketpair@plt>
xor    %eax,%eax
call   1070 <fork@plt>
mov    %rsp,%rdi
test   %rax,%rax
je     1191 <main+0x41>
call   1030 <be_bc@plt>
xor    %edi,%edi
call   1060 <wait@plt>
jmp    1196 <main+0x46>
call   1050 <be_dc@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@PF_UNSPEC = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
store i32 0, i32* %1
%3 = load i32, i32* @AF_UNIX
%4 = load i32, i32* @SOCK_STREAM
%5 = load i32, i32* @PF_UNSPEC
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = call i32 @socketpair(i32 %3, i32 %4, i32 %5, i32* %6)
%8 = call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = call i32 @be_dc(i32* %11)
br label %17
13: ; preds = %0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%15 = call i32 @be_bc(i32* %14)
%16 = call i32 @wait(i32* null)
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

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