// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/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;
        }
    }

    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->reply = listCreate();
    c->reply_bytes = 0;
    c->obuf_soft_limit_reached_time = 0;
    listSetFreeMethod(c->reply,freeClientReplyValue);
    listSetDupMethod(c->reply,dupClientReplyValue);
    c->btype = BLOCKED_NONE;
    c->sub_counters = NULL;
    c->peerid = NULL;
    if (fd != -1) listAddNodeTail(server.clients,c);
    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0xc(%rbp)
movl $0x40c0, %edi           # imm = 0x40C0
callq 0x20a00
movq %rax, -0x18(%rbp)
cmpl $-0x1, -0xc(%rbp)
je 0x235bc
movl -0xc(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x14750
movl -0xc(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x14950
leaq 0x9bb96(%rip), %rax     # 0xbf0e8
cmpl $0x0, 0x5a0(%rax)
je 0x23574
movl -0xc(%rbp), %esi
leaq 0x9bb83(%rip), %rax     # 0xbf0e8
movl 0x5a0(%rax), %edx
xorl %eax, %eax
movl %eax, %edi
callq 0x147b0
leaq 0x9bb6d(%rip), %rax     # 0xbf0e8
movq 0x38(%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %r8
movl $0x1, %edx
leaq 0x1de(%rip), %rcx       # 0x23770
callq 0x137d0
cmpl $-0x1, %eax
jne 0x235ba
movl -0xc(%rbp), %edi
callq 0x123a0
movq -0x18(%rbp), %rdi
callq 0x20ce0
movq $0x0, -0x8(%rbp)
jmp 0x2375f
jmp 0x235bc
leaq 0x9bb25(%rip), %rax     # 0xbf0e8
movq 0x318(%rax), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
leaq 0x9bb10(%rip), %rax     # 0xbf0e8
movq %rdx, 0x318(%rax)
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0xb8(%rax)
callq 0x1e290
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x4c(%rax)
movq -0x18(%rbp), %rax
movq $-0x1, 0x50(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x88(%rax)
leaq 0x9ba50(%rip), %rax     # 0xbf0e8
movq 0x648(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x18(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8c(%rax)
callq 0x12b00
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x80(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
leaq -0x237(%rip), %rcx      # 0x234c0
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
leaq -0x26a(%rip), %rcx      # 0x234a0
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x90(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0xb0(%rax)
cmpl $-0x1, -0xc(%rbp)
je 0x23757
leaq 0x9b9a1(%rip), %rax     # 0xbf0e8
movq 0x1e0(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x12ce0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)