#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 /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ EPOLLIN;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ add_event(int, int, int /*<<< orphan*/);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
void handle_accpet(int epollfd, int listenfd) {
  int clifd;
  struct sockaddr_in cliaddr;
  socklen_t cliaddrlen;
  clifd = accept(listenfd, (struct sockaddr *)&cliaddr, &cliaddrlen);
  if (clifd == -1)
    perror("accpet error:");
  else {
    printf("accept a new client: %s:%d\n", inet_ntoa(cliaddr.sin_addr),
           cliaddr.sin_port);
    add_event(epollfd, clifd, EPOLLIN);
  }
}


x86 assembly (clang, -O0):
<handle_accpet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <accept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    118c <handle_accpet+0x3c>
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
jmp    11ba <handle_accpet+0x6a>
mov    -0x14(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
call   1050 <add_event@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_accpet>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%eax
mov    %edi,%ebx
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    %eax,%edi
call   1070 <accept@plt>
cmp    $0xffffffff,%eax
je     11a7 <handle_accpet+0x57>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   1030 <inet_ntoa@plt>
mov    0x8(%rsp),%edx
lea    0xe88(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <add_event@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe52(%rip),%rdi
call   1060 <perror@plt>
jmp    11a0 <handle_accpet+0x50>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"accpet error:\00"
@.str.1 = [28 x i8] c"accept a new client: %s:%d\0A\00"
@EPOLLIN = global i32 0
define void @handle_accpet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%10 = call i32 @accept(i32 %8, %struct.sockaddr* %9, i32* %7)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %26
15: ; preds = %2
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, 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* %6, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %20)
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = load i32, i32* @EPOLLIN
%25 = call i32 @add_event(i32 %22, i32 %23, i32 %24)
br label %26
26: ; preds = %15, %13
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"accpet error:\00"
@.str.1 = [28 x i8] c"accept a new client: %s:%d\0A\00"
@EPOLLIN = global i32 0
define void @handle_accpet(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%8 = call i32 @accept(i32 %1, %struct.sockaddr* %7, i32* %4)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
12: ; preds = %2
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%14 = load i32, i32* %13
%15 = call i8* @inet_ntoa(i32 %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
%19 = load i32, i32* @EPOLLIN
%20 = call i32 @add_event(i32 %0, i32 %8, i32 %19)
br label %21
21: ; preds = %12, %10
ret void
}