#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*/ connexion(int, char *);
int creer_serveur(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int socket_serveur;
  if (argc != 2) {
    printf("Erreur : paramètre(s) incorect\n");
    return -1;
  }
  if (opendir(argv[1]) == NULL) {
    printf("Erreur : Répértoire invalide\n");
    return -1;
  }
  socket_serveur = creer_serveur(8080);
  if (socket_serveur == -1) {
    perror("probleme creation serveur\n");
    return -1;
  }
  while (1)
    connexion(socket_serveur, argv[1]);
  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)
cmpl   $0x2,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <opendir@plt>
cmp    $0x0,%rax
jne    11b7 <main+0x67>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <main+0xb0>
mov    $0x1f90,%edi
call   1050 <creer_serveur@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11e6 <main+0x96>
lea    0xe6c(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <main+0xb0>
jmp    11eb <main+0x9b>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1060 <connexion@plt>
jmp    11eb <main+0x9b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    118d <main+0x3d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     1196 <main+0x46>
mov    $0x1f90,%edi
call   1050 <creer_serveur@plt>
cmp    $0xffffffff,%eax
je     11ae <main+0x5e>
mov    %eax,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x8(%rbx),%rsi
mov    %ebp,%edi
call   1060 <connexion@plt>
jmp    1180 <main+0x30>
lea    0xea6(%rip),%rdi
jmp    119d <main+0x4d>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe4b(%rip),%rdi
call   1070 <perror@plt>
jmp    11a2 <main+0x52>

LLVM IR (-O0):
@.str = [33 x i8] c"Erreur : param\C3\A8tre(s) incorect\0A\00"
@.str.1 = [32 x i8] c"Erreur : R\C3\A9p\C3\A9rtoire invalide\0A\00"
@.str.2 = [27 x i8] c"probleme creation serveur\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @opendir(i8* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
19: ; preds = %11
%20 = call i32 @creer_serveur(i32 8080)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
25: ; preds = %19
br label %26
26: ; preds = %25, %26
%27 = load i32, i32* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @connexion(i32 %27, i8* %30)
br label %26
32: ; preds = %23, %17, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.2 = [27 x i8] c"probleme creation serveur\0A\00"
@str = [31 x i8] c"Erreur : R\C3\A9p\C3\A9rtoire invalide\00"
@str.3 = [32 x i8] c"Erreur : param\C3\A8tre(s) incorect\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.3, i64 0, i64 0))
br label %21
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @opendir(i8* %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %21
13: ; preds = %6
%14 = tail call i32 @creer_serveur(i32 8080)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %21
18: ; preds = %13, %18
%19 = load i8*, i8** %7
%20 = tail call i32 @connexion(i32 %14, i8* %19)
br label %18
21: ; preds = %16, %11, %4
ret i32 -1
}