#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*/ write(int, char *, int);
int reception(int ma_socket, int fd) {
  int n = 0;
  char reponse_server[256];
  if ((n = read(ma_socket, reponse_server, 256 - 1)) > 0) {
    write(fd, reponse_server, n);
    if (fd != 1)
      write(1, reponse_server, n);
  }
  return n;
}


x86 assembly (clang, -O0):
<reception>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1040 <read@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    118d <reception+0x6d>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <write@plt>
cmpl   $0x1,-0x8(%rbp)
je     1188 <reception+0x68>
lea    -0x110(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    118d <reception+0x6d>
mov    -0xc(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reception>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ebp
mov    %rsp,%rsi
mov    $0xff,%edx
call   1040 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    115e <reception+0x3e>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    $0x1,%ebp
je     115e <reception+0x3e>
mov    %rsp,%rsi
mov    $0x1,%edi
mov    %ebx,%edx
call   1030 <write@plt>
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @reception(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 255)
store i32 %9, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load i32, i32* %4
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = load i32, i32* %5
%15 = call i32 @write(i32 %12, i8* %13, i32 %14)
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* %5
%21 = call i32 @write(i32 1, i8* %19, i32 %20)
br label %22
22: ; preds = %18, %11
br label %23
23: ; preds = %22, %2
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
define i32 @reception(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @read(i32 %0, i8* %4, i32 255)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = call i32 @write(i32 %1, i8* %4, i32 %5)
%9 = icmp eq i32 %1, 1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @write(i32 1, i8* %4, i32 %5)
br label %12
12: ; preds = %7, %10, %2
ret i32 %5
}