LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeDelete
void listTypeDelete(listTypeEntry *entry) {

    listTypeIterator *li = entry->li;

    // ZIPLIST
    if (li->encoding == REDIS_ENCODING_ZIPLIST) {

        unsigned char *p = entry->zi;

        li->subject->ptr = ziplistDelete(li->subject->ptr,&p);

        /* Update position of the iterator depending on the direction */
        // 删除节点之后，更新迭代器的指针
        if (li->direction == REDIS_TAIL)
            li->zi = p;
        else
            li->zi = ziplistPrev(li->subject->ptr,p);

    // 双端链表
    } else if (entry->li->encoding == REDIS_ENCODING_LINKEDLIST) {

        // 记录后置节点
        listNode *next;

        if (li->direction == REDIS_TAIL)
            next = entry->ln->next;
        else
            next = entry->ln->prev;

        // 删除当前节点
        listDelNode(li->subject->ptr,entry->ln);

        // 删除节点之后，更新迭代器的指针
        li->ln = next;

    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x5, %eax
jne 0x488d1
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x33700
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x1, %eax
jne 0x488ad
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x488cc
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x333a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x48959
movq -0x8(%rbp), %rax
movq (%rax), %rax
movzbl 0x8(%rax), %eax
cmpl $0x4, %eax
jne 0x48935
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x1, %eax
jne 0x48900
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4890f
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x20170
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x48957
leaq 0x9a210(%rip), %rdi     # 0xe2b4c
leaq 0x9a6ee(%rip), %rsi     # 0xe3031
movl $0x1bb, %edx            # imm = 0x1BB
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x48959
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: signalListAsReady
void signalListAsReady(redisClient *c, robj *key) {
    readyList *rl;

    /* No clients blocking for this key? No need to queue it. */
    // 没有客户端被这个键阻塞，直接返回
    if (dictFind(c->db->blocking_keys,key) == NULL) return;

    /* Key was already signaled? No need to queue it again. */
    // 这个键已经被添加到 ready_keys 中了，直接返回
    if (dictFind(c->db->ready_keys,key) != NULL) return;

    /* Ok, we need to queue this key into server.ready_keys. */
    // 创建一个 readyList 结构，保存键和数据库
    // 然后将 readyList 添加到 server.ready_keys 中
    rl = zmalloc(sizeof(*rl));
    rl->key = key;
    rl->db = c->db;
    incrRefCount(key);
    listAddNodeTail(server.ready_keys,rl);

    /* We also add the key in the db->ready_keys dictionary in order
     * to avoid adding it multiple times into a list with a simple O(1)
     * check. 
     *
     * 将 key 添加到 c->db->ready_keys 集合中，防止重复添加
     */
    incrRefCount(key);
    redisAssert(dictAdd(c->db->ready_keys,key,NULL) == DICT_OK);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x23aa0
cmpq $0x0, %rax
jne 0x48b90
jmp 0x48c44
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x23aa0
cmpq $0x0, %rax
je 0x48bb0
jmp 0x48c44
movl $0x10, %edi
callq 0x2e130
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x3a3f0
leaq 0xcad0f(%rip), %rax     # 0x1138f8
movq 0x740(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1ff90
movq -0x10(%rbp), %rdi
callq 0x3a3f0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x236d0
cmpl $0x0, %eax
jne 0x48c22
jmp 0x48c44
leaq 0x9a50b(%rip), %rdi     # 0xe3134
leaq 0x9a401(%rip), %rsi     # 0xe3031
movl $0x4f5, %edx            # imm = 0x4F5
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: linsertCommand
void linsertCommand(redisClient *c) {

    // 编码 refval 对象
    c->argv[4] = tryObjectEncoding(c->argv[4]);

    if (strcasecmp(c->argv[2]->ptr,"after") == 0) {
        pushxGenericCommand(c,c->argv[3],c->argv[4],REDIS_TAIL);

    } else if (strcasecmp(c->argv[2]->ptr,"before") == 0) {
        pushxGenericCommand(c,c->argv[3],c->argv[4],REDIS_HEAD);

    } else {
        addReply(c,shared.syntaxerr);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rdi
callq 0x3acc0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x9a10f(%rip), %rsi     # 0xe30d2
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x48ff5
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rdx
movl $0x1, %ecx
callq 0x48c90
jmp 0x49054
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x9a0cc(%rip), %rsi     # 0xe30d8
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x4903b
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rdx
xorl %ecx, %ecx
callq 0x48c90
jmp 0x49052
movq -0x8(%rbp), %rdi
leaq 0xcb10a(%rip), %rax     # 0x114150
movq 0x80(%rax), %rsi
callq 0x35a70
jmp 0x49054
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: popGenericCommand
void popGenericCommand(redisClient *c, int where) {

    // 取出列表对象
    robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk);

    if (o == NULL || checkType(c,o,REDIS_LIST)) return;

    // 弹出列表元素
    robj *value = listTypePop(o,where);

    // 根据弹出元素是否为空，决定后续动作
    if (value == NULL) {
        addReply(c,shared.nullbulk);
    } else {
        char *event = (where == REDIS_HEAD) ? "lpop" : "rpop";

        addReplyBulk(c,value);
        decrRefCount(value);
        notifyKeyspaceEvent(REDIS_NOTIFY_LIST,event,c->argv[1],c->db->id);
        if (listTypeLength(o) == 0) {
            notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",
                                c->argv[1],c->db->id);
            dbDelete(c->db,c->argv[1]);
        }
        signalModifiedKey(c->db,c->argv[1]);
        server.dirty++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xcab8a(%rip), %rax     # 0x114150
movq 0x50(%rax), %rdx
callq 0x3c110
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x495f1
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x495f6
jmp 0x49706
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x47fa0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x49626
movq -0x8(%rbp), %rdi
leaq 0xcab38(%rip), %rax     # 0x114150
movq 0x50(%rax), %rsi
callq 0x35a70
jmp 0x49706
movl -0xc(%rbp), %edx
leaq 0x94d12(%rip), %rax     # 0xde342
leaq 0x94d23(%rip), %rcx     # 0xde35a
cmpl $0x0, %edx
cmoveq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x36620
movq -0x20(%rbp), %rdi
callq 0x3aaa0
movq -0x28(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x10, %edi
callq 0x814a0
movq -0x18(%rbp), %rdi
callq 0x480f0
cmpq $0x0, %rax
jne 0x496cd
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x4, %edi
leaq 0x94e56(%rip), %rsi     # 0xde505
callq 0x814a0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c4f0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c3d0
leaq 0xca20b(%rip), %rax     # 0x1138f8
movq 0x560(%rax), %rcx
addq $0x1, %rcx
leaq 0xca1f9(%rip), %rax     # 0x1138f8
movq %rcx, 0x560(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: rpoplpushHandlePush
void rpoplpushHandlePush(redisClient *c, robj *dstkey, robj *dstobj, robj *value) {
    /* Create the list if the key does not exist */
    // 如果目标列表不存在，那么创建一个
    if (!dstobj) {
        dstobj = createZiplistObject();
        dbAdd(c->db,dstkey,dstobj);
        signalListAsReady(c,dstkey);
    }

    signalModifiedKey(c->db,dstkey);

    // 将值推入目标列表中
    listTypePush(dstobj,value,REDIS_HEAD);

    notifyKeyspaceEvent(REDIS_NOTIFY_LIST,"lpush",dstkey,c->db->id);
    /* Always send the pushed value to the client. */
    addReplyBulk(c,value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x49f2a
callq 0x3a690
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3c160
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x48b60
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x3c3d0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47e50
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x10, %edi
leaq 0x943ea(%rip), %rsi     # 0xde34f
callq 0x814a0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x36620
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: unblockClientWaitingData
void unblockClientWaitingData(redisClient *c) {
    dictEntry *de;
    dictIterator *di;
    list *l;

    redisAssertWithInfo(c,NULL,dictSize(c->bpop.keys) != 0);

    // 遍历所有 key ，将它们从客户端 db->blocking_keys 的链表中移除
    di = dictGetIterator(c->bpop.keys);
    /* The client may wait for multiple keys, so unblock it for every key. */
    while((de = dictNext(di)) != NULL) {
        robj *key = dictGetKey(de);

        /* Remove this client from the list of clients waiting for this key. */
        // 获取所有因为 key 而被阻塞的客户端的链表
        l = dictFetchValue(c->db->blocking_keys,key);

        redisAssertWithInfo(c,key,l != NULL);

        // 将指定客户端从链表中删除
        listDelNode(l,listSearchKey(l,c));

        /* If the list is empty we need to remove it to avoid wasting memory */
        // 如果已经没有其他客户端阻塞在这个 key 上，那么删除这个链表
        if (listLength(l) == 0)
            dictDelete(c->db->blocking_keys,key);
    }
    dictReleaseIterator(di);

    /* Cleanup the client structure */
    // 清空 bpop.keys 集合（字典）
    dictEmpty(c->bpop.keys,NULL);
    if (c->bpop.target) {
        decrRefCount(c->bpop.target);
        c->bpop.target = NULL;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x128(%rax), %rax
movq 0x28(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x128(%rcx), %rcx
addq 0x48(%rcx), %rax
cmpq $0x0, %rax
je 0x4a2e2
jmp 0x4a30d
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq 0x98e1d(%rip), %rdx     # 0xe310e
leaq 0x98d39(%rip), %rcx     # 0xe3031
movl $0x4a9, %r8d            # imm = 0x4A9
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
movq 0x128(%rax), %rdi
callq 0x241d0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x24270
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4a3d6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x24050
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4a365
jmp 0x4a390
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0x98db6(%rip), %rdx     # 0xe312a
leaq 0x98cb6(%rip), %rcx     # 0xe3031
movl $0x4b5, %r8d            # imm = 0x4B5
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x20480
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x20170
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x4a3d1
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x23c30
jmp 0x4a321
movq -0x18(%rbp), %rdi
callq 0x243d0
movq -0x8(%rbp), %rax
movq 0x128(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x24a00
movq -0x8(%rbp), %rax
cmpq $0x0, 0x130(%rax)
je 0x4a420
movq -0x8(%rbp), %rax
movq 0x130(%rax), %rdi
callq 0x3aaa0
movq -0x8(%rbp), %rax
movq $0x0, 0x130(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: brpoplpushCommand
void brpoplpushCommand(redisClient *c) {
    mstime_t timeout;

    // 取出 timeout 参数
    if (getTimeoutFromObjectOrReply(c,c->argv[3],&timeout,UNIT_SECONDS)
        != REDIS_OK) return;

    // 取出列表键
    robj *key = lookupKeyWrite(c->db, c->argv[1]);

    // 键为空，阻塞
    if (key == NULL) {
        if (c->flags & REDIS_MULTI) {
            /* Blocking against an empty list in a multi state
             * returns immediately. */
            addReply(c, shared.nullbulk);
        } else {
            /* The list is empty and the client blocks. */
            blockForKeys(c, c->argv + 1, 1, timeout, c->argv[2]);
        }

    // 键非空，执行 RPOPLPUSH
    } else {
        if (key->type != REDIS_LIST) {
            addReply(c, shared.wrongtypeerr);
        } else {
            /* The list exists and has elements, so
             * the regular rpoplpushCommand is executed. */
            redisAssertWithInfo(c,key,listTypeLength(key) > 0);

            rpoplpushCommand(c);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rsi
leaq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x81d90
cmpl $0x0, %eax
je 0x4abc1
jmp 0x4aca4
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c090
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4ac39
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x4ac0d
movq -0x8(%rbp), %rdi
leaq 0xc954e(%rip), %rax     # 0x114150
movq 0x50(%rax), %rsi
callq 0x35a70
jmp 0x4ac37
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %r8
movl $0x1, %edx
callq 0x4a130
jmp 0x4aca4
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x1, %eax
je 0x4ac5d
movq -0x8(%rbp), %rdi
leaq 0xc94fe(%rip), %rax     # 0x114150
movq 0x70(%rax), %rsi
callq 0x35a70
jmp 0x4aca2
movq -0x18(%rbp), %rdi
callq 0x480f0
cmpq $0x0, %rax
jbe 0x4ac6e
jmp 0x4ac99
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x984f4(%rip), %rdx     # 0xe3171
leaq 0x983ad(%rip), %rcx     # 0xe3031
movl $0x64e, %r8d            # imm = 0x64E
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rdi
callq 0x49f80
jmp 0x4aca4
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeConvert
void setTypeConvert(robj *setobj, int enc) {

    setTypeIterator *si;

    // 确认类型和编码正确
    redisAssertWithInfo(NULL,setobj,setobj->type == REDIS_SET &&
                             setobj->encoding == REDIS_ENCODING_INTSET);

    if (enc == REDIS_ENCODING_HT) {
        int64_t intele;
        // 创建新字典
        dict *d = dictCreate(&setDictType,NULL);
        robj *element;

        /* Presize the dict to avoid rehashing */
        // 预先扩展空间
        dictExpand(d,intsetLen(setobj->ptr));

        /* To add the elements we extract integers and create redis objects */
        // 遍历集合，并将元素添加到字典中
        si = setTypeInitIterator(setobj);
        while (setTypeNext(si,NULL,&intele) != -1) {
            element = createStringObjectFromLongLong(intele);
            redisAssertWithInfo(NULL,element,dictAdd(d,element,NULL) == DICT_OK);
        }
        setTypeReleaseIterator(si);

        // 更新集合的编码
        setobj->encoding = REDIS_ENCODING_HT;
        zfree(setobj->ptr);
        // 更新集合的值对象
        setobj->ptr = d;
    } else {
        redisPanic("Unsupported set conversion");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x2, %eax
jne 0x4aee0
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x4aee0
jmp 0x4af0b
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0x982e5(%rip), %rdx     # 0xe31d4
leaq 0x982bf(%rip), %rcx     # 0xe31b5
movl $0x17d, %r8d            # imm = 0x17D
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
cmpl $0x2, -0xc(%rbp)
jne 0x4aff5
leaq 0xc7964(%rip), %rdi     # 0x112880
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x67ab0
movq -0x38(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x232b0
movq -0x8(%rbp), %rdi
callq 0x4b1d0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdx
callq 0x4b2c0
cmpl $-0x1, %eax
je 0x4afc0
movq -0x20(%rbp), %rdi
callq 0x3a330
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x236d0
cmpl $0x0, %eax
jne 0x4af93
jmp 0x4afbe
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0x98279(%rip), %rdx     # 0xe321b
leaq 0x9820c(%rip), %rcx     # 0xe31b5
movl $0x18e, %r8d            # imm = 0x18E
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
jmp 0x4af58
movq -0x18(%rbp), %rdi
callq 0x4b280
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff0f, %ecx       # imm = 0xFFFFFF0F
orl $0x20, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2e3a0
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x4b017
leaq 0x98242(%rip), %rdi     # 0xe323e
leaq 0x981b2(%rip), %rsi     # 0xe31b5
movl $0x198, %edx            # imm = 0x198
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeRemove
int setTypeRemove(robj *setobj, robj *value) {
    long long llval;

    // HT
    if (setobj->encoding == REDIS_ENCODING_HT) {
        // 从字典中删除键（集合元素）
        if (dictDelete(setobj->ptr,value) == DICT_OK) {
            // 看是否有必要在删除之后缩小字典的大小
            if (htNeedsResize(setobj->ptr)) dictResize(setobj->ptr);
            return 1;
        }

    // INTSET
    } else if (setobj->encoding == REDIS_ENCODING_INTSET) {
        // 如果对象的值可以编码为整数的话，那么尝试从 intset 中移除元素
        if (isObjectRepresentableAsLongLong(value,&llval) == REDIS_OK) {
            int success;
            setobj->ptr = intsetRemove(setobj->ptr,llval,&success);
            if (success) return 1;
        }

    // 未知编码
    } else {
        redisPanic("Unknown set encoding");
    }

    // 删除失败
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
jne 0x4b084
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x23c30
cmpl $0x0, %eax
jne 0x4b082
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x25700
cmpl $0x0, %eax
je 0x4b076
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x23250
movl $0x1, -0x4(%rbp)
jmp 0x4b105
jmp 0x4b0fe
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x4b0da
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3ac00
cmpl $0x0, %eax
jne 0x4b0d8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x678d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x24(%rbp)
je 0x4b0d6
movl $0x1, -0x4(%rbp)
jmp 0x4b105
jmp 0x4b0d8
jmp 0x4b0fc
leaq 0x97a83(%rip), %rdi     # 0xe2b64
leaq 0x980cd(%rip), %rsi     # 0xe31b5
movl $0x8b, %edx
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x4b0fe
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeIsMember
int setTypeIsMember(robj *subject, robj *value) {
    long long llval;

    // HT
    if (subject->encoding == REDIS_ENCODING_HT) {
        return dictFind((dict*)subject->ptr,value) != NULL;

    // INTSET
    } else if (subject->encoding == REDIS_ENCODING_INTSET) {
        if (isObjectRepresentableAsLongLong(value,&llval) == REDIS_OK) {
            return intsetFind((intset*)subject->ptr,llval);
        }

    // 未知编码
    } else {
        redisPanic("Unknown set encoding");
    }

    // 查找失败
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
jne 0x4b153
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x23aa0
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x4b1bc
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x4b191
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3ac00
cmpl $0x0, %eax
jne 0x4b18f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x67990
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x4b1bc
jmp 0x4b1b3
leaq 0x979cc(%rip), %rdi     # 0xe2b64
leaq 0x98016(%rip), %rsi     # 0xe31b5
movl $0xa4, %edx
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x4b1b5
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeInitIterator
setTypeIterator *setTypeInitIterator(robj *subject) {

    setTypeIterator *si = zmalloc(sizeof(setTypeIterator));
    
    // 指向被迭代的对象
    si->subject = subject;

    // 记录对象的编码
    si->encoding = subject->encoding;

    // HT
    if (si->encoding == REDIS_ENCODING_HT) {
        // 字典迭代器
        si->di = dictGetIterator(subject->ptr);

    // INTSET
    } else if (si->encoding == REDIS_ENCODING_INTSET) {
        // 索引
        si->ii = 0;

    // 未知编码
    } else {
        redisPanic("Unknown set encoding");
    }

    // 返回迭代器
    return si;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl $0x18, %edi
callq 0x2e130
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
shrl $0x4, %ecx
andl $0xf, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0x4b22c
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x241d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x4b267
movq -0x10(%rbp), %rax
cmpl $0x6, 0x8(%rax)
jne 0x4b243
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
jmp 0x4b265
leaq 0x9791a(%rip), %rdi     # 0xe2b64
leaq 0x97f64(%rip), %rsi     # 0xe31b5
movl $0xc6, %edx
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x4b267
movq -0x10(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeNext
int setTypeNext(setTypeIterator *si, robj **objele, int64_t *llele) {

    // 从字典中取出对象
    if (si->encoding == REDIS_ENCODING_HT) {

        // 更新迭代器
        dictEntry *de = dictNext(si->di);

        // 字典已迭代完
        if (de == NULL) return -1;

        // 返回节点的键（集合的元素）
        *objele = dictGetKey(de);

    // 从 intset 中取出元素
    } else if (si->encoding == REDIS_ENCODING_INTSET) {
        if (!intsetGet(si->subject->ptr,si->ii++,llele))
            return -1;
    }

    // 返回编码
    return si->encoding;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0x4b30f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x24270
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4b2ff
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b357
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4b34d
movq -0x10(%rbp), %rax
cmpl $0x6, 0x8(%rax)
jne 0x4b34b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
movl %esi, %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rdx
callq 0x67a60
cmpb $0x0, %al
jne 0x4b349
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b357
jmp 0x4b34b
jmp 0x4b34d
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeNextObject
robj *setTypeNextObject(setTypeIterator *si) {
    int64_t intele;
    robj *objele;
    int encoding;

    // 取出元素
    encoding = setTypeNext(si,&objele,&intele);
    // 总是为元素创建对象
    switch(encoding) {
        // 已为空
        case -1:    return NULL;
        // INTSET 返回一个整数值，需要为这个值创建对象
        case REDIS_ENCODING_INTSET:
            return createStringObjectFromLongLong(intele);
        // HT 本身已经返回对象了，只需执行 incrRefCount()
        case REDIS_ENCODING_HT:
            incrRefCount(objele);
            return objele;
        default:
            redisPanic("Unsupported encoding");
    }

    return NULL; /* just to suppress warnings */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x4b2c0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
subl $-0x1, %eax
je 0x4b3a1
jmp 0x4b38d
movl -0x28(%rbp), %eax
subl $0x2, %eax
je 0x4b3ba
jmp 0x4b397
movl -0x28(%rbp), %eax
subl $0x6, %eax
je 0x4b3ab
jmp 0x4b3cd
movq $0x0, -0x8(%rbp)
jmp 0x4b3ef
movq -0x18(%rbp), %rdi
callq 0x3a330
movq %rax, -0x8(%rbp)
jmp 0x4b3ef
movq -0x20(%rbp), %rdi
callq 0x3a3f0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4b3ef
leaq 0x97de9(%rip), %rdi     # 0xe31bd
leaq 0x97dda(%rip), %rsi     # 0xe31b5
movl $0x12f, %edx            # imm = 0x12F
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeRandomElement
int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) {

    if (setobj->encoding == REDIS_ENCODING_HT) {
        dictEntry *de = dictGetRandomKey(setobj->ptr);
        *objele = dictGetKey(de);

    } else if (setobj->encoding == REDIS_ENCODING_INTSET) {
        *llele = intsetRandom(setobj->ptr);

    } else {
        redisPanic("Unknown set encoding");
    }

    return setobj->encoding;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
jne 0x4b446
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x24470
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4b494
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x4b470
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x679f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4b492
leaq 0x976ed(%rip), %rdi     # 0xe2b64
leaq 0x97d37(%rip), %rsi     # 0xe31b5
movl $0x158, %edx            # imm = 0x158
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x4b494
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: setTypeSize
unsigned long setTypeSize(robj *subject) {

    if (subject->encoding == REDIS_ENCODING_HT) {
        return dictSize((dict*)subject->ptr);

    } else if (subject->encoding == REDIS_ENCODING_INTSET) {
        return intsetLen((intset*)subject->ptr);

    } else {
        redisPanic("Unknown set encoding");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
jne 0x4b4eb
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq 0x48(%rcx), %rax
movq %rax, -0x8(%rbp)
jmp 0x4b533
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x4b511
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x67ab0
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x4b533
leaq 0x9764c(%rip), %rdi     # 0xe2b64
leaq 0x97c96(%rip), %rsi     # 0xe31b5
movl $0x16a, %edx            # imm = 0x16A
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: saddCommand
void saddCommand(redisClient *c) {
    robj *set;
    int j, added = 0;

    // 取出集合对象
    set = lookupKeyWrite(c->db,c->argv[1]);

    // 对象不存在，创建一个新的，并将它关联到数据库
    if (set == NULL) {
        set = setTypeCreate(c->argv[2]);
        dbAdd(c->db,c->argv[1],set);

    // 对象存在，检查类型
    } else {
        if (set->type != REDIS_SET) {
            addReply(c,shared.wrongtypeerr);
            return;
        }
    }

    // 将所有输入元素添加到集合中
    for (j = 2; j < c->argc; j++) {
        c->argv[j] = tryObjectEncoding(c->argv[j]);
        // 只有元素未存在于集合时，才算一次成功添加
        if (setTypeAdd(set,c->argv[j])) added++;
    }

    // 如果有至少一个元素被成功添加，那么执行以下程序
    if (added) {
        // 发送键修改信号
        signalModifiedKey(c->db,c->argv[1]);
        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_SET,"sadd",c->argv[1],c->db->id);
    }

    // 将数据库设为脏
    server.dirty += added;

    // 返回添加元素的数量
    addReplyLongLong(c,added);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c090
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4b5ab
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x4acf0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x3c160
jmp 0x4b5d4
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x2, %eax
je 0x4b5d2
movq -0x8(%rbp), %rdi
leaq 0xc8b8c(%rip), %rax     # 0x114150
movq 0x70(%rax), %rsi
callq 0x35a70
jmp 0x4b6b7
jmp 0x4b5d4
movl $0x2, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x4b643
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3acc0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4ad30
cmpl $0x0, %eax
je 0x4b636
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4b638
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4b5db
cmpl $0x0, -0x18(%rbp)
je 0x4b68a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c3d0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x20, %edi
leaq 0x92cfd(%rip), %rsi     # 0xde382
callq 0x814a0
movslq -0x18(%rbp), %rcx
leaq 0xc8263(%rip), %rax     # 0x1138f8
addq 0x560(%rax), %rcx
leaq 0xc8255(%rip), %rax     # 0x1138f8
movq %rcx, 0x560(%rax)
movq -0x8(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x36480
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: sremCommand
void sremCommand(redisClient *c) {
    robj *set;
    int j, deleted = 0, keyremoved = 0;

    // 取出集合对象
    if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,set,REDIS_SET)) return;

    // 删除输入的所有元素
    for (j = 2; j < c->argc; j++) {
        
        // 只有元素在集合中时，才算一次成功删除
        if (setTypeRemove(set,c->argv[j])) {
            deleted++;
            // 如果集合已经为空，那么删除集合对象
            if (setTypeSize(set) == 0) {
                dbDelete(c->db,c->argv[1]);
                keyremoved = 1;
                break;
            }
        }
    }

    // 如果有至少一个元素被成功删除，那么执行以下程序
    if (deleted) {
        // 发送键修改信号
        signalModifiedKey(c->db,c->argv[1]);
        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_SET,"srem",c->argv[1],c->db->id);
        // 发送事件通知
        if (keyremoved)
            notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",c->argv[1],
                                c->db->id);
        // 将数据库设为脏
        server.dirty += deleted;
    }
    
    // 将被成功删除元素的数量作为回复
    addReplyLongLong(c,deleted);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xc8a5f(%rip), %rax     # 0x114150
movq 0x20(%rax), %rdx
callq 0x3c110
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4b71b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x4b720
jmp 0x4b840
movl $0x2, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x4b79a
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4b020
cmpl $0x0, %eax
je 0x4b78d
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4b4b0
cmpq $0x0, %rax
jne 0x4b78b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c4f0
movl $0x1, -0x1c(%rbp)
jmp 0x4b79a
jmp 0x4b78d
jmp 0x4b78f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4b727
cmpl $0x0, -0x18(%rbp)
je 0x4b833
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3c3d0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x20, %edi
leaq 0x92ba7(%rip), %rsi     # 0xde387
callq 0x814a0
cmpl $0x0, -0x1c(%rbp)
je 0x4b813
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x4, %edi
leaq 0x92cf7(%rip), %rsi     # 0xde505
callq 0x814a0
movslq -0x18(%rbp), %rcx
leaq 0xc80da(%rip), %rax     # 0x1138f8
addq 0x560(%rax), %rcx
leaq 0xc80cc(%rip), %rax     # 0x1138f8
movq %rcx, 0x560(%rax)
movq -0x8(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x36480
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: sismemberCommand
void sismemberCommand(redisClient *c) {
    robj *set;

    // 取出集合对象
    if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,set,REDIS_SET)) return;

    // 编码输入元素
    c->argv[2] = tryObjectEncoding(c->argv[2]);

    // 检查是否存在
    if (setTypeIsMember(set,c->argv[2]))
        addReply(c,shared.cone);
    else
        addReply(c,shared.czero);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xc865d(%rip), %rax     # 0x114150
movq 0x20(%rax), %rdx
callq 0x3c0c0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4bb1d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x4bb1f
jmp 0x4bb83
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x3acc0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rsi
callq 0x4b110
cmpl $0x0, %eax
je 0x4bb6f
movq -0x8(%rbp), %rdi
leaq 0xc85ec(%rip), %rax     # 0x114150
movq 0x28(%rax), %rsi
callq 0x35a70
jmp 0x4bb83
movq -0x8(%rbp), %rdi
leaq 0xc85d6(%rip), %rax     # 0x114150
movq 0x20(%rax), %rsi
callq 0x35a70
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: scardCommand
void scardCommand(redisClient *c) {
    robj *o;

    // 取出集合
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_SET)) return;

    // 返回集合的基数
    addReplyLongLong(c,setTypeSize(o));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xc859d(%rip), %rax     # 0x114150
movq 0x20(%rax), %rdx
callq 0x3c0c0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4bbdd
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x4bbdf
jmp 0x4bbfc
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4b4b0
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x36480
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: srandmemberCommand
void srandmemberCommand(redisClient *c) {
    robj *set, *ele;
    int64_t llele;
    int encoding;

    // 如果带有 count 参数，那么调用 srandmemberWithCountCommand 来处理
    if (c->argc == 3) {
        srandmemberWithCountCommand(c);
        return;

    // 参数错误
    } else if (c->argc > 3) {
        addReply(c,shared.syntaxerr);
        return;
    }

    // 随机取出单个元素就可以了

    // 取出集合对象
    if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
        checkType(c,set,REDIS_SET)) return;

    // 随机取出一个元素
    encoding = setTypeRandomElement(set,&ele,&llele);
    // 回复
    if (encoding == REDIS_ENCODING_INTSET) {
        addReplyBulkLongLong(c,llele);
    } else {
        addReplyBulk(c,ele);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x3, 0x30(%rax)
jne 0x4c754
movq -0x8(%rbp), %rdi
callq 0x4bdd0
jmp 0x4c7f2
movq -0x8(%rbp), %rax
cmpl $0x3, 0x30(%rax)
jle 0x4c777
movq -0x8(%rbp), %rdi
leaq 0xc79e7(%rip), %rax     # 0x114150
movq 0x80(%rax), %rsi
callq 0x35a70
jmp 0x4c7f2
jmp 0x4c779
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xc79c0(%rip), %rax     # 0x114150
movq 0x50(%rax), %rdx
callq 0x3c0c0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4c7ba
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x4c7bc
jmp 0x4c7f2
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x4b400
movl %eax, -0x24(%rbp)
cmpl $0x6, -0x24(%rbp)
jne 0x4c7e5
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x366c0
jmp 0x4c7f2
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x36620
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: sscanCommand
void sscanCommand(redisClient *c) {
    robj *set;
    unsigned long cursor;

    if (parseScanCursorOrReply(c,c->argv[2],&cursor) == REDIS_ERR) return;
    if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL ||
        checkType(c,set,REDIS_SET)) return;
    scanGenericCommand(c,set,cursor);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x18(%rbp), %rdx
callq 0x3cf50
cmpl $-0x1, %eax
jne 0x4cf6c
jmp 0x4cfc3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xc71cd(%rip), %rax     # 0x114150
movq 0x148(%rax), %rdx
callq 0x3c0c0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4cfb0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x4cfb2
jmp 0x4cfc3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3d000
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: zslFree
void zslFree(zskiplist *zsl) {

    zskiplistNode *node = zsl->header->level[0].forward, *next;

    // 释放表头
    zfree(zsl->header);

    // 释放表中所有节点
    // T = O(N)
    while(node) {

        next = node->level[0].forward;

        zslFreeNode(node);

        node = next;
    }
    
    // 释放跳跃表结构
    zfree(zsl);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x2e3a0
cmpq $0x0, -0x10(%rbp)
je 0x4d19d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4d120
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x4d177
movq -0x8(%rbp), %rdi
callq 0x2e3a0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: zslFirstInRange
zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec *range) {
    zskiplistNode *x;
    int i;

    /* If everything is out of range, return early. */
    if (!zslIsInRange(zsl,range)) return NULL;

    // 遍历跳跃表，查找符合范围 min 项的节点
    // T_wrost = O(N), T_avg = O(log N)
    x = zsl->header;
    for (i = zsl->level-1; i >= 0; i--) {
        /* Go forward while *OUT* of range. */
        while (x->level[i].forward &&
            !zslValueGteMin(x->level[i].forward->score,range))
                x = x->level[i].forward;
    }

    /* This is an inner range, so the next node cannot be NULL. */
    x = x->level[0].forward;
    redisAssert(x != NULL);

    /* Check if score <= max. */
    // 检查节点是否符合范围的 max 项
    // T = O(1)
    if (!zslValueLteMax(x->score,range)) return NULL;
    return x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4dac0
cmpl $0x0, %eax
jne 0x4dc6f
movq $0x0, -0x8(%rbp)
jmp 0x4dd75
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x4dd15
jmp 0x4dc93
movq -0x20(%rbp), %rcx
addq $0x18, %rcx
movslq -0x24(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x25(%rbp)
je 0x4dce0
movq -0x20(%rbp), %rax
addq $0x18, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x4db90
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x4dce9
jmp 0x4dd05
movq -0x20(%rbp), %rax
addq $0x18, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4dc93
jmp 0x4dd07
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4dc87
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4dd2a
jmp 0x4dd4c
leaq 0x95566(%rip), %rdi     # 0xe3297
leaq 0x95556(%rip), %rsi     # 0xe328e
movl $0x1da, %edx            # imm = 0x1DA
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x4dbe0
cmpl $0x0, %eax
jne 0x4dd6d
movq $0x0, -0x8(%rbp)
jmp 0x4dd75
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: zslLastInRange
zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec *range) {
    zskiplistNode *x;
    int i;

    /* If everything is out of range, return early. */
    // 先确保跳跃表中至少有一个节点符合 range 指定的范围，
    // 否则直接失败
    // T = O(1)
    if (!zslIsInRange(zsl,range)) return NULL;

    // 遍历跳跃表，查找符合范围 max 项的节点
    // T_wrost = O(N), T_avg = O(log N)
    x = zsl->header;
    for (i = zsl->level-1; i >= 0; i--) {
        /* Go forward while *IN* range. */
        while (x->level[i].forward &&
            zslValueLteMax(x->level[i].forward->score,range))
                x = x->level[i].forward;
    }

    /* This is an inner range, so this node cannot be NULL. */
    redisAssert(x != NULL);

    /* Check if score >= min. */
    // 检查节点是否符合范围的 min 项
    // T = O(1)
    if (!zslValueGteMin(x->score,range)) return NULL;

    // 返回节点
    return x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4dac0
cmpl $0x0, %eax
jne 0x4ddaf
movq $0x0, -0x8(%rbp)
jmp 0x4dea7
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x4de53
jmp 0x4ddd3
movq -0x20(%rbp), %rcx
addq $0x18, %rcx
movslq -0x24(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x25(%rbp)
je 0x4de1e
movq -0x20(%rbp), %rax
addq $0x18, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x4dbe0
cmpl $0x0, %eax
setne %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x4de27
jmp 0x4de43
movq -0x20(%rbp), %rax
addq $0x18, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4ddd3
jmp 0x4de45
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4ddc7
cmpq $0x0, -0x20(%rbp)
je 0x4de5c
jmp 0x4de7e
leaq 0x95434(%rip), %rdi     # 0xe3297
leaq 0x95424(%rip), %rsi     # 0xe328e
movl $0x201, %edx            # imm = 0x201
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x4db90
cmpl $0x0, %eax
jne 0x4de9f
movq $0x0, -0x8(%rbp)
jmp 0x4dea7
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)