#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *gets(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
void traiter(int fdr, int fdq) {
  char reponse[11];
  char question[11];
  for (;;) {
    if (gets(question) == NULL) {
      exit(EXIT_FAILURE);
    }
    write(fdq, question, 10);
    printf("Client -> %s \n", question);
    read(fdr, reponse, 10);
    printf("Serveur -> %s \n", reponse);
    if (strcmp(reponse, "OK") == 0) {
      break;
    }
  }
}


x86 assembly (clang, -O0):
<traiter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x1e(%rbp),%rdi
call   1070 <gets@plt>
cmp    $0x0,%rax
jne    118f <traiter+0x2f>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xa,%edx
call   1030 <write@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x13(%rbp),%rsi
mov    $0xa,%edx
call   1050 <read@plt>
lea    -0x13(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
lea    -0x13(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <traiter+0x90>
jmp    11f5 <traiter+0x95>
jmp    116e <traiter+0xe>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<traiter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %edi,%r12d
lea    0x2(%rsp),%rbx
lea    0xd(%rsp),%rbp
lea    0xe8a(%rip),%r13
lea    0xe93(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     11f6 <traiter+0x96>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <write@plt>
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0xa,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1190 <traiter+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [15 x i8] c"Client -> %s \0A\00"
@.str.1 = [16 x i8] c"Serveur -> %s \0A\00"
@.str.2 = [3 x i8] c"OK\00"
define void @traiter(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [11 x i8]
%6 = alloca [11 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %7
7: ; preds = %29, %2
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%9 = call i32* @gets(i8* %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %7
%15 = load i32, i32* %4
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%17 = call i32 @write(i32 %15, i8* %16, i32 10)
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %3
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%22 = call i32 @read(i32 %20, i8* %21, i32 10)
%23 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %14
br label %30
29: ; preds = %14
br label %7
30: ; preds = %28
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [15 x i8] c"Client -> %s \0A\00"
@.str.1 = [16 x i8] c"Serveur -> %s \0A\00"
@.str.2 = [3 x i8] c"OK\00"
define void @traiter(i32 %0, i32 %1) {
%3 = alloca [11 x i8]
%4 = alloca [11 x i8]
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %13, %2
%8 = call i32* @gets(i8* %6)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %7
%14 = call i32 @write(i32 %1, i8* %6, i32 10)
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
%16 = call i32 @read(i32 %0, i8* %5, i32 10)
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %13
ret void
}