#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 */
typedef int /*<<< orphan*/ string;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ string_modificator(char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
void handle_connection(int cfd) {
  char string[200 + 1];
  memset(string, '\0', sizeof(string));
  read(cfd, string, sizeof(string) - 1);
  printf("message received (fd = %d): %s\n", cfd, string);
  string_modificator(string);
  write(cfd, string, strlen(string) + 1);
  printf("message send (fd = %d): %s\n", cfd, string);
}


x86 assembly (clang, -O0):
<handle_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc9,%edx
call   1070 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0xc8,%edx
call   1080 <read@plt>
mov    -0x4(%rbp),%esi
lea    -0xd0(%rbp),%rdx
lea    0xe5a(%rip),%rdi
call   1060 <printf@plt>
lea    -0xd0(%rbp),%rdi
call   1030 <string_modificator@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xdc(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0xd0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xdc(%rbp),%edi
mov    -0xd8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <write@plt>
mov    -0x4(%rbp),%esi
lea    -0xd0(%rbp),%rdx
lea    0xe1c(%rip),%rdi
call   1060 <printf@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_connection>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc9,%edx
call   1070 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc8,%edx
call   1080 <read@plt>
lea    0xe6c(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <string_modificator@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <write@plt>
lea    0xe5d(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   1060 <printf@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"message received (fd = %d): %s\0A\00"
@.str.1 = [28 x i8] c"message send (fd = %d): %s\0A\00"
define void @handle_connection(i32 %0) {
%2 = alloca i32
%3 = alloca [201 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i8 signext 0, i32 201)
%6 = load i32, i32* %2
%7 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%8 = call i32 @read(i32 %6, i8* %7, i32 200)
%9 = load i32, i32* %2
%10 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %10)
%12 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%13 = call i32 @string_modificator(i8* %12)
%14 = load i32, i32* %2
%15 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i32 @write(i32 %14, i8* %15, i64 %18)
%20 = load i32, i32* %2
%21 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"message received (fd = %d): %s\0A\00"
@.str.1 = [28 x i8] c"message send (fd = %d): %s\0A\00"
define void @handle_connection(i32 %0) {
%2 = alloca [201 x i8]
%3 = getelementptr inbounds [201 x i8], [201 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i8 signext 0, i32 201)
%5 = call i32 @read(i32 %0, i8* %3, i32 200)
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %3)
%7 = call i32 @string_modificator(i8* %3)
%8 = call i64 @strlen(i8* %3)
%9 = add nsw i64 %8, 1
%10 = call i32 @write(i32 %0, i8* %3, i64 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %3)
ret void
}