// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: serveClientBlockedOnList
int serveClientBlockedOnList(redisClient *receiver, robj *key, robj *dstkey, redisDb *db, robj *value, int where)
{
    robj *argv[3];

    // 执行的是 BLPOP 或 BRPOP
    if (dstkey == NULL) {
        /* Propagate the [LR]POP operation. */
        argv[0] = (where == REDIS_HEAD) ? shared.lpop :
                                          shared.rpop;
        argv[1] = key;
        propagate((where == REDIS_HEAD) ?
            server.lpopCommand : server.rpopCommand,
            db->id,argv,2,REDIS_PROPAGATE_AOF|REDIS_PROPAGATE_REPL);

        /* BRPOP/BLPOP */
        addReplyMultiBulkLen(receiver,2);
        addReplyBulk(receiver,key);
        addReplyBulk(receiver,value);

    // 执行的是 BRPOPLPUSH 
    } else {
        /* BRPOPLPUSH */

        // 取出目标对象
        robj *dstobj =
            lookupKeyWrite(receiver->db,dstkey);
        if (!(dstobj &&
             checkType(receiver,dstobj,REDIS_LIST)))
        {
            /* Propagate the RPOP operation. */
            // 传播 RPOP 命令
            argv[0] = shared.rpop;
            argv[1] = key;
            propagate(server.rpopCommand,
                db->id,argv,2,
                REDIS_PROPAGATE_AOF|
                REDIS_PROPAGATE_REPL);

            // 将值推入到 dstobj 中，如果 dstobj 不存在，
            // 那么新创建一个
            rpoplpushHandlePush(receiver,dstkey,dstobj,
                value);

            /* Propagate the LPUSH operation. */
            // 传播 LPUSH 命令
            argv[0] = shared.lpush;
            argv[1] = dstkey;
            argv[2] = value;
            propagate(server.lpushCommand,
                db->id,argv,3,
                REDIS_PROPAGATE_AOF|
                REDIS_PROPAGATE_REPL);
        } else {
            /* BRPOPLPUSH failed because of wrong
             * destination type. */
            return REDIS_ERR;
        }
    }
    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4a50f
cmpl $0x0, -0x34(%rbp)
jne 0x4a475
leaq 0xc9ce8(%rip), %rax     # 0x114150
movq 0x138(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x4a487
leaq 0xc9cd4(%rip), %rax     # 0x114150
movq 0x130(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x4a4b1
leaq 0xc9454(%rip), %rax     # 0x1138f8
movq 0x330(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x4a4c3
leaq 0xc9440(%rip), %rax     # 0x1138f8
movq 0x338(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %esi
leaq -0x50(%rbp), %rdx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x28790
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x364f0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x36620
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x36620
jmp 0x4a5f4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x3c090
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4a546
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x3abb0
cmpl $0x0, %eax
jne 0x4a5e9
leaq 0xc9c03(%rip), %rax     # 0x114150
movq 0x130(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0xc9391(%rip), %rax     # 0x1138f8
movq 0x338(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %esi
leaq -0x50(%rbp), %rdx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x28790
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x49ee0
leaq 0xc9bab(%rip), %rax     # 0x114150
movq 0x140(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0xc9331(%rip), %rax     # 0x1138f8
movq 0x328(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %esi
leaq -0x50(%rbp), %rdx
movl $0x3, %r8d
movl %r8d, %ecx
callq 0x28790
jmp 0x4a5f2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a5fb
jmp 0x4a5f4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)