#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*/ collect_metadata_from_client(int, int);
scalar_t__ communicate_with_client(int, int *, int *);
int *create_all_readers(int, char const *, char const *, int, int);
int create_client_file(char const *, char const *);
int /*<<< orphan*/ destroy_all_readers(int, int *, char const *, char const *);
int /*<<< orphan*/ put_together_file(int, int, char const *, char const *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stop_all_readers(int, int *);
void process_client(const char *node, const char *port, int fd) {
  int *pid_array;
  int pagesize;
  int cpus;
  int ofd;
  if (communicate_with_client(fd, &cpus, &pagesize) < 0)
    return;
  ofd = create_client_file(node, port);
  pid_array = create_all_readers(cpus, node, port, pagesize, fd);
  if (!pid_array)
    return;
  collect_metadata_from_client(fd, ofd);
  sleep(1);
  stop_all_readers(cpus, pid_array);
  sleep(1);
  put_together_file(cpus, ofd, node, port);
  destroy_all_readers(cpus, pid_array, node, port);
}


x86 assembly (clang, -O0):
<process_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1090 <communicate_with_client@plt>
cmp    $0x0,%rax
jge    11b2 <process_client+0x32>
jmp    123f <process_client+0xbf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <create_client_file@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1070 <create_all_readers@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ed <process_client+0x6d>
jmp    123f <process_client+0xbf>
mov    -0x14(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1060 <collect_metadata_from_client@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1080 <stop_all_readers@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1040 <put_together_file@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1050 <destroy_all_readers@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_client>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
call   1090 <communicate_with_client@plt>
test   %rax,%rax
js     1224 <process_client+0xa4>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <create_client_file@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%ecx
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %ebp,%r8d
call   1070 <create_all_readers@plt>
test   %rax,%rax
je     1224 <process_client+0xa4>
mov    %rax,%r12
mov    %ebp,%edi
mov    %r15d,%esi
call   1060 <collect_metadata_from_client@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    0x8(%rsp),%edi
mov    %r12,%rsi
call   1080 <stop_all_readers@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    0x8(%rsp),%edi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <put_together_file@plt>
mov    0x8(%rsp),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <destroy_all_readers@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @process_client(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = call i64 @communicate_with_client(i32 %11, i32* %9, i32* %8)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
br label %47
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = call i32 @create_client_file(i8* %16, i8* %17)
store i32 %18, i32* %10
%19 = load i32, i32* %9
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = load i32, i32* %8
%23 = load i32, i32* %6
%24 = call i32* @create_all_readers(i32 %19, i8* %20, i8* %21, i32 %22, i32 %23)
store i32* %24, i32** %7
%25 = load i32*, i32** %7
%26 = icmp ne i32* %25, null
br i1 %26, label %28, label %27
27: ; preds = %15
br label %47
28: ; preds = %15
%29 = load i32, i32* %6
%30 = load i32, i32* %10
%31 = call i32 @collect_metadata_from_client(i32 %29, i32 %30)
%32 = call i32 @sleep(i32 1)
%33 = load i32, i32* %9
%34 = load i32*, i32** %7
%35 = call i32 @stop_all_readers(i32 %33, i32* %34)
%36 = call i32 @sleep(i32 1)
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = call i32 @put_together_file(i32 %37, i32 %38, i8* %39, i8* %40)
%42 = load i32, i32* %9
%43 = load i32*, i32** %7
%44 = load i8*, i8** %4
%45 = load i8*, i8** %5
%46 = call i32 @destroy_all_readers(i32 %42, i32* %43, i8* %44, i8* %45)
br label %47
47: ; preds = %28, %27, %14
ret void
}

LLVM IR (-O2):
define void @process_client(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call i64 @communicate_with_client(i32 %2, i32* %5, i32* %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %3
%11 = call i32 @create_client_file(i8* %0, i8* %1)
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = call i32* @create_all_readers(i32 %12, i8* %0, i8* %1, i32 %13, i32 %2)
%15 = icmp eq i32* %14, null
br i1 %15, label %26, label %16
16: ; preds = %10
%17 = call i32 @collect_metadata_from_client(i32 %2, i32 %11)
%18 = call i32 @sleep(i32 1)
%19 = load i32, i32* %5
%20 = call i32 @stop_all_readers(i32 %19, i32* %14)
%21 = call i32 @sleep(i32 1)
%22 = load i32, i32* %5
%23 = call i32 @put_together_file(i32 %22, i32 %11, i8* %0, i8* %1)
%24 = load i32, i32* %5
%25 = call i32 @destroy_all_readers(i32 %24, i32* %14, i8* %0, i8* %1)
br label %26
26: ; preds = %10, %3, %16
ret void
}