// File: /workspace/github_c_makefile_star2_O0/qq-smart[P]qq_sh_server/core/qq_connection.c
// Function: qq_get_connection
qq_connection_t *
qq_get_connection(qq_socket_t s)
{
    qq_uint_t         instance;
    qq_event_t       *rev, *wev;
    qq_connection_t  *c;

    c = qq_cycle->free_connections;
    if (c == NULL) {
        qq_log_error(0, 
                     "qq_get_connection(connection_n:%u) worker_connections are not enough",
                     qq_cycle->connection_n);

        return NULL;
    }

    qq_cycle->free_connections = c->data;
    qq_cycle->free_connection_n--;

    rev = c->read;
    wev = c->write;

    memset(c, 0, sizeof(qq_connection_t));

    c->read = rev;
    c->write = wev;
    c->fd = s;

    instance = rev->instance;

    memset(rev, 0, sizeof(qq_event_t));
    memset(wev, 0, sizeof(qq_event_t));

    rev->instance = !instance;
    wev->instance = !instance;

    rev->index = QQ_INVALID_INDEX;
    wev->index = QQ_INVALID_INDEX;

    rev->data = c;
    wev->data = c;

    wev->write = 1;

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0xc(%rbp)
leaq 0x119ae(%rip), %rax     # 0x142e0
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x296f
leaq 0x11995(%rip), %rax     # 0x142e0
movq (%rax), %rax
movq 0x8(%rax), %rdx
xorl %edi, %edi
leaq 0xc851(%rip), %rsi      # 0xf1ac
movb $0x0, %al
callq 0x9cc0
movq $0x0, -0x8(%rbp)
jmp 0x2aa7
movq -0x30(%rbp), %rax
movq (%rax), %rcx
leaq 0x11963(%rip), %rax     # 0x142e0
movq (%rax), %rax
movq %rcx, 0x18(%rax)
leaq 0x11955(%rip), %rax     # 0x142e0
movq (%rax), %rax
movq 0x20(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0xa0, %edx
callq 0x2170
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0xc(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
shrl $0x2, %eax
andl $0x1, %eax
movl %eax, %eax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x2170
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x2170
cmpq $0x0, -0x18(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x1, %edx
shll $0x2, %edx
andl $-0x5, %ecx
orl %edx, %ecx
movl %ecx, 0x8(%rax)
cmpq $0x0, -0x18(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x1, %edx
shll $0x2, %edx
andl $-0x5, %ecx
orl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl $0xd0d0d0d0, %ecx       # imm = 0xD0D0D0D0
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movl $0xd0d0d0d0, %ecx       # imm = 0xD0D0D0D0
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
andl $-0x2, %ecx
orl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)