// File: /workspace/github_c_makefile_star2_O0/qq-smart[P]qq_sh_server/core/qq_listening.c
// Function: qq_create_listening
qq_int_t
qq_create_listening(qq_cycle_t *cycle)
{
    size_t                  size;
    int                     i;
    qq_listening_t         *ls;
    qq_listening_config_t  *p, *n;

    size = sizeof(qq_listening_t) * cycle->nlistening;
    cycle->listening = qq_pcalloc(cycle->pool, size);
    if (cycle->listening == NULL) {
        qq_log_error(0, "qq_listening_t malloc(%u) failed", size);
        return QQ_ERROR;
    }

    cycle->current_listening_config = cycle->listening_config;

    ls = cycle->listening;
    for (i = 0; i < cycle->nlistening; i++) {
        ls[i].sockaddr.sin_family = AF_INET;
        ls[i].sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
        ls[i].sockaddr.sin_port = htons(cycle->current_listening_config->port);
        ls[i].socklen = sizeof(struct sockaddr);

        ls[i].addr_text_len = qq_sock_ntop(&ls[i].sockaddr, ls[i].addr_text);
        qq_log_debug("listening address: %s, address len: %d",
            ls[i].addr_text, ls[i].addr_text_len);

        ls[i].fd = (qq_socket_t) -1;
        ls[i].type = cycle->current_listening_config->type;

        ls[i].backlog = QQ_LISTEN_BACKLOG;
        ls[i].rcvbuf = QQ_SOCK_REVBUF_SIZE;
        ls[i].sndbuf = QQ_SOCK_SNDBUF_SIZE;

        ls[i].handler = cycle->current_listening_config->handler;
        ls[i].pool_size = cycle->current_listening_config->pool_size;

        cycle->current_listening_config = cycle->current_listening_config->next;
    }

    for (p = cycle->listening_config, n = cycle->listening_config->next;
         /* void */;
         p = n, n = n->next) {
        free(p);
        if (n == NULL) {
            break;
        }
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
imulq $0x60, 0x38(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xbb60
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x9260
movq -0x18(%rbp), %rdx
xorl %edi, %edi
leaq 0x677b(%rip), %rsi      # 0xf9c7
movb $0x0, %al
callq 0x9cc0
movq $-0x1, -0x8(%rbp)
jmp 0x9495
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x9449
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movw $0x2, 0x4(%rax)
xorl %edi, %edi
callq 0x21d0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl 0xc(%rax), %eax
movzwl %ax, %edi
callq 0x2040
movw %ax, %cx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movw %cx, 0x6(%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x10, 0x14(%rax)
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rsi
addq $0x18, %rsi
callq 0x4b00
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rsi
addq $0x18, %rsi
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %edx
leaq 0x6679(%rip), %rdi      # 0xf9e8
movb $0x0, %al
callq 0x9e70
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x34(%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x1ff, 0x38(%rax)      # imm = 0x1FF
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x2000, 0x3c(%rax)     # imm = 0x2000
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x2000, 0x40(%rax)     # imm = 0x2000
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9283
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2368
cmpq $0x0, -0x38(%rbp)
jne 0x9476
jmp 0x948d
jmp 0x9478
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x9464
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop