#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*/ comunicate(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int getClient(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
void listeningProcess(int socketDescriptor) {
  while (1) {
    int clientDescriptor = getClient(socketDescriptor);
    int pid_client = fork();
    switch (pid_client) {
    case -1:
      perror("Error creating fill process.\n");
      break;
    case 0:
      printf("%sClient connected.%s\n", "\x1B[34m", "\x1B[0m");
      comunicate(clientDescriptor);
      exit(0);
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<listeningProcess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <getClient@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xffffffff,%eax
je     11a4 <listeningProcess+0x44>
jmp    1194 <listeningProcess+0x34>
mov    -0x10(%rbp),%eax
test   %eax,%eax
je     11b5 <listeningProcess+0x55>
jmp    11de <listeningProcess+0x7e>
lea    0xe55(%rip),%rdi
call   1060 <perror@plt>
jmp    11e3 <listeningProcess+0x83>
lea    0xe62(%rip),%rdi
lea    0xe72(%rip),%rsi
lea    0xe71(%rip),%rdx
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <comunicate@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    11e3 <listeningProcess+0x83>
jmp    116b <listeningProcess+0xb>

x86 assembly (clang, -O2):
<listeningProcess>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xe93(%rip),%r14
jmp    1180 <listeningProcess+0x20>
mov    %r14,%rdi
call   1060 <perror@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1050 <getClient@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <fork@plt>
cmp    $0xffffffff,%eax
je     116f <listeningProcess+0xf>
test   %eax,%eax
jne    1180 <listeningProcess+0x20>
lea    0xe7e(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe8d(%rip),%rdx
call   1030 <printf@plt>
mov    %ebp,%edi
call   1040 <comunicate@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Error creating fill process.\0A\00"
@.str.1 = [23 x i8] c"%sClient connected.%s\0A\00"
@.str.2 = [6 x i8] c"\1B[34m\00"
@.str.3 = [5 x i8] c"\1B[0m\00"
define void @listeningProcess(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
br label %5
5: ; preds = %1, %18
%6 = load i32, i32* %2
%7 = call i32 @getClient(i32 %6)
store i32 %7, i32* %3
%8 = call i32 (...) @fork()
store i32 %8, i32* %4
%9 = load i32, i32* %4
switch i32 %9, label %17 [
i32 -1, label %10
i32 0, label %12
]
10: ; preds = %5
%11 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %18
12: ; preds = %5
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = call i32 @comunicate(i32 %14)
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %5
br label %18
18: ; preds = %17, %10
br label %5
}

LLVM IR (-O2):
@.str = [30 x i8] c"Error creating fill process.\0A\00"
@.str.1 = [23 x i8] c"%sClient connected.%s\0A\00"
@.str.2 = [6 x i8] c"\1B[34m\00"
@.str.3 = [5 x i8] c"\1B[0m\00"
define void @listeningProcess(i32 %0) {
br label %2
2: ; preds = %5, %1
%3 = tail call i32 @getClient(i32 %0)
%4 = tail call i32 (...) @fork()
switch i32 %4, label %5 [
i32 -1, label %6
i32 0, label %8
]
5: ; preds = %2, %6
br label %2
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %5
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @comunicate(i32 %3)
%11 = tail call i32 @exit(i32 0)
unreachable
}