#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*/ afficherEnTete();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strtok(char *, char *);
void lecteurResultat(int sock) {
  char buffer;
  char message[100];
  char stx = 0x02;
  int fin = 0;
  afficherEnTete();
  printf("------------------------------------\n");
  printf("LISTE DES TRAINS :\n");
  do {
    do {
      read(sock, &buffer, 1);
    } while (buffer != (char)0x02 && buffer != (char)0x04 && buffer != '\0');
    if (buffer != (char)0x04) {
      read(sock, &buffer, 1);
      sprintf(message, "%c", buffer);
      while (buffer != (char)0x03 && buffer != '\0') {
        read(sock, &buffer, 1);
        sprintf(message, "%s%c", message, buffer);
      }
      printf("------------------------------------\n");
      strtok(message, "#");
      printf("Ville de Depart : %s\n", strtok(NULL, "#"));
      printf("Ville D'arrivee : %s\n", strtok(NULL, "#"));
      printf("Heure de Depart : %s\n", strtok(NULL, "#"));
      printf("Heure D'arrivee : %s\n", strtok(NULL, "#"));
      printf("Prix : %s\n", strtok(NULL, "#"));
      printf("------------------------------------\n\n");
    } else
      fin = 1;
  } while (fin != 1);
}


x86 assembly (clang, -O0):
<lecteurResultat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x2,-0x71(%rbp)
movl   $0x0,-0x78(%rbp)
mov    $0x0,%al
call   1070 <afficherEnTete@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1191 <lecteurResultat+0x41>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x79(%rbp)
je     11d3 <lecteurResultat+0x83>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
mov    %al,-0x79(%rbp)
je     11d3 <lecteurResultat+0x83>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    1191 <lecteurResultat+0x41>
movsbl -0x5(%rbp),%eax
cmp    $0x4,%eax
je     1347 <lecteurResultat+0x1f7>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
lea    -0x70(%rbp),%rdi
movsbl -0x5(%rbp),%edx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x7a(%rbp)
je     1231 <lecteurResultat+0xe1>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x7a(%rbp)
mov    -0x7a(%rbp),%al
test   $0x1,%al
jne    1241 <lecteurResultat+0xf1>
jmp    1271 <lecteurResultat+0x121>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rdx
movsbl -0x5(%rbp),%ecx
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1212 <lecteurResultat+0xc2>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xda5(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rsi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd84(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rsi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd63(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rsi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd42(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd21(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rsi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    134e <lecteurResultat+0x1fe>
movl   $0x1,-0x78(%rbp)
jmp    1353 <lecteurResultat+0x203>
cmpl   $0x1,-0x78(%rbp)
jne    118c <lecteurResultat+0x3c>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lecteurResultat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1080 <afficherEnTete@plt>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf(%rsp),%r15
lea    0xe6a(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe59(%rip),%rbp
jmp    125a <lecteurResultat+0xfa>
nopl   0x0(%rax)
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0xe2f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0xe2a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0xe25(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0xe20(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0xe1b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    0xf(%rsp),%al
test   %al,%al
je     1280 <lecteurResultat+0x120>
cmp    $0x2,%al
je     1280 <lecteurResultat+0x120>
cmp    $0x4,%al
jne    125a <lecteurResultat+0xfa>
jmp    12ed <lecteurResultat+0x18d>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    0xf(%rsp),%r14b
mov    %r14b,0x10(%rsp)
movb   $0x0,0x11(%rsp)
test   %r14b,%r14b
je     11b0 <lecteurResultat+0x50>
nopw   0x0(%rax,%rax,1)
cmp    $0x3,%r14b
je     11b0 <lecteurResultat+0x50>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movzbl 0xf(%rsp),%r14d
movsbl %r14b,%ecx
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
test   %r14b,%r14b
jne    12b0 <lecteurResultat+0x150>
jmp    11b0 <lecteurResultat+0x50>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"------------------------------------\0A\00"
@.str.1 = [20 x i8] c"LISTE DES TRAINS :\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [5 x i8] c"%s%c\00"
@.str.4 = [2 x i8] c"#\00"
@.str.5 = [22 x i8] c"Ville de Depart : %s\0A\00"
@.str.6 = [22 x i8] c"Ville D'arrivee : %s\0A\00"
@.str.7 = [22 x i8] c"Heure de Depart : %s\0A\00"
@.str.8 = [22 x i8] c"Heure D'arrivee : %s\0A\00"
@.str.9 = [11 x i8] c"Prix : %s\0A\00"
@.str.10 = [39 x i8] c"------------------------------------\0A\0A\00"
define void @lecteurResultat(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca [100 x i8]
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %2
store i8 2, i8* %5
store i32 0, i32* %6
%7 = call i32 (...) @afficherEnTete()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %74, %1
br label %11
11: ; preds = %26, %10
%12 = load i32, i32* %2
%13 = call i32 @read(i32 %12, i8* %3, i32 1)
br label %14
14: ; preds = %11
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 4
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br label %26
26: ; preds = %22, %18, %14
%27 = phi i1 [ false, %18 ], [ false, %14 ], [ %25, %22 ]
br i1 %27, label %11, label %28
28: ; preds = %26
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 4
br i1 %31, label %32, label %72
32: ; preds = %28
%33 = load i32, i32* %2
%34 = call i32 @read(i32 %33, i8* %3, i32 1)
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%36 = load i8, i8* %3
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %49, %32
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 3
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br label %47
47: ; preds = %43, %39
%48 = phi i1 [ false, %39 ], [ %46, %43 ]
br i1 %48, label %49, label %57
49: ; preds = %47
%50 = load i32, i32* %2
%51 = call i32 @read(i32 %50, i8* %3, i32 1)
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%54 = load i8, i8* %3
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %53, i32 %55)
br label %39
57: ; preds = %47
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %61)
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %63)
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %65)
%67 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %67)
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %73
72: ; preds = %28
store i32 1, i32* %6
br label %73
73: ; preds = %72, %57
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = icmp ne i32 %75, 1
br i1 %76, label %10, label %77
77: ; preds = %74
ret void
}

LLVM IR (-O2):
@.str.3 = [5 x i8] c"%s%c\00"
@.str.4 = [2 x i8] c"#\00"
@.str.5 = [22 x i8] c"Ville de Depart : %s\0A\00"
@.str.6 = [22 x i8] c"Ville D'arrivee : %s\0A\00"
@.str.7 = [22 x i8] c"Heure de Depart : %s\0A\00"
@.str.8 = [22 x i8] c"Heure D'arrivee : %s\0A\00"
@.str.9 = [11 x i8] c"Prix : %s\0A\00"
@str.11 = [19 x i8] c"LISTE DES TRAINS :\00"
@str.12 = [37 x i8] c"------------------------------------\00"
@str.13 = [38 x i8] c"------------------------------------\0A\00"
define void @lecteurResultat(i32 %0) {
%2 = alloca i8
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @afficherEnTete()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
br label %9
9: ; preds = %12, %1
%10 = call i32 @read(i32 %0, i8* %2, i32 1)
%11 = load i8, i8* %2
switch i8 %11, label %12 [
i8 4, label %37
i8 0, label %13
i8 2, label %13
]
12: ; preds = %9, %23
br label %9
13: ; preds = %9, %9
%14 = call i32 @read(i32 %0, i8* %2, i32 1)
%15 = load i8, i8* %2
store i8 %15, i8* %4
store i8 0, i8* %8
br label %16
16: ; preds = %18, %13
%17 = phi i8 [ %20, %18 ], [ %15, %13 ]
switch i8 %17, label %18 [
i8 3, label %23
i8 0, label %23
]
18: ; preds = %16
%19 = call i32 @read(i32 %0, i8* %2, i32 1)
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %21)
br label %16
23: ; preds = %16, %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.12, i64 0, i64 0))
%25 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %30)
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %32)
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %34)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
br label %12
37: ; preds = %9
ret void
}