#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int read(int, char *, int);
void *handler(void *arg) {
  int *p = (int *)arg;
  int ret;
  int fd = *p;
  char buff[1024];
  while (1) {
    memset(buff, 0, 1024);
    ret = read(fd, buff, 1024);
    printf("recv message:%s:%s\n", buff, buff + 20);
  }
}


x86 assembly (clang, -O0):
<handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
lea    -0x420(%rbp),%rsi
lea    -0x420(%rbp),%rdx
add    $0x14,%rdx
mov    %rdx,-0x428(%rbp)
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    1150 <handler+0x20>

x86 assembly (clang, -O2):
<handler>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    (%rdi),%ebp
lea    0x14(%rsp),%r14
mov    %rsp,%rbx
lea    0xeb2(%rip),%r15
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
jmp    1150 <handler+0x20>

LLVM IR (-O0):
@.str = [20 x i8] c"recv message:%s:%s\0A\00"
define i8* @handler(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = load i32, i32* %9
store i32 %10, i32* %5
br label %11
11: ; preds = %1, %11
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 1024)
%14 = load i32, i32* %5
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i32 @read(i32 %14, i8* %15, i32 1024)
store i32 %16, i32* %4
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 20
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %19)
br label %11
}

LLVM IR (-O2):
@.str = [20 x i8] c"recv message:%s:%s\0A\00"
define noalias i8* @handler(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 20
br label %7
7: ; preds = %7, %1
%8 = call i32 @memset(i8* %5, i32 0, i32 1024)
%9 = call i32 @read(i32 %4, i8* %5, i32 1024)
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
br label %7
}