// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/networking.c
// Function: freeClient
void freeClient(client *c) {
    listNode *ln;

    /* If it is our master that's beging disconnected we should make sure
     * to cache the state to try a partial resynchronization later.
     *
     * Note that before doing this we make sure that the client is not in
     * some unexpected state, by checking its flags. */
    if (server.master && c->flags & CLIENT_MASTER) {
        serverLog(LL_WARNING,"Connection with master lost.");
        if (!(c->flags & (CLIENT_CLOSE_AFTER_REPLY|
                          CLIENT_CLOSE_ASAP|
                          CLIENT_BLOCKED|
                          CLIENT_UNBLOCKED)))
        {
            replicationCacheMaster(c);
            return;
        }
    }

    /* Log link disconnection with slave */
    if ((c->flags & CLIENT_SLAVE) && !(c->flags & CLIENT_MONITOR)) {
        serverLog(LL_WARNING,"Connection with slave %s lost.",
            replicationGetSlaveName(c));
    }

    /* Free the query buffer */
    sdsfree(c->querybuf);
    c->querybuf = NULL;

    /* Deallocate structures used to block on blocking ops. */
    if (c->flags & CLIENT_BLOCKED) unblockClient(c);
    dictRelease(c->bpop.keys);

    /* UNWATCH all the keys */
    unwatchAllKeys(c);
    listRelease(c->watched_keys);

    /* Unsubscribe from all the pubsub channels */
    pubsubUnsubscribeAllChannels(c,0);
    pubsubUnsubscribeAllPatterns(c,0);
    dictRelease(c->pubsub_channels);
    listRelease(c->pubsub_patterns);

    /* Free data structures. */
    listRelease(c->reply);
    freeClientArgv(c);

    /* Unlink the client: this will close the socket, remove the I/O
     * handlers, and remove references of the client from different
     * places where active clients may be referenced. */
    unlinkClient(c);

    /* Master/slave cleanup Case 1:
     * we lost the connection with a slave. */
    if (c->flags & CLIENT_SLAVE) {
        if (c->replstate == SLAVE_STATE_SEND_BULK) {
            if (c->repldbfd != -1) close(c->repldbfd);
            if (c->replpreamble) sdsfree(c->replpreamble);
        }
        list *l = (c->flags & CLIENT_MONITOR) ? server.monitors : server.slaves;
        ln = listSearchKey(l,c);
        serverAssert(ln != NULL);
        listDelNode(l,ln);
        /* We need to remember the time when we started to have zero
         * attached slaves, as after some time we'll free the replication
         * backlog. */
        if (c->flags & CLIENT_SLAVE && listLength(server.slaves) == 0)
            server.repl_no_slaves_since = server.unixtime;
        refreshGoodSlavesCount();
    }

    /* Master/slave cleanup Case 2:
     * we lost the connection with the master. */
    if (c->flags & CLIENT_MASTER) replicationHandleMasterDisconnection();

    /* If this client was scheduled for async freeing we need to remove it
     * from the queue. */
    if (c->flags & CLIENT_CLOSE_ASAP) {
        ln = listSearchKey(server.clients_to_close,c);
        serverAssert(ln != NULL);
        listDelNode(server.clients_to_close,ln);
    }

    /* Release other dynamically allocated client structure fields,
     * and finally release the client structure itself. */
    if (c->name) decrRefCount(c->name);
    zfree(c->argv);
    freeClientMultiState(c);
    sdsfree(c->peerid);
    zfree(c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x134325(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x838(%rax)
je 0x43f06
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x43f06
movl $0x3, %edi
leaq 0xf6c14(%rip), %rsi     # 0x13aaef
movb $0x0, %al
callq 0x2fc60
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x4d0, %eax            # imm = 0x4D0
cmpl $0x0, %eax
jne 0x43f04
movq -0x8(%rbp), %rdi
callq 0x51e40
jmp 0x441fa
jmp 0x43f06
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x43f49
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x43f49
movq -0x8(%rbp), %rdi
callq 0x4d700
movq %rax, %rdx
movl $0x3, %edi
leaq 0xf6bca(%rip), %rsi     # 0x13ab0c
movb $0x0, %al
callq 0x2fc60
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x38620
movq -0x8(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x43f7d
movq -0x8(%rbp), %rdi
callq 0x9d930
movq -0x8(%rbp), %rax
movq 0x178(%rax), %rdi
callq 0x2e230
movq -0x8(%rbp), %rdi
callq 0x75980
movq -0x8(%rbp), %rax
movq 0x1a0(%rax), %rdi
callq 0x26ea0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x74db0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x74eb0
movq -0x8(%rbp), %rax
movq 0x1a8(%rax), %rdi
callq 0x2e230
movq -0x8(%rbp), %rax
movq 0x1b0(%rax), %rdi
callq 0x26ea0
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x26ea0
movq -0x8(%rbp), %rdi
callq 0x44400
movq -0x8(%rbp), %rdi
callq 0x44200
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4412b
movq -0x8(%rbp), %rax
cmpl $0x8, 0xa0(%rax)
jne 0x4405a
movq -0x8(%rbp), %rax
cmpl $-0x1, 0xa8(%rax)
je 0x4403a
movq -0x8(%rbp), %rax
movl 0xa8(%rax), %edi
callq 0x26180
movq -0x8(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
je 0x44058
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x38620
jmp 0x4405a
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x44080
leaq 0x134165(%rip), %rax    # 0x1781d8
movq 0x1e8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x44092
leaq 0x134151(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x274d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x440b4
jmp 0x440d6
leaq 0xf6a29(%rip), %rdi     # 0x13aae4
leaq 0xf6974(%rip), %rsi     # 0x13aa36
movl $0x350, %edx            # imm = 0x350
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x44126
leaq 0x1340dc(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rax
cmpq $0x0, 0x28(%rax)
jne 0x44126
leaq 0x1340c7(%rip), %rax    # 0x1781d8
movq 0x978(%rax), %rcx
leaq 0x1340b9(%rip), %rax    # 0x1781d8
movq %rcx, 0x800(%rax)
callq 0x4e850
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x44142
callq 0x51920
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x441b3
leaq 0x13407b(%rip), %rax    # 0x1781d8
movq 0x1d0(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x274d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4417a
jmp 0x4419c
leaq 0xf6963(%rip), %rdi     # 0x13aae4
leaq 0xf68ae(%rip), %rsi     # 0x13aa36
movl $0x362, %edx            # imm = 0x362
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
leaq 0x134035(%rip), %rax    # 0x1781d8
movq 0x1d0(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x441cb
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x48f70
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x3afa0
movq -0x8(%rbp), %rdi
callq 0x75780
movq -0x8(%rbp), %rax
movq 0x1b8(%rax), %rdi
callq 0x38620
movq -0x8(%rbp), %rdi
callq 0x3afa0
addq $0x20, %rsp
popq %rbp
retq