#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*/ creation_message_erreur(char *);
int /*<<< orphan*/ diffusion_erreur(int);
int /*<<< orphan*/ ecriture_s(int);
int /*<<< orphan*/ get_message();
int lecture(char *);
int lecture_s(int);
int /*<<< orphan*/ liste_referentiel(int);
int /*<<< orphan*/ quitter(int);
int read(int, char *, int);
scalar_t__ sscanf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void lancement_service(int ta_socket) {
  int n;
  int choix;
  choix = 1;
  char mMessage[256] = "";
  char reponse[256] = "";
  char nom[256] = "";
  if ((n = read(ta_socket, nom, 256 - 1)) > 0)
    ;
  else
    strcpy(nom, "sombre inconnu");
  liste_referentiel(ta_socket);
  while (choix) {
    n = lecture_s(ta_socket);
    if (sscanf(get_message(), "%s", mMessage) > 0) {
      while ((n = lecture(mMessage)) == 1) {
        ecriture_s(ta_socket);
      }
      if (n < 0) {
        creation_message_erreur(mMessage);
        diffusion_erreur(ta_socket);
      }
    }
    if (!strcmp(mMessage, "q") || !strcmp(mMessage, "Q")) {
      choix = 0;
      quitter(ta_socket);
    }
  }
}


x86 assembly (clang, -O0):
<lancement_service>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x310(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x310(%rbp),%rsi
mov    $0xff,%edx
call   10b0 <read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1243 <lancement_service+0x73>
jmp    1256 <lancement_service+0x86>
lea    -0x310(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1070 <strcpy@plt>
mov    -0x4(%rbp),%edi
call   10d0 <liste_referentiel@plt>
cmpl   $0x0,-0xc(%rbp)
je     1332 <lancement_service+0x162>
mov    -0x4(%rbp),%edi
call   10a0 <lecture_s@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <get_message@plt>
mov    %eax,%edi
lea    -0x110(%rbp),%rdx
lea    0xd85(%rip),%rsi
call   10e0 <sscanf@plt>
cmp    $0x0,%rax
jle    12e6 <lancement_service+0x116>
jmp    129e <lancement_service+0xce>
lea    -0x110(%rbp),%rdi
call   1050 <lecture@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x1,%eax
jne    12c3 <lancement_service+0xf3>
mov    -0x4(%rbp),%edi
call   1040 <ecriture_s@plt>
jmp    129e <lancement_service+0xce>
cmpl   $0x0,-0x8(%rbp)
jge    12e1 <lancement_service+0x111>
lea    -0x110(%rbp),%rdi
call   10f0 <creation_message_erreur@plt>
mov    -0x4(%rbp),%edi
call   1090 <diffusion_erreur@plt>
jmp    12e6 <lancement_service+0x116>
lea    -0x110(%rbp),%rdi
lea    0xd1e(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
je     131e <lancement_service+0x14e>
lea    -0x110(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    132d <lancement_service+0x15d>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <quitter@plt>
jmp    125e <lancement_service+0x8e>
add    $0x310,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lancement_service>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
test   %eax,%eax
jg     12c8 <lancement_service+0x118>
lea    0xd40(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcpy@plt>
mov    %ebx,%edi
call   10b0 <liste_referentiel@plt>
lea    0xd39(%rip),%r14
lea    0x100(%rsp),%r15
jmp    12f4 <lancement_service+0x144>
test   %eax,%eax
js     1340 <lancement_service+0x190>
mov    0x100(%rsp),%eax
or     $0x20,%eax
cmp    $0x71,%ax
je     1351 <lancement_service+0x1a1>
mov    %ebx,%edi
call   1090 <lecture_s@plt>
xor    %eax,%eax
call   1030 <get_message@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <sscanf@plt>
test   %rax,%rax
jle    12e4 <lancement_service+0x134>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1050 <lecture@plt>
cmp    $0x1,%eax
jne    12e0 <lancement_service+0x130>
mov    %ebx,%edi
call   1040 <ecriture_s@plt>
jmp    1320 <lancement_service+0x170>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10d0 <creation_message_erreur@plt>
mov    %ebx,%edi
call   1080 <diffusion_erreur@plt>
jmp    12e4 <lancement_service+0x134>
mov    %ebx,%edi
call   1060 <quitter@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"sombre inconnu\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"q\00"
@.str.3 = [2 x i8] c"Q\00"
define void @lancement_service(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
store i32 %0, i32* %2
store i32 1, i32* %4
%8 = bitcast [256 x i8]* %5 to i8*
%9 = bitcast [256 x i8]* %6 to i8*
%10 = bitcast [256 x i8]* %7 to i8*
%11 = load i32, i32* %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 255)
store i32 %13, i32* %3
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
br label %19
16: ; preds = %1
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %15
%20 = load i32, i32* %2
%21 = call i32 @liste_referentiel(i32 %20)
br label %22
22: ; preds = %60, %19
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %61
25: ; preds = %22
%26 = load i32, i32* %2
%27 = call i32 @lecture_s(i32 %26)
store i32 %27, i32* %3
%28 = call i32 (...) @get_message()
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%30 = call i64 @sscanf(i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %49
32: ; preds = %25
br label %33
33: ; preds = %37, %32
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%35 = call i32 @lecture(i8* %34)
store i32 %35, i32* %3
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %2
%39 = call i32 @ecriture_s(i32 %38)
br label %33
40: ; preds = %33
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%45 = call i32 @creation_message_erreur(i8* %44)
%46 = load i32, i32* %2
%47 = call i32 @diffusion_erreur(i32 %46)
br label %48
48: ; preds = %43, %40
br label %49
49: ; preds = %48, %25
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %53, %49
store i32 0, i32* %4
%58 = load i32, i32* %2
%59 = call i32 @quitter(i32 %58)
br label %60
60: ; preds = %57, %53
br label %22
61: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"sombre inconnu\00"
@.str.1 = [3 x i8] c"%s\00"
define void @lancement_service(i32 %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @read(i32 %0, i8* %5, i32 255)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %1, %8
%11 = call i32 @liste_referentiel(i32 %0)
%12 = bitcast [256 x i8]* %2 to i16*
br label %13
13: ; preds = %31, %10
%14 = call i32 @lecture_s(i32 %0)
%15 = call i32 (...) @get_message()
%16 = call i64 @sscanf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = call i32 @lecture(i8* %4)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %18, %21
%22 = call i32 @ecriture_s(i32 %0)
%23 = call i32 @lecture(i8* %4)
%24 = icmp eq i32 %23, 1
br i1 %24, label %21, label %25
25: ; preds = %21, %18
%26 = phi i32 [ %19, %18 ], [ %23, %21 ]
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 @creation_message_erreur(i8* %4)
%30 = call i32 @diffusion_erreur(i32 %0)
br label %31
31: ; preds = %25, %28, %13
%32 = load i16, i16* %12
switch i16 %32, label %13 [
i16 113, label %33
i16 81, label %33
]
33: ; preds = %31, %31
%34 = call i32 @quitter(i32 %0)
ret void
}