#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_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct DomainSocket {
  int dummy;
};
typedef int /*<<< orphan*/ ss;
typedef int socklen_t;

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ EINTR;
int accept(int, struct sockaddr *, int *);
scalar_t__ errno;
scalar_t__ evutil_make_socket_nonblocking(int);
int /*<<< orphan*/ new_domain_socket_client(struct DomainSocket *, int,
                                            struct sockaddr *, int);
void accept_socket(int fd, short what, void *arg) {
  struct DomainSocket *uds = (struct DomainSocket *)arg;
  struct sockaddr_storage ss;
  socklen_t addrlen = sizeof(ss);
  int nfd;
  do {
    ;
  } while (0);
  if ((nfd = accept(fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
    if (errno != EAGAIN && errno != EINTR) {
      do {
        ;
      } while (0);
    }
    return;
  }
  if (evutil_make_socket_nonblocking(nfd) < 0) {
    return;
  }
  new_domain_socket_client(uds, nfd, (struct sockaddr *)&ss, addrlen);
}


x86 assembly (clang, -O0):
<accept_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %edi,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
jmp    115a <accept_socket+0x2a>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <accept@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    11be <accept_socket+0x8e>
mov    0x2e63(%rip),%rax
mov    (%rax),%rax
mov    0x2e41(%rip),%rcx
cmp    (%rcx),%rax
je     11b9 <accept_socket+0x89>
mov    0x2e49(%rip),%rax
mov    (%rax),%rax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
je     11b9 <accept_socket+0x89>
jmp    11af <accept_socket+0x7f>
jmp    11b4 <accept_socket+0x84>
jmp    11b9 <accept_socket+0x89>
jmp    11e8 <accept_socket+0xb8>
mov    -0x28(%rbp),%edi
call   1050 <evutil_make_socket_nonblocking@plt>
cmp    $0x0,%rax
jge    11d5 <accept_socket+0xa5>
jmp    11e8 <accept_socket+0xb8>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <new_domain_socket_client@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_socket>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
movl   $0x4,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <accept@plt>
cmp    $0xffffffff,%eax
je     1176 <accept_socket+0x46>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <evutil_make_socket_nonblocking@plt>
test   %rax,%rax
js     1176 <accept_socket+0x46>
mov    0xc(%rsp),%ecx
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <new_domain_socket_client@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.DomainSocket = type { i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EAGAIN = global i64 0
@EINTR = global i64 0
define void @accept_socket(i32 %0, i16 signext %1, i8* %2) {
%4 = alloca i32
%5 = alloca i16
%6 = alloca i8*
%7 = alloca %struct.DomainSocket*
%8 = alloca %struct.sockaddr_storage
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%11 = load i8*, i8** %6
%12 = bitcast i8* %11 to %struct.DomainSocket*
store %struct.DomainSocket* %12, %struct.DomainSocket** %7
store i32 4, i32* %9
br label %13
13: ; preds = %3
br label %14
14: ; preds = %13
%15 = load i32, i32* %4
%16 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%17 = call i32 @accept(i32 %15, %struct.sockaddr* %16, i32* %9)
store i32 %17, i32* %10
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = load i64, i64* @errno
%21 = load i64, i64* @EAGAIN
%22 = icmp ne i64 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i64, i64* @errno
%25 = load i64, i64* @EINTR
%26 = icmp ne i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29, %23, %19
br label %42
31: ; preds = %14
%32 = load i32, i32* %10
%33 = call i64 @evutil_make_socket_nonblocking(i32 %32)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %42
36: ; preds = %31
%37 = load %struct.DomainSocket*, %struct.DomainSocket** %7
%38 = load i32, i32* %10
%39 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%40 = load i32, i32* %9
%41 = call i32 @new_domain_socket_client(%struct.DomainSocket* %37, i32 %38, %struct.sockaddr* %39, i32 %40)
br label %42
42: ; preds = %36, %35, %30
ret void
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.DomainSocket = type { i32 }
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EAGAIN = global i64 0
@EINTR = global i64 0
define void @accept_socket(i32 %0, i16 signext %1, i8* %2) {
%4 = alloca %struct.sockaddr_storage
%5 = alloca i32
%6 = bitcast i8* %2 to %struct.DomainSocket*
%7 = bitcast %struct.sockaddr_storage* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 4, i32* %5
%9 = bitcast %struct.sockaddr_storage* %4 to %struct.sockaddr*
%10 = call i32 @accept(i32 %0, %struct.sockaddr* %9, i32* %5)
%11 = icmp eq i32 %10, -1
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = call i64 @evutil_make_socket_nonblocking(i32 %10)
%14 = icmp slt i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %5
%17 = call i32 @new_domain_socket_client(%struct.DomainSocket* %6, i32 %10, %struct.sockaddr* %9, i32 %16)
br label %18
18: ; preds = %12, %3, %15
ret void
}