#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 /*<<< orphan*/ pids;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ bidi_loop();
int /*<<< orphan*/ client_loop();
scalar_t__ fork();
int /*<<< orphan*/ mb_socket_name(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ status_loop();
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(int argc __attribute__((unused)),
         char **argv __attribute__((unused))) {
  unsigned int i = 0;
  pid_t pids[1];
  pid_t status = fork();
  pid_t bidi;
  char buffer[1024];
  if (status == 0)
    status_loop();
  bidi = fork();
  if (bidi == 0)
    bidi_loop();
  for (; i < sizeof(pids) / sizeof(pids[0]); i++) {
    pid_t pid = 0;
    if (pid == 0) {
      client_loop();
    }
    pids[i] = pid;
  }
  for (i = 0; i < sizeof(pids) / sizeof(pids[0]); i++)
    wait(NULL);
  waitpid(status, NULL, 0);
  waitpid(bidi, NULL, 0);
  mb_socket_name(buffer, 1024);
  printf("%s\n", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bd <main+0x3d>
mov    $0x0,%al
call   1060 <status_loop@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11da <main+0x5a>
mov    $0x0,%al
call   1070 <bidi_loop@plt>
jmp    11df <main+0x5f>
mov    -0x14(%rbp),%eax
cmp    $0x1,%rax
jae    1229 <main+0xa9>
movq   $0x0,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
jne    120c <main+0x8c>
mov    $0x0,%al
call   1030 <client_loop@plt>
mov    -0x438(%rbp),%rcx
mov    -0x14(%rbp),%eax
mov    %rcx,-0x20(%rbp,%rax,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11df <main+0x5f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    $0x1,%rax
jae    1254 <main+0xd4>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <wait@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1230 <main+0xb0>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
call   1080 <mb_socket_name@plt>
lea    -0x430(%rbp),%rsi
lea    0xd6f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a0 <main+0x20>
xor    %eax,%eax
call   1060 <status_loop@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b6 <main+0x36>
xor    %eax,%eax
call   1070 <bidi_loop@plt>
xor    %eax,%eax
call   1030 <client_loop@plt>
xor    %edi,%edi
call   1090 <wait@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1080 <mb_socket_name@plt>
lea    0xe0d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1 x i64]
%8 = alloca i64
%9 = alloca i64
%10 = alloca [1024 x i8]
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%12 = call i64 (...) @fork()
store i64 %12, i64* %8
%13 = load i64, i64* %8
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (...) @status_loop()
br label %17
17: ; preds = %15, %2
%18 = call i64 (...) @fork()
store i64 %18, i64* %9
%19 = load i64, i64* %9
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @bidi_loop()
br label %23
23: ; preds = %21, %17
br label %24
24: ; preds = %38, %23
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = icmp ult i64 %26, 1
br i1 %27, label %28, label %41
28: ; preds = %24
store i64 0, i64* %11
%29 = load i64, i64* %11
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (...) @client_loop()
br label %33
33: ; preds = %31, %28
%34 = load i64, i64* %11
%35 = load i32, i32* %6
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 %36
store i64 %34, i64* %37
br label %38
38: ; preds = %33
%39 = load i32, i32* %6
%40 = add i32 %39, 1
store i32 %40, i32* %6
br label %24
41: ; preds = %24
store i32 0, i32* %6
br label %42
42: ; preds = %48, %41
%43 = load i32, i32* %6
%44 = zext i32 %43 to i64
%45 = icmp ult i64 %44, 1
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = call i32 @wait(i32* null)
br label %48
48: ; preds = %46
%49 = load i32, i32* %6
%50 = add i32 %49, 1
store i32 %50, i32* %6
br label %42
51: ; preds = %42
%52 = load i64, i64* %8
%53 = call i32 @waitpid(i64 %52, i32* null, i32 0)
%54 = load i64, i64* %9
%55 = call i32 @waitpid(i64 %54, i32* null, i32 0)
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%57 = call i32 @mb_socket_name(i8* %56, i32 1024)
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = tail call i64 (...) @fork()
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @status_loop()
br label %9
9: ; preds = %7, %2
%10 = tail call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 (...) @bidi_loop()
br label %14
14: ; preds = %12, %9
%15 = tail call i32 (...) @client_loop()
%16 = tail call i32 @wait(i32* null)
%17 = tail call i32 @waitpid(i64 %4, i32* null, i32 0)
%18 = tail call i32 @waitpid(i64 %10, i32* null, i32 0)
%19 = call i32 @mb_socket_name(i8* %5, i32 1024)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
ret i32 0
}