#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*/ bzero(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void client_dump(int sock_fd) {
  char rec[1024] = {0};
  int size;
  while ((size = read(sock_fd, rec, 1024)) > 0) {
    printf("****************************\n");
    printf("recv data is %s\n", rec);
    write(sock_fd, rec, size);
    bzero(rec, 1024);
  }
}


x86 assembly (clang, -O0):
<client_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,-0x414(%rbp)
cmp    $0x0,%eax
jle    11e2 <client_dump+0x92>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
call   1030 <write@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1070 <bzero@plt>
jmp    1171 <client_dump+0x21>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %edi,%r12d
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    11f5 <client_dump+0x95>
mov    %eax,%ebp
lea    0xe70(%rip),%r14
lea    0xe58(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1080 <bzero@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     11b0 <client_dump+0x50>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [17 x i8] c"recv data is %s\0A\00"
@str = [29 x i8] c"****************************\00"
define void @client_dump(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 1024)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1, %6
%7 = phi i32 [ %12, %6 ], [ %4, %1 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = call i32 @write(i32 %0, i8* %3, i32 %7)
%11 = call i32 @bzero(i8* %3, i32 1024)
%12 = call i32 @read(i32 %0, i8* %3, i32 1024)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %6, label %14
14: ; preds = %6, %1
ret void
}