// File: /workspace/github_cpp_makefile_star2_O2/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 0x29c8
testl %ebx, %ebx
jns 0x2d85
callq 0x2030
movq %rax, %r15
movl (%rax), %r14d
leaq 0x434(%rip), %rsi       # 0x30bf
leaq 0x505(%rip), %rcx       # 0x3197
leaq 0x10(%rsp), %r12
pushq $0x37
popq %rdx
pushq $0x4
popq %r8
movq %r12, %rdi
callq 0x2670
movq %r12, %rdi
callq 0x28be
addq $0x10, %rax
leaq 0x4d5(%rip), %rsi       # 0x318e
movq %rax, %rdi
callq 0x21c0
leaq 0x10(%rsp), %rdi
callq 0x27b0
cmpl $0x18, %r14d
ja 0x2ceb
movl $0xc05200, %eax         # imm = 0xC05200
btl %r14d, %eax
jb 0x2d08
movl $0x1000812, %eax        # imm = 0x1000812
btl %r14d, %eax
jb 0x2d82
leal -0x47(%r14), %eax
cmpl $0x22, %eax
ja 0x2d96
movabsq $0x401020000, %rcx      # imm = 0x401020000
btq %rax, %rcx
jae 0x2d72
leaq 0x3b0(%rip), %rsi       # 0x30bf
leaq 0x481(%rip), %rcx       # 0x3197
leaq 0x10(%rsp), %r15
pushq $0x49
popq %rdx
pushq $0x5
popq %r8
movq %r15, %rdi
callq 0x2670
movq %r15, %rdi
callq 0x28be
addq $0x10, %rax
leaq 0x461(%rip), %rsi       # 0x319e
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2270
movq %rax, %r15
movl %r14d, %edi
callq 0x2090
movq %r15, %rdi
movq %rax, %rsi
callq 0x21c0
leaq 0x10(%rsp), %rdi
callq 0x27b0
jmp 0x2d85
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jae 0x2d96
movl %r14d, (%r15)
movl %ebx, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x322(%rip), %rsi       # 0x30bf
leaq 0x3f3(%rip), %rcx       # 0x3197
leaq 0x10(%rsp), %r15
pushq $0x4d
popq %rdx
pushq $0x5
popq %r8
movq %r15, %rdi
callq 0x2670
movq %r15, %rdi
callq 0x28be
addq $0x10, %rax
leaq 0x3f2(%rip), %rsi       # 0x31bd
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2270
jmp 0x2d66
jmp 0x2de4
jmp 0x2de4
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x27b0
movq %rbx, %rdi
callq 0x2290