#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 */
struct sockaddr_in {
  int sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ get_client_data(int);
int /*<<< orphan*/ getpeername(int, struct sockaddr *, int *);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, int);
void data_process(int client_fd) {
  struct sockaddr_in c_addr;
  socklen_t c_len = sizeof(struct sockaddr);
  getpeername(client_fd, (struct sockaddr *)&c_addr, &c_len);
  printf("a client connected:ip = %s,port = %d\n", inet_ntoa(c_addr.sin_addr),
         c_addr.sin_port);
  get_client_data(client_fd);
  printf("a client disconnected:ip = %s,port = %d\n",
         inet_ntoa(c_addr.sin_addr), c_addr.sin_port);
  exit(0);
}


x86 assembly (clang, -O0):
<data_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <getpeername@plt>
mov    -0xc(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%edx
lea    0xe79(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <get_client_data@plt>
mov    -0xc(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%edx
lea    0xe7d(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<data_process>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x4,0xc(%rsp)
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
call   1050 <getpeername@plt>
mov    0x4(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    (%rsp),%edx
lea    0xe81(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <get_client_data@plt>
mov    0x4(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    (%rsp),%edx
lea    0xe85(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [38 x i8] c"a client connected:ip = %s,port = %d\0A\00"
@.str.1 = [41 x i8] c"a client disconnected:ip = %s,port = %d\0A\00"
define void @data_process(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %4
%5 = load i32, i32* %2
%6 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%7 = call i32 @getpeername(i32 %5, %struct.sockaddr* %6, i32* %4)
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i8* @inet_ntoa(i32 %9)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @get_client_data(i32 %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i8* @inet_ntoa(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %20)
%22 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [38 x i8] c"a client connected:ip = %s,port = %d\0A\00"
@.str.1 = [41 x i8] c"a client disconnected:ip = %s,port = %d\0A\00"
define void @data_process(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%6 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%7 = call i32 @getpeername(i32 %0, %struct.sockaddr* %6, i32* %3)
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%9 = load i32, i32* %8
%10 = call i8* @inet_ntoa(i32 %9)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %12)
%14 = call i32 @get_client_data(i32 %0)
%15 = load i32, i32* %8
%16 = call i8* @inet_ntoa(i32 %15)
%17 = load i32, i32* %11
%18 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
%19 = call i32 @exit(i32 0)
unreachable
}