// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: verifyClusterConfigWithData
int verifyClusterConfigWithData(void) {
    int j;
    int update_config = 0;

    /* If this node is a slave, don't perform the check at all as we
     * completely depend on the replication stream. */
    // 不对从节点进行检查
    if (nodeIsSlave(myself)) return REDIS_OK;

    /* Make sure we only have keys in DB0. */
    // 确保只有 0 号数据库有数据
    for (j = 1; j < server.dbnum; j++) {
        if (dictSize(server.db[j].dict)) return REDIS_ERR;
    }

    /* Check that all the slots we see populated memory have a corresponding
     * entry in the cluster table. Otherwise fix the table. */
    // 检查槽表是否都有相应的节点，如果不是的话，进行修复
    for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
        if (!countKeysInSlot(j)) continue; /* No keys in this slot. */
        /* Check if we are assigned to this slot or if we are importing it.
         * In both cases check the next slot as the configuration makes
         * sense. */
        // 跳过正在导入的槽
        if (server.cluster->slots[j] == myself ||
            server.cluster->importing_slots_from[j] != NULL) continue;

        /* If we are here data and cluster config don't agree, and we have
         * slot 'j' populated even if we are not importing it, nor we are
         * assigned to this slot. Fix this condition. */

        update_config++;
        /* Case A: slot is unassigned. Take responsability for it. */
        if (server.cluster->slots[j] == NULL) {
            // 处理未被接受的槽
            redisLog(REDIS_WARNING, "I've keys about slot %d that is "
                                    "unassigned. Taking responsability "
                                    "for it.",j);
            clusterAddSlot(myself,j);
        } else {
            // 如果一个槽已经被其他节点接管
            // 那么将槽中的资料发送给对方
            redisLog(REDIS_WARNING, "I've keys about slot %d that is "
                                    "already assigned to a different node. "
                                    "Setting it in importing state.",j);
            server.cluster->importing_slots_from[j] = server.cluster->slots[j];
        }
    }

    // 保存 nodes.conf 文件
    if (update_config) clusterSaveConfigOrDie(1);

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0xc(%rbp)
movq 0xb9352(%rip), %rax     # 0x127f78
movl 0x30(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x6ec3d
movl $0x0, -0x4(%rbp)
jmp 0x6edd8
movl $0x1, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0xa4caa(%rip), %rcx     # 0x1138f8
cmpl 0x480(%rcx), %eax
jge 0x6ecaf
leaq 0xa4c9b(%rip), %rax     # 0x1138f8
movq 0x10(%rax), %rax
movslq -0x8(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
leaq 0xa4c7e(%rip), %rcx     # 0x1138f8
movq 0x10(%rcx), %rcx
movslq -0x8(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
addq 0x48(%rcx), %rax
cmpq $0x0, %rax
je 0x6eca2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6edd8
jmp 0x6eca4
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x6ec44
movl $0x0, -0x8(%rbp)
cmpl $0x4000, -0x8(%rbp)     # imm = 0x4000
jge 0x6edc1
movl -0x8(%rbp), %edi
callq 0x3ec00
cmpl $0x0, %eax
jne 0x6ecd5
jmp 0x6edb3
leaq 0xa4c1c(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
movq 0x40028(%rax,%rcx,8), %rax
cmpq 0xb9282(%rip), %rax     # 0x127f78
je 0x6ed15
leaq 0xa4bf9(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
cmpq $0x0, 0x20028(%rax,%rcx,8)
je 0x6ed1a
jmp 0x6edb3
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0xa4bce(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
cmpq $0x0, 0x40028(%rax,%rcx,8)
jne 0x6ed67
movl -0x8(%rbp), %edx
movl $0x3, %edi
leaq 0x77a9c(%rip), %rsi     # 0xe67eb
movb $0x0, %al
callq 0x24fb0
movq 0xb921b(%rip), %rdi     # 0x127f78
movl -0x8(%rbp), %esi
callq 0x68ce0
jmp 0x6edb1
movl -0x8(%rbp), %edx
movl $0x3, %edi
leaq 0x77abf(%rip), %rsi     # 0xe6835
movb $0x0, %al
callq 0x24fb0
leaq 0xa4b74(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
movq 0x40028(%rax,%rcx,8), %rdx
leaq 0xa4b5a(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
movq %rdx, 0x20028(%rax,%rcx,8)
jmp 0x6edb3
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x6ecb6
cmpl $0x0, -0xc(%rbp)
je 0x6edd1
movl $0x1, %edi
callq 0x69020
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)