// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_set.c
// Function: smoveCommand
void smoveCommand(redisClient *c) {
    robj *srcset, *dstset, *ele;

    // 取出源集合
    srcset = lookupKeyWrite(c->db,c->argv[1]);
    // 取出目标集合
    dstset = lookupKeyWrite(c->db,c->argv[2]);

    // 编码元素
    ele = c->argv[3] = tryObjectEncoding(c->argv[3]);

    /* If the source key does not exist return 0 */
    // 源集合不存在，直接返回
    if (srcset == NULL) {
        addReply(c,shared.czero);
        return;
    }

    /* If the source key has the wrong type, or the destination key
     * is set and has the wrong type, return with an error. */
    // 如果源集合的类型错误
    // 或者目标集合存在、但是类型错误
    // 那么直接返回
    if (checkType(c,srcset,REDIS_SET) ||
        (dstset && checkType(c,dstset,REDIS_SET))) return;

    /* If srcset and dstset are equal, SMOVE is a no-op */
    // 如果源集合和目标集合相等，那么直接返回
    if (srcset == dstset) {
        addReply(c,shared.cone);
        return;
    }

    /* If the element cannot be removed from the src set, return 0. */
    // 从源集合中移除目标元素
    // 如果目标元素不存在于源集合中，那么直接返回
    if (!setTypeRemove(srcset,ele)) {
        addReply(c,shared.czero);
        return;
    }

    // 发送事件通知
    notifyKeyspaceEvent(REDIS_NOTIFY_SET,"srem",c->argv[1],c->db->id);

    /* Remove the src set from the database when empty */
    // 如果源集合已经为空，那么将它从数据库中删除
    if (setTypeSize(srcset) == 0) {
        // 删除集合对象
        dbDelete(c->db,c->argv[1]);
        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",c->argv[1],c->db->id);
    }

    // 发送键修改信号
    signalModifiedKey(c->db,c->argv[1]);
    signalModifiedKey(c->db,c->argv[2]);

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

    /* Create the destination set when it doesn't exist */
    // 如果目标集合不存在，那么创建它
    if (!dstset) {
        dstset = setTypeCreate(ele);
        dbAdd(c->db,c->argv[2],dstset);
    }

    /* An extra key has changed when ele was successfully added to dstset */
    // 将元素添加到目标集合
    if (setTypeAdd(dstset,ele)) {
        // 将数据库设为脏
        server.dirty++;
        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_SET,"sadd",c->argv[2],c->db->id);
    }

    // 回复 1 
    addReply(c,shared.cone);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2f988
movq %rax, %r12
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
callq 0x2f988
movq %rax, %r14
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x2ef4c
movq %rax, %r15
movq 0x38(%rbx), %rax
movq %r15, 0x18(%rax)
leaq 0x8e3db(%rip), %r13     # 0xc7800
leaq 0x20(%r13), %rbp
testq %r12, %r12
je 0x39571
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2eec6
testl %eax, %eax
je 0x39453
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r14, %r14
je 0x3946a
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2eec6
testl %eax, %eax
jne 0x39444
addq $0x28, %r13
cmpq %r14, %r12
je 0x3956e
movq %r12, %rdi
movq %r15, %rsi
callq 0x38ea5
testl %eax, %eax
je 0x39571
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x50e7f(%rip), %rsi     # 0x8a31f
pushq $0x20
popq %rdi
callq 0x5b488
movq %r12, %rdi
callq 0x3917b
testq %rax, %rax
jne 0x394e4
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fc3b
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x50fc1(%rip), %rsi     # 0x8a49d
pushq $0x4
popq %rdi
callq 0x5b488
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fbc0
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
callq 0x2fbc0
leaq 0x8da9b(%rip), %r12     # 0xc6fa8
incq 0x560(%r12)
testq %r14, %r14
jne 0x39539
movq %r15, %rdi
callq 0x38c74
movq %rax, %r14
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdx
callq 0x2fa09
movq %r14, %rdi
movq %r15, %rsi
callq 0x38c8c
testl %eax, %eax
je 0x3956e
incq 0x560(%r12)
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x10(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x50db4(%rip), %rsi     # 0x8a31a
pushq $0x20
popq %rdi
callq 0x5b488
movq %r13, %rbp
movq (%rbp), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2c10d