#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 */
struct sockaddr_un {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int communication(struct sockaddr_un from, int sockfd) {
  int r;
  char buf[512];
  char *message = "Envoyez votre message : ";
  for (;;) {
    r = write(sockfd, message, strlen(message));
    r = read(sockfd, buf, 512);
    if (r <= 0) {
      printf("fin client\n");
      break;
    }
    buf[r] = '\0';
    printf("%s\n", buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<communication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x218(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x224(%rbp)
mov    -0x218(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x218(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x224(%rbp),%edi
mov    -0x220(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1060 <read@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jg     11cd <communication+0x8d>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f3 <communication+0xb3>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x210(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    115f <communication+0x1f>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<communication>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %esi,%ebx
lea    0xeab(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x200,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    11c5 <communication+0x85>
mov    %rsp,%r14
lea    0xe7a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x200,%edx
call   1060 <read@plt>
test   %eax,%eax
jg     1190 <communication+0x50>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
@.str = [25 x i8] c"Envoyez votre message : \00"
@.str.1 = [12 x i8] c"fin client\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @communication(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca i32
%6 = alloca [512 x i8]
%7 = alloca i8*
%8 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
store i32 %0, i32* %8
store i32 %1, i32* %4
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %7
br label %9
9: ; preds = %22, %2
%10 = load i32, i32* %4
%11 = load i8*, i8** %7
%12 = load i8*, i8** %7
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @write(i32 %10, i8* %11, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%17 = call i32 @read(i32 %15, i8* %16, i32 512)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %28
22: ; preds = %9
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %9
28: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Envoyez votre message : \00"
@str = [11 x i8] c"fin client\00"
define i32 @communication(i32 %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @read(i32 %1, i8* %4, i32 512)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %11, %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
11: ; preds = %2, %11
%12 = phi i32 [ %18, %11 ], [ %7, %2 ]
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i32 @puts(i8* %4)
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @read(i32 %1, i8* %4, i32 512)
%19 = icmp slt i32 %18, 1
br i1 %19, label %9, label %11
}