#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 read(int, char *, int);
int /*<<< orphan*/ set_message(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int lecture_s(int ta_socket) {
  char message[256];
  char garde_message[256];
  int n;
  if ((n = read(ta_socket, message, 256 - 1)) > 0)
    strncpy(garde_message, message, n);
  else
    strcpy(garde_message, "pas de reponse");
  set_message(garde_message);
  return n;
}


x86 assembly (clang, -O0):
<lecture_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1050 <read@plt>
mov    %eax,-0x214(%rbp)
cmp    $0x0,%eax
jle    118f <lecture_s+0x4f>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x214(%rbp),%edx
call   1030 <strncpy@plt>
jmp    11a2 <lecture_s+0x62>
lea    -0x210(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x210(%rbp),%rdi
call   1060 <set_message@plt>
mov    -0x214(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lecture_s>:
push   %rbx
sub    $0x200,%rsp
lea    0x100(%rsp),%rsi
mov    $0xff,%edx
call   1050 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1174 <lecture_s+0x34>
mov    %rsp,%rdi
lea    0x100(%rsp),%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
jmp    1183 <lecture_s+0x43>
lea    0xe85(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
mov    %rsp,%rdi
call   1060 <set_message@plt>
mov    %ebx,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"pas de reponse\00"
define i32 @lecture_s(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @read(i32 %6, i8* %7, i32 255)
store i32 %8, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* %5
%14 = call i32 @strncpy(i8* %11, i8* %12, i32 %13)
br label %18
15: ; preds = %1
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%20 = call i32 @set_message(i8* %19)
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@.str = [15 x i8] c"pas de reponse\00"
define i32 @lecture_s(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* %4, i32 255)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @strncpy(i8* %5, i8* %4, i32 %6)
br label %12
10: ; preds = %1
%11 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @set_message(i8* %5)
ret i32 %6
}