// File: /workspace/github_c_makefile_star2_O0/qq-smart[P]qq_sh_server/event/qq_event_accept.c
// Function: qq_event_recvmsg
void
qq_event_recvmsg(qq_event_t *ev)
{
    ssize_t            n;
    size_t             size;
    qq_err_t           err;
    struct iovec       iov[1];
    struct msghdr      msg;
    struct sockaddr    sa;
    qq_listening_t    *ls;
    qq_connection_t   *c;

    if (ev->timedout) {
        if (qq_enable_accept_events((qq_cycle_t *) qq_cycle) != QQ_OK) {
            return;
        }
        ev->timedout = 0;
    }

    c = ev->data;
    ls = c->listening;
    ev->ready = 0;

    qq_log_debug("qq_event_recvmsg() on %s, ready: %d", ls->addr_text, ev->available);

    if (c->pool == NULL) {
        qq_log_debug("c->pool == NULL");

        c->pool = qq_create_pool(ls->pool_size);
        if (c->pool == NULL) {
            qq_log_error(0, "qq_create_pool(%d) failed", ls->pool_size);
            return;
        }

        c->socklen = sizeof(struct sockaddr);
        c->sockaddr = qq_palloc(c->pool, c->socklen);
        if (c->sockaddr == NULL) {
            qq_destroy_pool(c->pool);
            c->pool = NULL;
            return;
        }

        c->addr_text = qq_palloc(c->pool, QQ_SOCKADDR_STRLEN);
        if (c->addr_text == NULL) {
            qq_destroy_pool(c->pool);
            c->pool = NULL;
            return;
        }

        c->buffer = qq_pcalloc(c->pool, sizeof(qq_buf_t));
        if (c->buffer == NULL) {
            qq_destroy_pool(c->pool);
            c->pool = NULL;
            return;
        }
        size = ls->pool_size -
            ((size_t)((uintptr_t)c->buffer - (uintptr_t)c->pool) + sizeof(qq_buf_t));
        c->buffer->start = qq_pnalloc(c->pool, size);
        if (c->buffer->start == NULL) {
            qq_destroy_pool(c->pool);
            c->pool = NULL;
            return;
        }
        c->buffer->pos = c->buffer->start;
        c->buffer->last = c->buffer->start;
        c->buffer->end = c->buffer->last + size;
        c->buffer->temporary = 1;

        c->shared = 1;
        c->send = qq_udp_send;
        c->local_sockaddr = (struct sockaddr *) &ls->sockaddr;
        c->local_socklen = ls->socklen;
    }

    memset(&msg, 0, sizeof(struct msghdr));

    iov[0].iov_base = (void *) c->buffer->pos;
    iov[0].iov_len = c->buffer->end - c->buffer->start;
    qq_log_debug("recvmsg(size: %d)", c->buffer->end - c->buffer->start);

    msg.msg_name = &sa;
    msg.msg_namelen = sizeof(struct sockaddr);
    msg.msg_iov = iov;
    msg.msg_iovlen = 1;

    n = recvmsg(c->fd, &msg, 0);

    if (n == -1) {
        err = errno;
        if (err == QQ_EAGAIN) {
            qq_log_debug("recvmsg() not ready");
            return;
        }

        qq_log_error(err, "recvmsg() failed");
        return;
    }

    memcpy(c->sockaddr, msg.msg_name, c->socklen);

    c->buffer->last += n;

    c->write->ready = 1;

    memset(c->addr_text, 0, QQ_SOCKADDR_STRLEN);
    c->addr_text_len = qq_sock_ntop((struct sockaddr_in *)c->sockaddr, c->addr_text);
    if (c->addr_text_len != 0) {
        qq_log_debug("connection address: %s, address len: %d",
            c->addr_text, c->addr_text_len);
    }

    ls->handler(c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x439e
leaq 0xff68(%rip), %rax      # 0x142e0
movq (%rax), %rdi
callq 0x4180
cmpq $0x0, %rax
je 0x438b
jmp 0x4872
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0xfffffbff, %ecx       # imm = 0xFFFFFBFF
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $-0x21, %ecx
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0x80(%rbp), %rsi
addq $0x18, %rsi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edx
shrl $0x14, %edx
andl $0x1, %edx
leaq 0xb301(%rip), %rdi      # 0xf6e8
movb $0x0, %al
callq 0x9e70
movq -0x88(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x46b7
leaq 0xb305(%rip), %rdi      # 0xf70c
movb $0x0, %al
callq 0x9e70
movq -0x80(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0xba30
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x4454
movq -0x80(%rbp), %rax
movq 0x50(%rax), %rdx
xorl %edi, %edi
leaq 0xae19(%rip), %rsi      # 0xf261
movb $0x0, %al
callq 0x9cc0
jmp 0x4872
movq -0x88(%rbp), %rax
movl $0x10, 0x58(%rax)
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x88(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, %esi
callq 0xba90
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x44be
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x2368
movq -0x88(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x4872
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
movl $0x16, %esi
callq 0xba90
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x4513
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x2368
movq -0x88(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x4872
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
movl $0x38, %esi
callq 0xbb60
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x4568
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x2368
movq -0x88(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x4872
movq -0x80(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x88(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x88(%rbp), %rdx
movq 0x40(%rdx), %rdx
subq %rdx, %rcx
addq $0x38, %rcx
subq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xbb00
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x45f0
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x2368
movq -0x88(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x4872
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rcx
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, (%rax)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rcx
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rcx
addq -0x18(%rbp), %rcx
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movw 0x30(%rax), %cx
andw $-0x2, %cx
orw $0x1, %cx
movw %cx, 0x30(%rax)
movq -0x88(%rbp), %rax
movb 0x98(%rax), %cl
andb $-0x41, %cl
orb $0x40, %cl
movb %cl, 0x98(%rax)
movq -0x88(%rbp), %rax
leaq 0x8f71(%rip), %rcx      # 0xd600
movq %rcx, 0x30(%rax)
movq -0x80(%rbp), %rcx
addq $0x4, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x80(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x78(%rax)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2170
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq -0x88(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rsi
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rax
subq %rax, %rsi
leaq 0xaff6(%rip), %rdi      # 0xf71c
movb $0x0, %al
callq 0x9e70
leaq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x10, -0x60(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x1, -0x50(%rbp)
movq -0x88(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0x2090
movq %rax, -0x10(%rbp)
cmpq $-0x1, -0x10(%rbp)
jne 0x47a5
callq 0x2030
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0xb, -0x1c(%rbp)
jne 0x478f
leaq 0xafab(%rip), %rdi      # 0xf72e
movb $0x0, %al
callq 0x9e70
jmp 0x4872
movl -0x1c(%rbp), %edi
leaq 0xafa9(%rip), %rsi      # 0xf742
movb $0x0, %al
callq 0x9cc0
jmp 0x4872
movq -0x88(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x68(%rbp), %rsi
movq -0x88(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, %edx
callq 0x21e0
movq -0x10(%rbp), %rcx
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %ecx
andl $-0x21, %ecx
orl $0x20, %ecx
movl %ecx, 0x8(%rax)
movq -0x88(%rbp), %rax
movq 0x60(%rax), %rdi
xorl %esi, %esi
movl $0x16, %edx
callq 0x2170
movq -0x88(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x88(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x4b00
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x88(%rbp), %rax
cmpl $0x0, 0x68(%rax)
je 0x4861
movq -0x88(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x88(%rbp), %rax
movl 0x68(%rax), %edx
leaq 0xae66(%rip), %rdi      # 0xf6c0
movb $0x0, %al
callq 0x9e70
movq -0x80(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x88(%rbp), %rdi
callq *%rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)