// File: /workspace/github_cpp_makefile_star2_O3/Rjerk[P]ratabase/Sockets.cpp
// Function: sockets::accept(int, sockaddr_in6*)
int sockets::accept(int sockfd, struct sockaddr_in6* addr)
{
    socklen_t addrlen = static_cast<socklen_t>(sizeof(*addr));
    int connfd = ::accept(sockfd,
            static_cast<struct sockaddr*>((void*)addr), &addrlen);
    setNonBlockAndCloseOnExec(connfd);
    if (connfd < 0) {
        auto saved_errno = errno;
        LOG_ERROR << "sockets::accept";
        switch (saved_errno) {
            case EAGAIN:
            case ECONNABORTED:
            case EINTR:
            case EPROTO:
            case EPERM:
            case EMFILE:
                errno = saved_errno;
                break;
            case EBADF:
            case EFAULT:
            case EINVAL:
            case ENFILE:
            case ENOBUFS:
            case ENOMEM:
            case ENOTSOCK:
            case EOPNOTSUPP:
                LOG_FATAL << "unexpected error of ::accpet: "
                          << saved_errno << ::strerror(saved_errno);
                break;
            default:
                LOG_FATAL << "unknown error of ::accept: " << saved_errno;
                break;
        }
    }
    return connfd;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
leaq 0xc(%rsp), %rdx
movl $0x1c, (%rdx)
callq 0x2080
movl %eax, %ebx
movl %eax, %edi
callq 0x2bb4
testl %ebx, %ebx
jns 0x3079
callq 0x2040
movq %rax, %r15
movl (%rax), %r14d
leaq 0x122c(%rip), %rsi      # 0x410a
leaq 0x12fd(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x37, %edx
movl $0x4, %r8d
callq 0x26ce
movq %r12, %rdi
callq 0x2a30
addq $0x10, %rax
leaq 0x12c9(%rip), %rsi      # 0x41d9
movl $0xf, %edx
movq %rax, %rdi
callq 0x21f0
leaq 0x10(%rsp), %rdi
callq 0x28e2
cmpl $0x18, %r14d
ja 0x2f47
movl $0xc05200, %eax         # imm = 0xC05200
btl %r14d, %eax
jb 0x2f68
movl $0x1000812, %eax        # imm = 0x1000812
btl %r14d, %eax
jb 0x3016
leal -0x47(%r14), %eax
cmpl $0x22, %eax
ja 0x301b
movabsq $0x401020000, %rcx      # imm = 0x401020000
btq %rax, %rcx
jae 0x3006
leaq 0x119b(%rip), %rsi      # 0x410a
leaq 0x126c(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x49, %edx
movl $0x5, %r8d
callq 0x26ce
movq %r15, %rdi
callq 0x2a30
movq %rax, %r15
addq $0x10, %r15
leaq 0x1245(%rip), %rsi      # 0x41e9
movl $0x1e, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2290
movq %rax, %r15
movl %r14d, %edi
callq 0x20a0
testq %rax, %rax
je 0x2fea
movq %rax, %r14
movq %rax, %rdi
callq 0x2100
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x306f
movq (%r15), %rax
movq -0x18(%rax), %rax
movq %r15, %rdi
addq %rax, %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x2280
jmp 0x306f
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jae 0x301b
movl %r14d, (%r15)
jmp 0x3079
leaq 0x10e8(%rip), %rsi      # 0x410a
leaq 0x11b9(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x4d, %edx
movl $0x5, %r8d
callq 0x26ce
movq %r15, %rdi
callq 0x2a30
movq %rax, %r15
addq $0x10, %r15
leaq 0x11b1(%rip), %rsi      # 0x4208
movl $0x1b, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2290
leaq 0x10(%rsp), %rdi
callq 0x28e2
movl %ebx, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x308e
jmp 0x308e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x28e2
movq %rbx, %rdi
callq 0x22b0