// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_list.c
// Function: handleClientsBlockedOnLists
void handleClientsBlockedOnLists(void) {
    while(listLength(server.ready_keys) != 0) {
        list *l;

        /* Point server.ready_keys to a fresh list and save the current one
         * locally. This way as we run the old list we are free to call
         * signalListAsReady() that may push new elements in server.ready_keys
         * when handling clients blocked into BRPOPLPUSH. */
        l = server.ready_keys;
        server.ready_keys = listCreate();

        while(listLength(l) != 0) {
            listNode *ln = listFirst(l);
            readyList *rl = ln->value;

            /* First of all remove this key from db->ready_keys so that
             * we can safely call signalListAsReady() against this key. */
            dictDelete(rl->db->ready_keys,rl->key);

            /* If the key exists and it's a list, serve blocked clients
             * with data. */
            robj *o = lookupKeyWrite(rl->db,rl->key);
            if (o != NULL && o->type == OBJ_LIST) {
                dictEntry *de;

                /* We serve clients in the same order they blocked for
                 * this key, from the first blocked to the last. */
                de = dictFind(rl->db->blocking_keys,rl->key);
                if (de) {
                    list *clients = dictGetVal(de);
                    int numclients = listLength(clients);

                    while(numclients--) {
                        listNode *clientnode = listFirst(clients);
                        client *receiver = clientnode->value;
                        robj *dstkey = receiver->bpop.target;
                        int where = (receiver->lastcmd &&
                                     receiver->lastcmd->proc == blpopCommand) ?
                                    LIST_HEAD : LIST_TAIL;
                        robj *value = listTypePop(o,where);

                        if (value) {
                            /* Protect receiver->bpop.target, that will be
                             * freed by the next unblockClient()
                             * call. */
                            if (dstkey) incrRefCount(dstkey);
                            unblockClient(receiver);

                            if (serveClientBlockedOnList(receiver,
                                rl->key,dstkey,rl->db,value,
                                where) == C_ERR)
                            {
                                /* If we failed serving the client we need
                                 * to also undo the POP operation. */
                                    listTypePush(o,value,where);
                            }

                            if (dstkey) decrRefCount(dstkey);
                            decrRefCount(value);
                        } else {
                            break;
                        }
                    }
                }

                if (listTypeLength(o) == 0) {
                    dbDelete(rl->db,rl->key);
                }
                /* We don't call signalModifiedKey() as it was already called
                 * when an element was pushed on the list. */
            }

            /* Free this item. */
            decrRefCount(rl->key);
            zfree(rl);
            listDelNode(l,ln);
        }
        listRelease(l); /* We have the new list on place at this point. */
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0x11d159(%rip), %rax    # 0x1781d8
movq 0x928(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x5b2c8
leaq 0x11d140(%rip), %rax    # 0x1781d8
movq 0x928(%rax), %rax
movq %rax, -0x8(%rbp)
callq 0x26e20
movq %rax, %rcx
leaq 0x11d126(%rip), %rax    # 0x1781d8
movq %rcx, 0x928(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5b2ba
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2de50
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x4a6f0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5b292
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x1, %eax
jne 0x5b292
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2dcb0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5b26d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x34(%rbp)
cmpl $0x0, %eax
je 0x5b26b
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x180(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x50(%rcx)
movb %al, -0x61(%rbp)
je 0x5b1cd
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rax
leaq 0x10d(%rip), %rcx       # 0x5b2d0
cmpq %rcx, 0x8(%rax)
sete %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %dl
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x59090
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x5b264
cmpq $0x0, -0x50(%rbp)
je 0x5b207
movq -0x50(%rbp), %rdi
callq 0x487b0
movq -0x48(%rbp), %rdi
callq 0x9d930
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x50(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x60(%rbp), %r8
movl -0x54(%rbp), %r9d
callq 0x5ae90
cmpl $-0x1, %eax
jne 0x5b249
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x54(%rbp), %edx
callq 0x58f20
cmpq $0x0, -0x50(%rbp)
je 0x5b259
movq -0x50(%rbp), %rdi
callq 0x48f70
movq -0x60(%rbp), %rdi
callq 0x48f70
jmp 0x5b266
jmp 0x5b26b
jmp 0x5b16a
jmp 0x5b26d
movq -0x20(%rbp), %rdi
callq 0x59140
cmpq $0x0, %rax
jne 0x5b290
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x4ac10
jmp 0x5b292
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x48f70
movq -0x18(%rbp), %rdi
callq 0x3afa0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x271e0
jmp 0x5b0b9
movq -0x8(%rbp), %rdi
callq 0x26ea0
jmp 0x5b078
addq $0x70, %rsp
popq %rbp
retq
nop