#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*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void *service(void *comm_fd) {
  int comm_sock = (intptr_t)comm_fd;
  char str[100];
  int nb;
  do {
    if ((nb = read(comm_sock, str, 100)) < 0) {
      perror("read");
      exit(3);
    }
    str[nb] = 0;
    printf("Le serveur reçoit - %s", str);
    write(comm_sock, str, nb + 1);
  } while (str[0] != '.');
  close(comm_sock);
  return 0;
}


x86 assembly (clang, -O0):
<service>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1060 <read@plt>
mov    %eax,-0x74(%rbp)
cmp    $0x0,%eax
jge    11a9 <service+0x49>
lea    0xe66(%rip),%rdi
call   1070 <perror@plt>
mov    $0x3,%edi
call   1080 <exit@plt>
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
add    $0x1,%edx
call   1030 <write@plt>
movsbl -0x70(%rbp),%eax
cmp    $0x2e,%eax
jne    1176 <service+0x16>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<service>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
lea    0xe8e(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x64,%edx
call   1060 <read@plt>
test   %eax,%eax
js     11cf <service+0x6f>
mov    %eax,%ebp
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmpb   $0x2e,(%rsp)
jne    1180 <service+0x20>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe2a(%rip),%rdi
call   1070 <perror@plt>
mov    $0x3,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@.str.1 = [24 x i8] c"Le serveur re\C3\A7oit - %s\00"
define i8* @service(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = ptrtoint i8* %6 to i64
%8 = trunc i64 %7 to i32
store i32 %8, i32* %3
br label %9
9: ; preds = %28, %1
%10 = load i32, i32* %3
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 100)
store i32 %12, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 3)
unreachable
17: ; preds = %9
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %3
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
%27 = call i32 @write(i32 %23, i8* %24, i32 %26)
br label %28
28: ; preds = %17
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 46
br i1 %32, label %9, label %33
33: ; preds = %28
%34 = load i32, i32* %3
%35 = call i32 @close(i32 %34)
ret i8* null
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@.str.1 = [24 x i8] c"Le serveur re\C3\A7oit - %s\00"
define noalias i8* @service(i8* %0) {
%2 = alloca [100 x i8]
%3 = ptrtoint i8* %0 to i64
%4 = trunc i64 %3 to i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %12, %1
%7 = call i32 @read(i32 %4, i8* %5, i32 100)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 3)
unreachable
12: ; preds = %6
%13 = zext i32 %7 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%16 = add nuw nsw i32 %7, 1
%17 = call i32 @write(i32 %4, i8* %5, i32 %16)
%18 = load i8, i8* %5
%19 = icmp eq i8 %18, 46
br i1 %19, label %20, label %6
20: ; preds = %12
%21 = call i32 @close(i32 %4)
ret i8* null
}