#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 IPC_CREAT;
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, ...);
int *shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int shmget(int, int, 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);
  int shmid = shmget(1234, 512, IPC_CREAT | 0644);
  int *max = shmat(shmid, NULL, 0);
  printf("a client connected:ip = %s,port = %d,current online=%d\n",
         inet_ntoa(c_addr.sin_addr), c_addr.sin_port, *max);
  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    0x2e47(%rip),%rax
mov    (%rax),%edx
or     $0x1a4,%edx
mov    $0x4d2,%edi
mov    $0x200,%esi
call   1080 <shmget@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <shmat@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
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    0xe34(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<data_process>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
movl   $0x4,0x14(%rsp)
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1050 <getpeername@plt>
mov    0x2e4a(%rip),%rax
mov    $0x1a4,%edx
or     (%rax),%edx
mov    $0x4d2,%edi
mov    $0x200,%esi
call   1080 <shmget@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <shmat@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    0x8(%rsp),%edx
mov    (%rbx),%ecx
lea    0xe30(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
call   1030 <get_client_data@plt>
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    0x8(%rsp),%edx
lea    0xe43(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@IPC_CREAT = global i32 0
@.str = [56 x i8] c"a client connected:ip = %s,port = %d,current online=%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
%5 = alloca i32
%6 = alloca i32*
store i32 %0, i32* %2
store i32 4, i32* %4
%7 = load i32, i32* %2
%8 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%9 = call i32 @getpeername(i32 %7, %struct.sockaddr* %8, i32* %4)
%10 = load i32, i32* @IPC_CREAT
%11 = or i32 %10, 420
%12 = call i32 @shmget(i32 1234, i32 512, i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i32* @shmat(i32 %13, i32* null, i32 0)
store i32* %14, i32** %6
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%16 = load i32, i32* %15
%17 = call i8* @inet_ntoa(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %19, i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @get_client_data(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%26 = load i32, i32* %25
%27 = call i8* @inet_ntoa(i32 %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %29)
%31 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@IPC_CREAT = global i32 0
@.str = [56 x i8] c"a client connected:ip = %s,port = %d,current online=%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 = load i32, i32* @IPC_CREAT
%9 = or i32 %8, 420
%10 = call i32 @shmget(i32 1234, i32 512, i32 %9)
%11 = call i32* @shmat(i32 %10, i32* null, i32 0)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%13 = load i32, i32* %12
%14 = call i8* @inet_ntoa(i32 %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* %11
%18 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %16, i32 %17)
%19 = call i32 @get_client_data(i32 %0)
%20 = load i32, i32* %12
%21 = call i8* @inet_ntoa(i32 %20)
%22 = load i32, i32* %15
%23 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %22)
%24 = call i32 @exit(i32 0)
unreachable
}