// File: /workspace/github_c_makefile_star2_O1/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 0x31454
movq %rax, %r12
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
callq 0x31454
movq %rax, %r14
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x30971
movq %rax, %r15
movq 0x38(%rbx), %rax
movq %r15, 0x18(%rax)
leaq 0x8e9a3(%rip), %r13     # 0xca800
leaq 0x20(%r13), %rbp
testq %r12, %r12
je 0x3bfb3
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x308e7
testl %eax, %eax
je 0x3be8d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r14, %r14
je 0x3bea6
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x308e7
testl %eax, %eax
jne 0x3be7e
addq $0x28, %r13
cmpq %r14, %r12
je 0x3bfb0
movq %r12, %rdi
movq %r15, %rsi
callq 0x3b89f
testl %eax, %eax
je 0x3bfb3
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x58433(%rip), %rsi     # 0x9430f
movl $0x20, %edi
callq 0x608b5
movq %r12, %rdi
callq 0x3bb8a
testq %rax, %rax
jne 0x3bf24
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3174b
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x58573(%rip), %rsi     # 0x9448d
movl $0x4, %edi
callq 0x608b5
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x316b7
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
callq 0x316b7
leaq 0x8e05b(%rip), %r12     # 0xc9fa8
incq 0x560(%r12)
testq %r14, %r14
jne 0x3bf79
movq %r15, %rdi
callq 0x3b65c
movq %rax, %r14
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdx
callq 0x314ef
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b674
testl %eax, %eax
je 0x3bfb0
incq 0x560(%r12)
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x10(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x58364(%rip), %rsi     # 0x9430a
movl $0x20, %edi
callq 0x608b5
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 0x2d6f0