#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 /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
void renvoi(int sock) {
  char buffer[9999];
  int longueur;
  if ((longueur = read(sock, buffer, sizeof(buffer))) <= 0)
    return;
  printf("message lu : %s \n", buffer);
  printf("renvoi du message traite.\n");
  sleep(3);
  write(sock, buffer, strlen(buffer) + 1);
  printf("message envoye. \n");
  return;
}


x86 assembly (clang, -O0):
<renvoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2740,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x2720(%rbp),%rsi
mov    $0x270f,%edx
call   1060 <read@plt>
mov    %eax,-0x2724(%rbp)
cmp    $0x0,%eax
jg     1186 <renvoi+0x36>
jmp    11fd <renvoi+0xad>
lea    -0x2720(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x3,%edi
call   1070 <sleep@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2734(%rbp)
lea    -0x2720(%rbp),%rax
mov    %rax,-0x2730(%rbp)
lea    -0x2720(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2734(%rbp),%edi
mov    -0x2730(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x2740,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<renvoi>:
push   %r14
push   %rbx
sub    $0x2718,%rsp
mov    %edi,%ebx
mov    %rsp,%rsi
mov    $0x270f,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    11c9 <renvoi+0x69>
lea    0xe7c(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <write@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
add    $0x2718,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"message lu : %s \0A\00"
@.str.1 = [27 x i8] c"renvoi du message traite.\0A\00"
@.str.2 = [18 x i8] c"message envoye. \0A\00"
define void @renvoi(i32 %0) {
%2 = alloca i32
%3 = alloca [9999 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [9999 x i8], [9999 x i8]* %3, i64 0, i64 0
%7 = call i32 @read(i32 %5, i8* %6, i32 9999)
store i32 %7, i32* %4
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
br label %22
10: ; preds = %1
%11 = getelementptr inbounds [9999 x i8], [9999 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @sleep(i32 3)
%15 = load i32, i32* %2
%16 = getelementptr inbounds [9999 x i8], [9999 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [9999 x i8], [9999 x i8]* %3, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %18, 1
%20 = call i32 @write(i32 %15, i8* %16, i64 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %10, %9
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"message lu : %s \0A\00"
@str = [26 x i8] c"renvoi du message traite.\00"
@str.3 = [17 x i8] c"message envoye. \00"
define void @renvoi(i32 %0) {
%2 = alloca [9999 x i8]
%3 = getelementptr inbounds [9999 x i8], [9999 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 9999)
%5 = icmp slt i32 %4, 1
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = call i32 @sleep(i32 3)
%10 = call i64 @strlen(i8* %3)
%11 = add nsw i64 %10, 1
%12 = call i32 @write(i32 %0, i8* %3, i64 %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.3, i64 0, i64 0))
br label %14
14: ; preds = %1, %6
ret void
}