#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 /*<<< orphan*/ close(int);
int fork();
int /*<<< orphan*/ server();
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int pid, status;
  {
    int i;
    for (i = 3; i < 64; i++)
      close(i);
  };
  if ((pid = fork()) == 0) {
    server();
    return 0;
  }
  client();
  wait(&status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    118d <main+0x3d>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    11b3 <main+0x63>
mov    $0x0,%al
call   1040 <server@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ca <main+0x7a>
mov    $0x0,%al
call   1050 <client@plt>
lea    -0x18(%rbp),%rdi
call   1060 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x3,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <close@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1160 <main+0x10>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     118d <main+0x3d>
xor    %eax,%eax
call   1050 <client@plt>
lea    0xc(%rsp),%rdi
call   1060 <wait@plt>
jmp    1194 <main+0x44>
xor    %eax,%eax
call   1040 <server@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %8
br label %9
9: ; preds = %15, %2
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 64
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* %8
%14 = call i32 @close(i32 %13)
br label %15
15: ; preds = %12
%16 = load i32, i32* %8
%17 = add nsw i32 %16, 1
store i32 %17, i32* %8
br label %9
18: ; preds = %9
%19 = call i32 (...) @fork()
store i32 %19, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @server()
store i32 0, i32* %3
br label %26
23: ; preds = %18
%24 = call i32 (...) @client()
%25 = call i32 @wait(i32* %7)
store i32 0, i32* %3
br label %26
26: ; preds = %23, %21
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 3, %2 ], [ %8, %5 ]
%7 = tail call i32 @close(i32 %6)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 64
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = tail call i32 (...) @fork()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (...) @server()
br label %18
15: ; preds = %10
%16 = tail call i32 (...) @client()
%17 = call i32 @wait(i32* %3)
br label %18
18: ; preds = %15, %13
ret i32 0
}