#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int execl(char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  pid_t daemonserver;
  printf("Avvio Server Chat, Modalità Servizio\n");
  daemonserver = fork();
  switch (daemonserver) {
  case -1: {
    printf("Errore avvio Server Chat in Modalità Servizio (fork)\n");
    exit(EXIT_FAILURE);
  }
  case 0: {
    if (execl("Server", "Chat", (char *)0) == -1) {
      printf("Errore Avvio Server Chat in Modalità Servizio (exec)\n");
      exit(EXIT_FAILURE);
    }
    return (1);
  }
  default: {
    printf("Servizio Avviato con PID: %d\n", daemonserver);
    printf("Premere un tasto per continuare\n");
    exit(EXIT_SUCCESS);
  }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xd(%rbp)
call   1030 <printf@plt>
mov    -0xd(%rbp),%al
call   1060 <fork@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xffffffff,%eax
je     118f <main+0x4f>
jmp    117f <main+0x3f>
mov    -0xc(%rbp),%eax
test   %eax,%eax
je     11ab <main+0x6b>
jmp    11f2 <main+0xb2>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
lea    0xeac(%rip),%rdi
lea    0xeac(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
cmp    $0xffffffff,%eax
jne    11e7 <main+0xa7>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    1189 <main+0x39>
lea    0xe91(%rip),%rdi
lea    0xe91(%rip),%rsi
xor    %edx,%edx
call   1060 <execl@plt>
cmp    $0xffffffff,%eax
je     1197 <main+0x47>
mov    $0x1,%eax
pop    %rcx
ret
cmp    $0xffffffff,%eax
jne    11b1 <main+0x61>
lea    0xef1(%rip),%rdi
jmp    119e <main+0x4e>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe54(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Avvio Server Chat, Modalit\C3\A0 Servizio\0A\00"
@.str.1 = [55 x i8] c"Errore avvio Server Chat in Modalit\C3\A0 Servizio (fork)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"Server\00"
@.str.3 = [5 x i8] c"Chat\00"
@.str.4 = [55 x i8] c"Errore Avvio Server Chat in Modalit\C3\A0 Servizio (exec)\0A\00"
@.str.5 = [30 x i8] c"Servizio Avviato con PID: %d\0A\00"
@.str.6 = [33 x i8] c"Premere un tasto per continuare\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @fork()
store i32 %4, i32* %2
%5 = load i32, i32* %2
switch i32 %5, label %18 [
i32 -1, label %6
i32 0, label %10
]
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = call i32 @execl(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
ret i32 1
18: ; preds = %0
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"Server\00"
@.str.3 = [5 x i8] c"Chat\00"
@.str.5 = [30 x i8] c"Servizio Avviato con PID: %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [38 x i8] c"Avvio Server Chat, Modalit\C3\A0 Servizio\00"
@str.7 = [54 x i8] c"Errore Avvio Server Chat in Modalit\C3\A0 Servizio (exec)\00"
@str.8 = [54 x i8] c"Errore avvio Server Chat in Modalit\C3\A0 Servizio (fork)\00"
@str.9 = [32 x i8] c"Premere un tasto per continuare\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @fork()
switch i32 %2, label %15 [
i32 -1, label %3
i32 0, label %7
]
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.8, i64 0, i64 0))
%5 = load i32, i32* @EXIT_FAILURE
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %0
%8 = tail call i32 @execl(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.7, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %7
ret i32 1
15: ; preds = %0
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %2)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%18 = load i32, i32* @EXIT_SUCCESS
%19 = tail call i32 @exit(i32 %18)
unreachable
}