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

    /* If this is marked as current client unset it. */
    if (server.current_client == c) server.current_client = NULL;

    /* Certain operations must be done only if the client has an active socket.
     * If the client was already unlinked or if it's a "fake client" the
     * fd is already set to -1. */
    if (c->fd != -1) {
        /* Remove from the list of active clients. */
        ln = listSearchKey(server.clients,c);
        serverAssert(ln != NULL);
        listDelNode(server.clients,ln);

        /* Unregister async I/O handlers and close the socket. */
        aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
        aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);
        close(c->fd);
        c->fd = -1;
    }

    /* Remove from the list of pending writes if needed. */
    if (c->flags & CLIENT_PENDING_WRITE) {
        ln = listSearchKey(server.clients_pending_write,c);
        serverAssert(ln != NULL);
        listDelNode(server.clients_pending_write,ln);
        c->flags &= ~CLIENT_PENDING_WRITE;
    }

    /* When client was just unblocked because of a blocking operation,
     * remove it from the list of unblocked clients. */
    if (c->flags & CLIENT_UNBLOCKED) {
        ln = listSearchKey(server.unblocked_clients,c);
        serverAssert(ln != NULL);
        listDelNode(server.unblocked_clients,ln);
        c->flags &= ~CLIENT_UNBLOCKED;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x133fc5(%rip), %rax    # 0x1781d8
movq 0x1f0(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x44232
leaq 0x133fb1(%rip), %rax    # 0x1781d8
movq $0x0, 0x1f0(%rax)
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x442ec
leaq 0x133f91(%rip), %rax    # 0x1781d8
movq 0x1c8(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x274d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x44264
jmp 0x44286
leaq 0xf6879(%rip), %rdi     # 0x13aae4
leaq 0xf67c4(%rip), %rsi     # 0x13aa36
movl $0x2f6, %edx            # imm = 0x2F6
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
leaq 0x133f4b(%rip), %rax    # 0x1781d8
movq 0x1c8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
leaq 0x133f34(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x1, %edx
callq 0x2aab0
leaq 0x133f18(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x2, %edx
callq 0x2aab0
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x26180
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
je 0x44373
leaq 0x133ed1(%rip), %rax    # 0x1781d8
movq 0x1d8(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x274d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x44324
jmp 0x44346
leaq 0xf67b9(%rip), %rdi     # 0x13aae4
leaq 0xf6704(%rip), %rsi     # 0x13aa36
movl $0x303, %edx            # imm = 0x303
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
leaq 0x133e8b(%rip), %rax    # 0x1781d8
movq 0x1d8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
movq -0x8(%rbp), %rax
movl 0x98(%rax), %ecx
andl $0xffdfffff, %ecx       # imm = 0xFFDFFFFF
movl %ecx, 0x98(%rax)
movq -0x8(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x443fa
leaq 0x133e4a(%rip), %rax    # 0x1781d8
movq 0x920(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x274d0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x443ab
jmp 0x443cd
leaq 0xf6732(%rip), %rdi     # 0x13aae4
leaq 0xf667d(%rip), %rsi     # 0x13aa36
movl $0x30c, %edx            # imm = 0x30C
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
leaq 0x133e04(%rip), %rax    # 0x1781d8
movq 0x920(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
movq -0x8(%rbp), %rax
movl 0x98(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movl %ecx, 0x98(%rax)
addq $0x10, %rsp
popq %rbp
retq