// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
movl %edi, %ebp
movl $0x41c8, %edi           # imm = 0x41C8
callq 0x327b9
movq %rax, %rbx
cmpl $-0x1, %ebp
je 0x361ae
xorl %edi, %edi
movl %ebp, %esi
callq 0x2929c
xorl %edi, %edi
movl %ebp, %esi
callq 0x2939b
leaq 0xc372f(%rip), %r14     # 0xf98a8
movl 0x600(%r14), %edx
testl %edx, %edx
je 0x3618d
xorl %edi, %edi
movl %ebp, %esi
callq 0x292ab
movq 0x40(%r14), %rdi
leaq 0x199(%rip), %rcx       # 0x36331
pushq $0x1
popq %rdx
movl %ebp, %esi
movq %rbx, %r8
callq 0x28ae8
cmpl $-0x1, %eax
je 0x36314
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3b3b1
leaq 0xc36e9(%rip), %r15     # 0xf98a8
movq 0x310(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x310(%r15)
movq %rax, (%rbx)
movl %ebp, 0x8(%rbx)
andq $0x0, 0x20(%rbx)
andl $0x0, 0x1c0(%rbx)
callq 0x3114c
movq %rax, 0x28(%rbx)
andq $0x0, 0x30(%rbx)
andl $0x0, 0x38(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x50(%rbx)
orq $-0x1, 0x60(%rbx)
andq $0x0, 0x78(%rbx)
movq 0x978(%r15), %rax
movq %rax, 0x88(%rbx)
movq %rax, 0x80(%rbx)
movups %xmm0, 0x98(%rbx)
andl $0x0, 0x114(%rbx)
movb $0x0, 0x118(%rbx)
andl $0x0, 0x148(%rbx)
movups %xmm0, 0xc8(%rbx)
andq $0x0, 0xd8(%rbx)
callq 0x26e0c
movq %rax, 0x68(%rbx)
andq $0x0, 0x70(%rbx)
andq $0x0, 0x90(%rbx)
leaq 0x409d(%rip), %r12      # 0x3a304
movq %r12, 0x18(%rax)
leaq -0x141(%rip), %rcx      # 0x36131
movq %rcx, 0x10(%rax)
andl $0x0, 0x168(%rbx)
andq $0x0, 0x170(%rbx)
leaq 0xc2b24(%rip), %r14     # 0xf8db0
movq %r14, %rdi
xorl %esi, %esi
callq 0x2a155
movq %rax, 0x178(%rbx)
andq $0x0, 0x180(%rbx)
andl $0x0, 0x188(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x190(%rbx)
callq 0x26e0c
movq %rax, 0x1a0(%rbx)
movq %r14, %rdi
xorl %esi, %esi
callq 0x2a155
movq %rax, 0x1a8(%rbx)
callq 0x26e0c
andq $0x0, 0x1b8(%rbx)
movq %rax, 0x1b0(%rbx)
movq %r12, 0x18(%rax)
leaq -0x1b3(%rip), %rcx      # 0x3613f
movq %rcx, 0x20(%rax)
cmpl $-0x1, %ebp
je 0x3630a
movq 0x1c8(%r15), %rdi
movq %rbx, %rsi
callq 0x26ecc
movq %rbx, %rdi
callq 0x56d90
jmp 0x36325
movl %ebp, %edi
callq 0x26180
movq %rbx, %rdi
callq 0x328f9
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq