#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*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
scalar_t__ write(int, char *, int);
int message(int client, char *message) {
  int size = strlen(message);
  printf("Server>>>%s\n", (message + 1));
  if (write(client, message, size) < 0) {
    perror("Error: Failed to write to the client\n");
    return -1;
  }
  write(client, "\n\rEBB>", 7);
  return 0;
}


x86 assembly (clang, -O0):
<message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11a0 <message+0x60>
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <message+0x7b>
mov    -0x8(%rbp),%edi
lea    0xe89(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<message>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%rbx),%rsi
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <write@plt>
test   %rax,%rax
js     1190 <message+0x50>
lea    0xeb6(%rip),%rsi
mov    %ebp,%edi
mov    $0x7,%edx
call   1030 <write@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe76(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    118b <message+0x4b>

LLVM IR (-O0):
@.str = [13 x i8] c"Server>>>%s\0A\00"
@.str.1 = [38 x i8] c"Error: Failed to write to the client\0A\00"
@.str.2 = [7 x i8] c"\0A\0DEBB>\00"
define i32 @message(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %4
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = call i64 @write(i32 %12, i8* %13, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %22
19: ; preds = %2
%20 = load i32, i32* %4
%21 = call i64 @write(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
store i32 0, i32* %3
br label %22
22: ; preds = %19, %17
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [13 x i8] c"Server>>>%s\0A\00"
@.str.1 = [38 x i8] c"Error: Failed to write to the client\0A\00"
@.str.2 = [7 x i8] c"\0A\0DEBB>\00"
define i32 @message(i32 %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = getelementptr inbounds i8, i8* %1, i64 1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = tail call i64 @write(i32 %0, i8* %1, i32 %3)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = tail call i64 @write(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ -1, %8 ], [ 0, %10 ]
ret i32 %13
}