// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/networking.c
// Function: createClient
client *createClient(int fd) {
    client *c = zmalloc(sizeof(client));

    /* passing -1 as fd it is possible to create a non connected client.
     * This is useful since all the commands needs to be executed
     * in the context of a client. When commands are executed in other
     * contexts (for instance a Lua script) we need a non connected client. */
    if (fd != -1) {
        anetNonBlock(NULL,fd);
        anetEnableTcpNoDelay(NULL,fd);
        if (server.tcpkeepalive)
            anetKeepAlive(NULL,fd,server.tcpkeepalive);
        if (aeCreateFileEvent(server.el,fd,AE_READABLE,
            readQueryFromClient, c) == AE_ERR)
        {
            close(fd);
            zfree(c);
            return NULL;
        }
    }

    selectDb(c,0);
    c->id = server.next_client_id++;
    c->fd = fd;
    c->name = NULL;
    c->bufpos = 0;
    c->querybuf = sdsempty();
    c->querybuf_peak = 0;
    c->reqtype = 0;
    c->argc = 0;
    c->argv = NULL;
    c->cmd = c->lastcmd = NULL;
    c->multibulklen = 0;
    c->bulklen = -1;
    c->sentlen = 0;
    c->flags = 0;
    c->ctime = c->lastinteraction = server.unixtime;
    c->authenticated = 0;
    c->replstate = REPL_STATE_NONE;
    c->repl_put_online_on_ack = 0;
    c->reploff = 0;
    c->repl_ack_off = 0;
    c->repl_ack_time = 0;
    c->slave_listening_port = 0;
    c->slave_ip[0] = '\0';
    c->slave_capa = SLAVE_CAPA_NONE;
    c->reply = listCreate();
    c->reply_bytes = 0;
    c->obuf_soft_limit_reached_time = 0;
    listSetFreeMethod(c->reply,decrRefCountVoid);
    listSetDupMethod(c->reply,dupClientReplyValue);
    c->btype = BLOCKED_NONE;
    c->bpop.timeout = 0;
    c->bpop.keys = dictCreate(&setDictType,NULL);
    c->bpop.target = NULL;
    c->bpop.numreplicas = 0;
    c->bpop.reploffset = 0;
    c->woff = 0;
    c->watched_keys = listCreate();
    c->pubsub_channels = dictCreate(&setDictType,NULL);
    c->pubsub_patterns = listCreate();
    c->peerid = NULL;
    listSetFreeMethod(c->pubsub_patterns,decrRefCountVoid);
    listSetMatchMethod(c->pubsub_patterns,listMatchObjects);
    if (fd != -1) listAddNodeTail(server.clients,c);
    initClientMultiState(c);
    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
movl $0x41c8, %edi           # imm = 0x41C8
callq 0x382d1
movq %rax, %rbx
cmpl $-0x1, %ebp
je 0x3be43
xorl %edi, %edi
movl %ebp, %esi
callq 0x2d6a1
xorl %edi, %edi
movl %ebp, %esi
callq 0x2d7d3
leaq 0xc5a9c(%rip), %r14     # 0x1018a8
movl 0x600(%r14), %edx
testl %edx, %edx
je 0x3be20
xorl %edi, %edi
movl %ebp, %esi
callq 0x2d6b2
movq 0x40(%r14), %rdi
leaq 0x19e(%rip), %rcx       # 0x3bfc9
movl %ebp, %esi
movl $0x1, %edx
movq %rbx, %r8
callq 0x2ce46
cmpl $-0x1, %eax
je 0x3bfa6
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x420b7
leaq 0xc5a51(%rip), %r15     # 0x1018a8
movq 0x310(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x310(%r15)
movq %rax, (%rbx)
movl %ebp, 0x8(%rbx)
movq %r12, 0x20(%rbx)
movl %r12d, 0x1c0(%rbx)
callq 0x3628d
movq %rax, 0x28(%rbx)
movq %r12, 0x30(%rbx)
movl %r12d, 0x38(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x50(%rbx)
movq $-0x1, 0x60(%rbx)
movq %r12, 0x78(%rbx)
movq 0x978(%r15), %rax
movq %rax, 0x88(%rbx)
movq %rax, 0x80(%rbx)
movups %xmm0, 0x98(%rbx)
movl %r12d, 0x114(%rbx)
movb $0x0, 0x118(%rbx)
movl %r12d, 0x148(%rbx)
movq %r12, 0xd8(%rbx)
movups %xmm0, 0xc8(%rbx)
callq 0x2b17c
movq %rax, 0x68(%rbx)
movq %r12, 0x70(%rbx)
movq %r12, 0x90(%rbx)
leaq 0x4e3b(%rip), %r13      # 0x40d37
movq %r13, 0x18(%rax)
leaq -0x146(%rip), %rcx      # 0x3bdc1
movq %rcx, 0x10(%rax)
movl %r12d, 0x168(%rbx)
movq %r12, 0x170(%rbx)
leaq 0xc4e90(%rip), %r14     # 0x100db0
movq %r14, %rdi
xorl %esi, %esi
callq 0x2e68c
movq %rax, 0x178(%rbx)
movq %r12, 0x180(%rbx)
movl %r12d, 0x188(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x190(%rbx)
callq 0x2b17c
movq %rax, 0x1a0(%rbx)
movq %r14, %rdi
xorl %esi, %esi
callq 0x2e68c
movq %rax, 0x1a8(%rbx)
callq 0x2b17c
movq %rax, 0x1b0(%rbx)
movq %r12, 0x1b8(%rbx)
movq %r13, 0x18(%rax)
leaq -0x1b5(%rip), %rcx      # 0x3bdcf
movq %rcx, 0x20(%rax)
cmpl $-0x1, %ebp
je 0x3bf9c
movq 0x1c8(%r15), %rdi
movq %rbx, %rsi
callq 0x2b24b
movq %rbx, %rdi
callq 0x60988
jmp 0x3bfb7
movl %ebp, %edi
callq 0x26180
movq %rbx, %rdi
callq 0x38413
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq