// File: /workspace/github_cpp_makefile_star2_O1/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 0x2bc0
testl %ebx, %ebx
jns 0x3085
callq 0x2040
movq %rax, %r15
movl (%rax), %r14d
leaq 0x1220(%rip), %rsi      # 0x410a
leaq 0x12f1(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x37, %edx
movl $0x4, %r8d
callq 0x26d0
movq %r12, %rdi
callq 0x2a32
addq $0x10, %rax
leaq 0x12bd(%rip), %rsi      # 0x41d9
movl $0xf, %edx
movq %rax, %rdi
callq 0x21f0
leaq 0x10(%rsp), %rdi
callq 0x28e4
cmpl $0x18, %r14d
ja 0x2f53
movl $0xc05200, %eax         # imm = 0xC05200
btl %r14d, %eax
jb 0x2f74
movl $0x1000812, %eax        # imm = 0x1000812
btl %r14d, %eax
jb 0x3022
leal -0x47(%r14), %eax
cmpl $0x22, %eax
ja 0x3027
movabsq $0x401020000, %rcx      # imm = 0x401020000
btq %rax, %rcx
jae 0x3012
leaq 0x118f(%rip), %rsi      # 0x410a
leaq 0x1260(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x49, %edx
movl $0x5, %r8d
callq 0x26d0
movq %r15, %rdi
callq 0x2a32
movq %rax, %r15
addq $0x10, %r15
leaq 0x1239(%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 0x2ff6
movq %rax, %r14
movq %rax, %rdi
callq 0x2100
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x307b
movq (%r15), %rax
movq -0x18(%rax), %rax
movq %r15, %rdi
addq %rax, %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x2280
jmp 0x307b
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jae 0x3027
movl %r14d, (%r15)
jmp 0x3085
leaq 0x10dc(%rip), %rsi      # 0x410a
leaq 0x11ad(%rip), %rcx      # 0x41e2
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x4d, %edx
movl $0x5, %r8d
callq 0x26d0
movq %r15, %rdi
callq 0x2a32
movq %rax, %r15
addq $0x10, %r15
leaq 0x11a5(%rip), %rsi      # 0x4208
movl $0x1b, %edx
movq %r15, %rdi
callq 0x21f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2290
leaq 0x10(%rsp), %rdi
callq 0x28e4
movl %ebx, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x309a
jmp 0x309a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x28e4
movq %rbx, %rdi
callq 0x22b0