#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);
char *nstoh();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, 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. IP: %s%s\n", "\x1B[34m", nstoh(), "\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   1060 <getClient@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
call   1090 <fork@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xffffffff,%eax
je     11b4 <listeningProcess+0x44>
jmp    11a4 <listeningProcess+0x34>
mov    -0x10(%rbp),%eax
test   %eax,%eax
je     11c5 <listeningProcess+0x55>
jmp    11f8 <listeningProcess+0x88>
lea    0xe45(%rip),%rdi
call   1070 <perror@plt>
jmp    11fd <listeningProcess+0x8d>
mov    $0x0,%al
call   1040 <nstoh@plt>
mov    %rax,%rdx
lea    0xe48(%rip),%rdi
lea    0xe5f(%rip),%rsi
lea    0xe5e(%rip),%rcx
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <comunicate@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    11fd <listeningProcess+0x8d>
jmp    117b <listeningProcess+0xb>

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

LLVM IR (-O0):
@.str = [30 x i8] c"Error creating fill process.\0A\00"
@.str.1 = [30 x i8] c"%sClient connected. IP: %s%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, %19
%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 %18 [
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 %19
12: ; preds = %5
%13 = call i8* (...) @nstoh()
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = call i32 @comunicate(i32 %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %5
br label %19
19: ; preds = %18, %10
br label %5
}

LLVM IR (-O2):
@.str = [30 x i8] c"Error creating fill process.\0A\00"
@.str.1 = [30 x i8] c"%sClient connected. IP: %s%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 i8* (...) @nstoh()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @comunicate(i32 %3)
%12 = tail call i32 @exit(i32 0)
unreachable
}