LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: redisLogHexDump
void redisLogHexDump(int level, char *descr, void *value, size_t len) {
    char buf[65], *b;
    unsigned char *v = value;
    char charset[] = "0123456789abcdef";

    redisLog(level,"%s (hexdump):", descr);
    b = buf;
    while(len) {
        b[0] = charset[(*v)>>4];
        b[1] = charset[(*v)&0xf];
        b[2] = '\0';
        b += 2;
        len--;
        v++;
        if (b-buf == 64 || len == 0) {
            redisLogRaw(level|REDIS_LOG_RAW,buf);
            b = buf;
        }
    }
    redisLogRaw(level|REDIS_LOG_RAW,"\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x80157(%rip), %rax     # 0xe5b00
movq %rax, -0xa0(%rbp)
movq 0x80151(%rip), %rax     # 0xe5b08
movq %rax, -0x98(%rbp)
movb 0x8014c(%rip), %al      # 0xe5b10
movb %al, -0x90(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rdx
leaq 0x800eb(%rip), %rsi     # 0xe5ac3
movb $0x0, %al
callq 0x24fb0
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x65a88
movq -0x80(%rbp), %rax
movzbl (%rax), %eax
sarl $0x4, %eax
cltq
movb -0xa0(%rbp,%rax), %cl
movq -0x78(%rbp), %rax
movb %cl, (%rax)
movq -0x80(%rbp), %rax
movzbl (%rax), %eax
andl $0xf, %eax
cltq
movb -0xa0(%rbp,%rax), %cl
movq -0x78(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x78(%rbp), %rax
movb $0x0, 0x2(%rax)
movq -0x78(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
leaq -0x70(%rbp), %rcx
subq %rcx, %rax
cmpq $0x40, %rax
je 0x65a69
cmpq $0x0, -0x20(%rbp)
jne 0x65a83
movl -0x4(%rbp), %edi
orl $0x400, %edi            # imm = 0x400
leaq -0x70(%rbp), %rsi
callq 0x24dd0
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x659e7
movl -0x4(%rbp), %edi
orl $0x400, %edi            # imm = 0x400
leaq 0x7ad21(%rip), %rsi     # 0xe07b9
callq 0x24dd0
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: watchdogSignalHandler
void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
#ifdef HAVE_BACKTRACE
    ucontext_t *uc = (ucontext_t*) secret;
#endif
    REDIS_NOTUSED(info);
    REDIS_NOTUSED(sig);

    redisLogFromHandler(REDIS_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---");
#ifdef HAVE_BACKTRACE
    logStackTrace(uc);
#else
    redisLogFromHandler(REDIS_WARNING,"Sorry: no support for backtrace().");
#endif
    redisLogFromHandler(REDIS_WARNING,"--------\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x3, %edi
leaq 0x7fffa(%rip), %rsi     # 0xe5ad1
callq 0x25090
movq -0x20(%rbp), %rdi
callq 0x64f70
movl $0x3, %edi
leaq 0x80000(%rip), %rsi     # 0xe5af1
callq 0x25090
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetResize
static intset *intsetResize(intset *is, uint32_t len) {

    // 计算数组的空间大小
    uint32_t size = len*intrev32ifbe(is->encoding);

    // 根据空间大小，重新分配空间
    // 注意这里使用的是 zrealloc ，
    // 所以如果新空间大小比原来的空间大小要大，
    // 那么数组原有的数据会被保留
    is = zrealloc(is,sizeof(intset)+size);

    return is;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
imull (%rcx), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
addq $0x8, %rsi
callq 0x2e270
movq %rax, -0x8(%rbp)
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/intset.c
// Function: intsetMoveTail
static void intsetMoveTail(intset *is, uint32_t from, uint32_t to) {

    void *src, *dst;

    // 要移动的元素个数
    uint32_t bytes = intrev32ifbe(is->length)-from;

    // 集合的编码方式
    uint32_t encoding = intrev32ifbe(is->encoding);

    // 根据不同的编码
    // src = (Enc_t*)is->contents+from 记录移动开始的位置
    // dst = (Enc_t*)is_.contents+to 记录移动结束的位置
    // bytes *= sizeof(Enc_t) 计算一共要移动多少字节
    if (encoding == INTSET_ENC_INT64) {
        src = (int64_t*)is->contents+from;
        dst = (int64_t*)is->contents+to;
        bytes *= sizeof(int64_t);
    } else if (encoding == INTSET_ENC_INT32) {
        src = (int32_t*)is->contents+from;
        dst = (int32_t*)is->contents+to;
        bytes *= sizeof(int32_t);
    } else {
        src = (int16_t*)is->contents+from;
        dst = (int16_t*)is->contents+to;
        bytes *= sizeof(int16_t);
    }

    // 进行移动
    // T = O(N)
    memmove(dst,src,bytes);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpq $0x8, %rax
jne 0x677c9
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0xc(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0x10(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
shlq $0x3, %rax
movl %eax, -0x24(%rbp)
jmp 0x6783f
movl -0x28(%rbp), %eax
cmpq $0x4, %rax
jne 0x6780a
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0xc(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0x10(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
shlq $0x2, %rax
movl %eax, -0x24(%rbp)
jmp 0x6783d
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0xc(%rbp), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movl -0x10(%rbp), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
shlq %rax
movl %eax, -0x24(%rbp)
jmp 0x6783f
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %eax
movl %eax, %edx
callq 0x1f780
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetSet
static void _intsetSet(intset *is, int pos, int64_t value) {

    // 取出集合的编码方式
    uint32_t encoding = intrev32ifbe(is->encoding);

    // 根据编码 ((Enc_t*)is->contents) 将数组转换回正确的类型
    // 然后 ((Enc_t*)is->contents)[pos] 定位到数组索引上
    // 接着 ((Enc_t*)is->contents)[pos] = value 将值赋给数组
    // 最后， ((Enc_t*)is->contents)+pos 定位到刚刚设置的新值上 
    // 如果有需要的话， memrevEncifbe 将对值进行大小端转换
    if (encoding == INTSET_ENC_INT64) {
        ((int64_t*)is->contents)[pos] = value;
        memrev64ifbe(((int64_t*)is->contents)+pos);
    } else if (encoding == INTSET_ENC_INT32) {
        ((int32_t*)is->contents)[pos] = value;
        memrev32ifbe(((int32_t*)is->contents)+pos);
    } else {
        ((int16_t*)is->contents)[pos] = value;
        memrev16ifbe(((int16_t*)is->contents)+pos);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpq $0x8, %rax
jne 0x67894
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x678c7
movl -0x1c(%rbp), %eax
cmpq $0x4, %rax
jne 0x678b1
movq -0x18(%rbp), %rax
movl %eax, %edx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl %edx, 0x8(%rax,%rcx,4)
jmp 0x678c5
movq -0x18(%rbp), %rax
movw %ax, %dx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movw %dx, 0x8(%rax,%rcx,2)
jmp 0x678c7
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetRemove
intset *intsetRemove(intset *is, int64_t value, int *success) {

    // 计算 value 的编码方式
    uint8_t valenc = _intsetValueEncoding(value);
    uint32_t pos;

    // 默认设置标识值为删除失败
    if (success) *success = 0;

    // 当 value 的编码大小小于或等于集合的当前编码方式（说明 value 有可能存在于集合）
    // 并且 intsetSearch 的结果为真，那么执行删除
    // T = O(log N)
    if (valenc <= intrev32ifbe(is->encoding) && intsetSearch(is,value,&pos)) {

        // 取出集合当前的元素数量
        uint32_t len = intrev32ifbe(is->length);

        /* We know we can delete */
        // 设置标识值为删除成功
        if (success) *success = 1;

        /* Overwrite value with tail and update length */
        // 如果 value 不是位于数组的末尾
        // 那么需要对原本位于 value 之后的元素进行移动
        //
        // 举个例子，如果数组表示如下，而 b 为删除的目标
        // | a | b | c | d |
        // 那么 intsetMoveTail 将 b 之后的所有数据向前移动一个元素的空间，
        // 覆盖 b 原来的数据
        // | a | c | d | d |
        // 之后 intsetResize 缩小内存大小时，
        // 数组末尾多出来的一个元素的空间将被移除
        // | a | c | d |
        if (pos < (len-1)) intsetMoveTail(is,pos+1,pos);
        // 缩小数组的大小，移除被删除元素占用的空间
        // T = O(N)
        is = intsetResize(is,len-1);
        // 更新集合的元素数量
        is->length = intrev32ifbe(len-1);
    }

    return is;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x67460
movb %al, -0x19(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x67901
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movzbl -0x19(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x67980
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x675a0
movzbl %al, %eax
cmpl $0x0, %eax
je 0x67980
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x67941
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl -0x20(%rbp), %eax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x67960
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
addl $0x1, %esi
movl -0x20(%rbp), %edx
callq 0x67760
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
subl $0x1, %esi
callq 0x67720
movq %rax, -0x8(%rbp)
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetFind
uint8_t intsetFind(intset *is, int64_t value) {

    // 计算 value 的编码
    uint8_t valenc = _intsetValueEncoding(value);

    // 如果 value 的编码大于集合的当前编码，那么 value 一定不存在于集合
    // 当 value 的编码小于等于集合的当前编码时，
    // 才再使用 intsetSearch 进行查找
    return valenc <= intrev32ifbe(is->encoding) && intsetSearch(is,value,NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x67460
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl (%rdx), %ecx
movb %al, -0x12(%rbp)
ja 0x679da
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x675a0
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x12(%rbp)
movb -0x12(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetGet
uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value) {

    // pos < intrev32ifbe(is->length) 
    // 检查 pos 是否符合数组的范围
    if (pos < intrev32ifbe(is->length)) {

        // 保存值到指针
        *value = _intsetGet(is,pos);

        // 返回成功指示值
        return 1;
    }

    // 超出索引范围
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x67a9b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x67a30
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x67a9f
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/intset.c
// Function: intsetGetEncoded
static int64_t _intsetGetEncoded(intset *is, int pos, uint8_t enc) {
    int64_t v64;
    int32_t v32;
    int16_t v16;

    // ((ENCODING*)is->contents) 首先将数组转换回被编码的类型
    // 然后 ((ENCODING*)is->contents)+pos 计算出元素在数组中的正确位置
    // 之后 member(&vEnc, ..., sizeof(vEnc)) 再从数组中拷贝出正确数量的字节
    // 如果有需要的话， memrevEncifbe(&vEnc) 会对拷贝出的字节进行大小端转换
    // 最后将值返回
    if (enc == INTSET_ENC_INT64) {
        memcpy(&v64,((int64_t*)is->contents)+pos,sizeof(v64));
        memrev64ifbe(&v64);
        return v64;
    } else if (enc == INTSET_ENC_INT32) {
        memcpy(&v32,((int32_t*)is->contents)+pos,sizeof(v32));
        memrev32ifbe(&v32);
        return v32;
    } else {
        memcpy(&v16,((int16_t*)is->contents)+pos,sizeof(v16));
        memrev16ifbe(&v16);
        return v16;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
cmpq $0x8, %rax
jne 0x67b25
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x67b62
movzbl -0x15(%rbp), %eax
cmpq $0x4, %rax
jne 0x67b48
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl 0x8(%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x67b62
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movw 0x8(%rax,%rcx,2), %ax
movw %ax, -0x26(%rbp)
movswq -0x26(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterLookupNode
clusterNode *clusterLookupNode(char *name) {
    sds s = sdsnewlen(name, REDIS_CLUSTER_NAMELEN);
    dictEntry *de;

    de = dictFind(server.cluster->nodes,s);
    sdsfree(s);
    if (de == NULL) return NULL;
    return dictGetVal(de);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x28, %esi
callq 0x2c000
movq %rax, -0x18(%rbp)
leaq 0xaaf23(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x23aa0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2c160
cmpq $0x0, -0x20(%rbp)
jne 0x68a07
movq $0x0, -0x8(%rbp)
jmp 0x68a13
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: createClusterNode
clusterNode *createClusterNode(char *nodename, int flags) {
    clusterNode *node = zmalloc(sizeof(*node));

    // 设置名字
    if (nodename)
        memcpy(node->name, nodename, REDIS_CLUSTER_NAMELEN);
    else
        getRandomHexChars(node->name, REDIS_CLUSTER_NAMELEN);

    // 初始化属性
    node->ctime = mstime();
    node->configEpoch = 0;
    node->flags = flags;
    memset(node->slots,0,sizeof(node->slots));
    node->numslots = 0;
    node->numslaves = 0;
    node->slaves = NULL;
    node->slaveof = NULL;
    node->ping_sent = node->pong_received = 0;
    node->fail_time = 0;
    node->link = NULL;
    memset(node->ip,0,sizeof(node->ip));
    node->port = 0;
    node->fail_reports = listCreate();
    node->voted_time = 0;
    node->repl_offset_time = 0;
    node->repl_offset = 0;
    listSetFreeMethod(node->fail_reports,zfree);

    return node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x8d0, %edi            # imm = 0x8D0
callq 0x2e130
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x68a5c
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rsi
movl $0x28, %edx
callq 0x1fbf0
jmp 0x68a6e
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movl $0x28, %esi
callq 0x39c50
callq 0x252e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1f110
movq -0x18(%rbp), %rax
movl $0x0, 0x840(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x844(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x848(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x850(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x860(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x858(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x868(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x8c0(%rax)
movq -0x18(%rbp), %rdi
addq $0x888, %rdi            # imm = 0x888
xorl %esi, %esi
movl $0x2e, %edx
callq 0x1f110
movq -0x18(%rbp), %rax
movl $0x0, 0x8b8(%rax)
callq 0x1fdb0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8c8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x870(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x878(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x880(%rax)
movq -0x18(%rbp), %rax
movq 0x8c8(%rax), %rax
leaq -0x3a7f4(%rip), %rcx    # 0x2e3a0
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterAddNode
int clusterAddNode(clusterNode *node) {
    int retval;
    // 将 node 添加到当前节点的 nodes 表中
    // 这样接下来当前节点就会创建连向 node 的节点
    retval = dictAdd(server.cluster->nodes,
            sdsnewlen(node->name,REDIS_CLUSTER_NAMELEN), node);
    return (retval == DICT_OK) ? REDIS_OK : REDIS_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xaad35(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movl $0x28, %esi
callq 0x2c000
movq -0x18(%rbp), %rdi
movq %rax, %rsi
movq -0x8(%rbp), %rdx
callq 0x236d0
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterNodeAddSlave
int clusterNodeAddSlave(clusterNode *master, clusterNode *slave) {
    int j;

    /* If it's already a slave, don't add it again. */
    // 如果 slave 已经存在，那么不做操作
    for (j = 0; j < master->numslaves; j++)
        if (master->slaves[j] == slave) return REDIS_ERR;

    // 将 slave 添加到 slaves 数组里面
    master->slaves = zrealloc(master->slaves,
        sizeof(clusterNode*)*(master->numslaves+1));
    master->slaves[master->numslaves] = slave;
    master->numslaves++;

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x844(%rcx), %eax
jge 0x68c65
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x18(%rbp), %rax
jne 0x68c58
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x68ccf
jmp 0x68c5a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x68c27
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x844(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x2e270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x848(%rax)
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x844(%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movl 0x844(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x844(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterAddSlot
int clusterAddSlot(clusterNode *n, int slot) {

    // 槽 slot 已经是节点 n 处理的了
    if (server.cluster->slots[slot]) return REDIS_ERR;

    // 设置 bitmap
    clusterNodeSetSlotBit(n,slot);

    // 更新集群状态
    server.cluster->slots[slot] = n;

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
leaq 0xaac02(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, 0x40028(%rax,%rcx,8)
je 0x68d15
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x68d46
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x6eb50
movq -0x10(%rbp), %rdx
leaq 0xaabcc(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, 0x40028(%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterLockConfig
int clusterLockConfig(char *filename) {
    /* To lock it, we need to open the file in a way it is created if
     * it does not exist, otherwise there is a race condition with other
     * processes. */
    int fd = open(filename,O_WRONLY|O_CREAT,0644);
    if (fd == -1) {
        redisLog(REDIS_WARNING,
            "Can't open %s in order to acquire a lock: %s",
            filename, strerror(errno));
        return REDIS_ERR;
    }

    if (flock(fd,LOCK_EX|LOCK_NB) == -1) {
        if (errno == EWOULDBLOCK) {
            redisLog(REDIS_WARNING,
                 "Sorry, the cluster configuration file %s is already used "
                 "by a different Redis Cluster node. Please make sure that "
                 "different nodes use different cluster configuration "
                 "files.", filename);
        } else {
            redisLog(REDIS_WARNING,
                "Impossible to lock %s: %s", filename, strerror(errno));
        }
        close(fd);
        return REDIS_ERR;
    }
    /* Lock acquired: leak the 'fd' by not closing it, so that we'll retain the
     * lock to the file as long as the process exists. */
    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x41, %esi
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0x1f640
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x690c1
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
callq 0x1f820
movl (%rax), %edi
callq 0x1f630
movq -0x20(%rbp), %rdx
movq %rax, %rcx
movl $0x3, %edi
leaq 0x7cd1a(%rip), %rsi     # 0xe5dcb
movb $0x0, %al
callq 0x24fb0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6913c
movl -0x14(%rbp), %edi
movl $0x6, %esi
callq 0x1f610
cmpl $-0x1, %eax
jne 0x69135
callq 0x1f820
cmpl $0xb, (%rax)
jne 0x690f6
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x7cd0b(%rip), %rsi     # 0xe5df8
movb $0x0, %al
callq 0x24fb0
jmp 0x69124
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x1f820
movl (%rax), %edi
callq 0x1f630
movq -0x28(%rbp), %rdx
movq %rax, %rcx
movl $0x3, %edi
leaq 0x7cd88(%rip), %rsi     # 0xe5ea5
movb $0x0, %al
callq 0x24fb0
movl -0x14(%rbp), %edi
callq 0x1f170
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6913c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterAcceptHandler
void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    int cport, cfd;
    int max = MAX_CLUSTER_ACCEPTS_PER_CALL;
    char cip[REDIS_IP_STR_LEN];
    clusterLink *link;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(mask);
    REDIS_NOTUSED(privdata);

    /* If the server is starting up, don't accept cluster connections:
     * UPDATE messages may interact with the database content. */
    if (server.masterhost == NULL && server.loading) return;

    while(max--) {
        cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
        if (cfd == ANET_ERR) {
            if (errno != EWOULDBLOCK)
                redisLog(REDIS_VERBOSE,
                    "Accepting cluster node: %s", server.neterr);
            return;
        }
        anetNonBlock(NULL,cfd);
        anetEnableTcpNoDelay(NULL,cfd);

        /* Use non-blocking I/O for cluster messages. */
        redisLog(REDIS_VERBOSE,"Accepted cluster node %s:%d", cip, cport);
        /* Create a link object we use to handle the connection.
         * It gets passed to the readable handler when data is available.
         * Initiallly the link->node pointer is set to NULL as we don't know
         * which node is, but the right node is references once we know the
         * node identity. */
        link = createClusterLink(NULL);
        link->fd = cfd;
        aeCreateFileEvent(server.el,cfd,AE_READABLE,clusterReadHandler,link);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x3e8, -0x28(%rbp)     # imm = 0x3E8
leaq 0xaa3b4(%rip), %rax     # 0x1138f8
cmpq $0x0, 0x650(%rax)
jne 0x69563
leaq 0xaa3a3(%rip), %rax     # 0x1138f8
cmpl $0x0, 0x2f0(%rax)
je 0x69563
jmp 0x69643
jmp 0x69565
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x28(%rbp)
cmpl $0x0, %eax
je 0x69643
movl -0xc(%rbp), %esi
leaq -0x60(%rbp), %rdx
leaq 0xaa371(%rip), %rdi     # 0x1138f8
addq $0x1e8, %rdi            # imm = 0x1E8
movl $0x2e, %ecx
leaq -0x20(%rbp), %r8
callq 0x229d0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x695d2
callq 0x1f820
cmpl $0xb, (%rax)
je 0x695d0
movl $0x1, %edi
leaq 0x7ca06(%rip), %rsi     # 0xe5fc1
leaq 0xaa336(%rip), %rdx     # 0x1138f8
addq $0x1e8, %rdx            # imm = 0x1E8
movb $0x0, %al
callq 0x24fb0
jmp 0x69643
movl -0x24(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x21890
movl -0x24(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x21ba0
leaq -0x60(%rbp), %rdx
movl -0x20(%rbp), %ecx
movl $0x1, %edi
leaq 0x7c9df(%rip), %rsi     # 0xe5fdc
movb $0x0, %al
callq 0x24fb0
xorl %eax, %eax
movl %eax, %edi
callq 0x69b30
movq %rax, -0x68(%rbp)
movl -0x24(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
leaq 0xaa2d6(%rip), %rax     # 0x1138f8
movq 0x28(%rax), %rdi
movl -0x24(%rbp), %esi
movq -0x68(%rbp), %r8
movl $0x1, %edx
leaq 0x617(%rip), %rcx       # 0x69c50
callq 0x20a80
jmp 0x69565
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSetNodeAsMaster
void clusterSetNodeAsMaster(clusterNode *n) {

    // 已经是主节点了。
    if (nodeIsMaster(n)) return;

    // 移除 slaveof
    if (n->slaveof) clusterNodeRemoveSlave(n->slaveof,n);

    // 关闭 SLAVE 标识
    n->flags &= ~REDIS_NODE_SLAVE;

    // 打开 MASTER 标识
    n->flags |= REDIS_NODE_MASTER;

    // 清零 slaveof 属性
    n->slaveof = NULL;

    /* Update config and state. */
    clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
                         CLUSTER_TODO_UPDATE_STATE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6988d
jmp 0x698e2
movq -0x8(%rbp), %rax
cmpq $0x0, 0x850(%rax)
je 0x698af
movq -0x8(%rbp), %rax
movq 0x850(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x6a1e0
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x850(%rax)
movl $0x6, %edi
callq 0x69b00
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterDelSlot
int clusterDelSlot(int slot) {

    // 获取当前处理槽 slot 的节点 n
    clusterNode *n = server.cluster->slots[slot];

    if (!n) return REDIS_ERR;

    // 清除位图
    redisAssert(clusterNodeClearSlotBit(n,slot) == 1);

    // 清空负责处理槽的节点
    server.cluster->slots[slot] = NULL;

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
leaq 0xa9ff6(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
movq 0x40028(%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x69929
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x69983
movq -0x10(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x6ebb0
cmpl $0x1, %eax
jne 0x6993c
jmp 0x6995e
leaq 0x7ce69(%rip), %rdi     # 0xe67ac
leaq 0x7c35b(%rip), %rsi     # 0xe5ca5
movl $0xfaa, %edx            # imm = 0xFAA
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
leaq 0xa9f93(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0x8(%rbp), %rcx
movq $0x0, 0x40028(%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterDelNode
void clusterDelNode(clusterNode *delnode) {
    int j;
    dictIterator *di;
    dictEntry *de;

    /* 1) Mark slots as unassigned. */
    for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
        // 取消向该节点接收槽的计划
        if (server.cluster->importing_slots_from[j] == delnode)
            server.cluster->importing_slots_from[j] = NULL;
        // 取消向该节点移交槽的计划
        if (server.cluster->migrating_slots_to[j] == delnode)
            server.cluster->migrating_slots_to[j] = NULL;
        // 将所有由该节点负责的槽设置为未分配
        if (server.cluster->slots[j] == delnode)
            clusterDelSlot(j);
    }

    /* 2) Remove failure reports. */
    // 移除所有由该节点发送的下线报告
    di = dictGetSafeIterator(server.cluster->nodes);
    while((de = dictNext(di)) != NULL) {
        clusterNode *node = dictGetVal(de);

        if (node == delnode) continue;
        clusterNodeDelFailureReport(node,delnode);
    }
    dictReleaseIterator(di);

    /* 3) Remove this node from its master's slaves if needed. */
    // 将节点从它的主节点的从节点列表中移除
    if (nodeIsSlave(delnode) && delnode->slaveof)
        clusterNodeRemoveSlave(delnode->slaveof,delnode);

    /* 4) Free the node, unlinking it from the cluster. */
    // 释放节点
    freeClusterNode(delnode);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x4000, -0xc(%rbp)     # imm = 0x4000
jge 0x69a5e
leaq 0xa9f41(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0xc(%rbp), %rcx
movq 0x20028(%rax,%rcx,8), %rax
cmpq -0x8(%rbp), %rax
jne 0x699ee
leaq 0xa9f21(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0xc(%rbp), %rcx
movq $0x0, 0x20028(%rax,%rcx,8)
leaq 0xa9f03(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0xc(%rbp), %rcx
movq 0x28(%rax,%rcx,8), %rax
cmpq -0x8(%rbp), %rax
jne 0x69a26
leaq 0xa9ee6(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0xc(%rbp), %rcx
movq $0x0, 0x28(%rax,%rcx,8)
leaq 0xa9ecb(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movslq -0xc(%rbp), %rcx
movq 0x40028(%rax,%rcx,8), %rax
cmpq -0x8(%rbp), %rax
jne 0x69a4e
movl -0xc(%rbp), %edi
callq 0x698f0
jmp 0x69a50
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x699a3
leaq 0xa9e93(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x24240
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x24270
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x69ab3
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x8(%rbp), %rax
jne 0x69aa4
jmp 0x69a79
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x6a110
jmp 0x69a79
movq -0x18(%rbp), %rdi
callq 0x243d0
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x69aed
movq -0x8(%rbp), %rax
cmpq $0x0, 0x850(%rax)
je 0x69aed
movq -0x8(%rbp), %rax
movq 0x850(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x6a1e0
movq -0x8(%rbp), %rdi
callq 0x6a350
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterNodeRemoveSlave
int clusterNodeRemoveSlave(clusterNode *master, clusterNode *slave) {
    int j;

    // 在 slaves 数组中找到从节点 slave 所属的主节点，
    // 将主节点中的 slave 信息移除
    for (j = 0; j < master->numslaves; j++) {
        if (master->slaves[j] == slave) {
            memmove(master->slaves+j,master->slaves+(j+1),
                (master->numslaves-1)-j);
            master->numslaves--;
            return REDIS_OK;
        }
    }
    return REDIS_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x844(%rcx), %eax
jge 0x6a297
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x18(%rbp), %rax
jne 0x6a287
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x848(%rax), %rsi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x844(%rax), %eax
subl $0x1, %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rdx
callq 0x1f780
movq -0x10(%rbp), %rax
movl 0x844(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x844(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x6a29e
jmp 0x6a289
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6a1f7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: freeClusterNode
void freeClusterNode(clusterNode *n) {
    sds nodename;

    nodename = sdsnewlen(n->name, REDIS_CLUSTER_NAMELEN);

    // 从 nodes 表中删除节点
    redisAssert(dictDelete(server.cluster->nodes,nodename) == DICT_OK);
    sdsfree(nodename);

    // 移除从节点
    if (n->slaveof) clusterNodeRemoveSlave(n->slaveof, n);

    // 释放连接
    if (n->link) freeClusterLink(n->link);
    
    // 释放失败报告
    listRelease(n->fail_reports);

    // 释放节点结构
    zfree(n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movl $0x28, %esi
callq 0x2c000
movq %rax, -0x10(%rbp)
leaq 0xa957f(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x23c30
cmpl $0x0, %eax
jne 0x6a394
jmp 0x6a3b6
leaq 0x7bc5d(%rip), %rdi     # 0xe5ff8
leaq 0x7b903(%rip), %rsi     # 0xe5ca5
movl $0x3cb, %edx            # imm = 0x3CB
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x10(%rbp), %rdi
callq 0x2c160
movq -0x8(%rbp), %rax
cmpq $0x0, 0x850(%rax)
je 0x6a3e1
movq -0x8(%rbp), %rax
movq 0x850(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x6a1e0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8c0(%rax)
je 0x6a3ff
movq -0x8(%rbp), %rax
movq 0x8c0(%rax), %rdi
callq 0x69ba0
movq -0x8(%rbp), %rax
movq 0x8c8(%rax), %rdi
callq 0x1fe30
movq -0x8(%rbp), %rdi
callq 0x2e3a0
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterRenameNode
void clusterRenameNode(clusterNode *node, char *newname) {
    int retval;
    sds s = sdsnewlen(node->name, REDIS_CLUSTER_NAMELEN);

    redisLog(REDIS_DEBUG,"Renaming node %.40s into %.40s",
        node->name, newname);
    retval = dictDelete(server.cluster->nodes, s);
    sdsfree(s);
    redisAssert(retval == DICT_OK);
    memcpy(node->name, newname, REDIS_CLUSTER_NAMELEN);
    clusterAddNode(node);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movl $0x28, %esi
callq 0x2c000
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdx
addq $0x8, %rdx
movq -0x10(%rbp), %rcx
xorl %edi, %edi
leaq 0x7bbd3(%rip), %rsi     # 0xe602e
movb $0x0, %al
callq 0x24fb0
leaq 0xa948f(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x23c30
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2c160
cmpl $0x0, -0x14(%rbp)
jne 0x6a491
jmp 0x6a4b3
leaq 0x7848a(%rip), %rdi     # 0xe2922
leaq 0x7b806(%rip), %rsi     # 0xe5ca5
movl $0x43b, %edx            # imm = 0x43B
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
movl $0x28, %edx
callq 0x1fbf0
movq -0x8(%rbp), %rdi
callq 0x68bb0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterBlacklistAddNode
void clusterBlacklistAddNode(clusterNode *node) {
    dictEntry *de;
    sds id = sdsnewlen(node->name,REDIS_CLUSTER_NAMELEN);

    // 先清理过期名单
    clusterBlacklistCleanup();

    // 添加节点
    if (dictAdd(server.cluster->nodes_black_list,id,NULL) == DICT_OK) {
        /* If the key was added, duplicate the sds string representation of
         * the key for the next lookup. We'll free it at the end. */
        id = sdsdup(id);
    }
    // 设置过期时间
    de = dictFind(server.cluster->nodes_black_list,id);
    dictSetUnsignedIntegerVal(de,time(NULL)+REDIS_CLUSTER_BLACKLIST_TTL);
    sdsfree(id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movl $0x28, %esi
callq 0x2c000
movq %rax, -0x18(%rbp)
callq 0x6a4e0
leaq 0xa935a(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x236d0
cmpl $0x0, %eax
jne 0x6a5c8
movq -0x18(%rbp), %rdi
callq 0x2c130
movq %rax, -0x18(%rbp)
leaq 0xa9329(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x23aa0
movq %rax, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x1fc70
movq %rax, %rcx
addq $0x3c, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rdi
callq 0x2c160
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterBlacklistExists
int clusterBlacklistExists(char *nodeid) {

    // 构建 SDS 表示的节点名
    sds id = sdsnewlen(nodeid,REDIS_CLUSTER_NAMELEN);
    int retval;

    // 清除过期黑名单
    clusterBlacklistCleanup();

    // 检查节点是否存在
    retval = dictFind(server.cluster->nodes_black_list,id) != NULL;
    sdsfree(id);

    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movl $0x28, %esi
callq 0x2c000
movq %rax, -0x10(%rbp)
callq 0x6a4e0
leaq 0xa92be(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x23aa0
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2c160
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: markNodeAsFailingIfNeeded
void markNodeAsFailingIfNeeded(clusterNode *node) {
    int failures;

    // 标记为 FAIL 所需的节点数量，需要超过集群节点数量的一半
    int needed_quorum = (server.cluster->size / 2) + 1;

    if (!nodeTimedOut(node)) return; /* We can reach it. */
    if (nodeFailed(node)) return; /* Already FAILing. */

    // 统计将 node 标记为 PFAIL 或者 FAIL 的节点数量（不包括当前节点）
    failures = clusterNodeFailureReportsCount(node);

    /* Also count myself as a voter if I'm a master. */
    // 如果当前节点是主节点，那么将当前节点也算在 failures 之内
    if (nodeIsMaster(myself)) failures++;
    // 报告下线节点的数量不足节点总数的一半，不能将节点判断为 FAIL ，返回
    if (failures < needed_quorum) return; /* No weak agreement from masters. */

    redisLog(REDIS_NOTICE,
        "Marking node %.40s as failing (quorum reached).", node->name);

    /* Mark the node as failing. */
    // 将 node 标记为 FAIL
    node->flags &= ~REDIS_NODE_PFAIL;
    node->flags |= REDIS_NODE_FAIL;
    node->fail_time = mstime();

    /* Broadcast the failing node name to everybody, forcing all the other
     * reachable nodes to flag the node as FAIL. */
    // 如果当前节点是主节点的话，那么向其他节点发送报告 node 的 FAIL 信息
    // 让其他节点也将 node 标记为 FAIL
    if (nodeIsMaster(myself)) clusterSendFail(node->name);
    clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xa9275(%rip), %rax     # 0x1138f8
movq 0x7d0(%rax), %rax
movl 0x14(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x6a6af
jmp 0x6a765
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6a6c3
jmp 0x6a765
movq -0x8(%rbp), %rdi
callq 0x6a1b0
movl %eax, -0xc(%rbp)
movq 0xbd8a2(%rip), %rax     # 0x127f78
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6a6ea
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x6a6f4
jmp 0x6a765
movq -0x8(%rbp), %rdx
addq $0x8, %rdx
movl $0x2, %edi
leaq 0x7b945(%rip), %rsi     # 0xe604d
movb $0x0, %al
callq 0x24fb0
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x30(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x868(%rax)
movq 0xbd835(%rip), %rax     # 0x127f78
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6a75b
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0x6a770
movl $0x6, %edi
callq 0x69b00
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSendFail
void clusterSendFail(char *nodename) {
    unsigned char buf[sizeof(clusterMsg)];
    clusterMsg *hdr = (clusterMsg*) buf;

    // 创建下线消息
    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAIL);

    // 记录命令
    memcpy(hdr->data.fail.about.nodename,nodename,REDIS_CLUSTER_NAMELEN);

    // 广播消息
    clusterBroadcastMessage(buf,ntohl(hdr->totlen));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10f0, %rsp           # imm = 0x10F0
movq %rdi, -0x8(%rbp)
leaq -0x10e0(%rbp), %rax
movq %rax, -0x10e8(%rbp)
movq -0x10e8(%rbp), %rdi
movl $0x3, %esi
callq 0x6cd20
movq -0x10e8(%rbp), %rdi
addq $0x8a0, %rdi            # imm = 0x8A0
movq -0x8(%rbp), %rsi
movl $0x28, %edx
callq 0x1fbf0
leaq -0x10e0(%rbp), %rax
movq %rax, -0x10f0(%rbp)
movq -0x10e8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x1f5a0
movq -0x10f0(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x6cc80
addq $0x10f0, %rsp           # imm = 0x10F0
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: nodeUpdateAddressIfNeeded
int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link, int port) {
    char ip[REDIS_IP_STR_LEN];

    /* We don't proceed if the link is the same as the sender link, as this
     * function is designed to see if the node link is consistent with the
     * symmetric link that is used to receive PINGs from the node.
     *
     * As a side effect this function never frees the passed 'link', so
     * it is safe to call during packet processing. */
    // 连接不变，直接返回
    if (link == node->link) return 0;

    // 获取字符串格式的 ip 地址
    nodeIp2String(ip,link);
    // 获取端口号
    if (node->port == port && strcmp(ip,node->ip) == 0) return 0;

    /* IP / port is different, update it. */
    memcpy(node->ip,ip,sizeof(ip));
    node->port = port;

    // 释放旧连接（新连接会在之后自动创建）
    if (node->link) freeClusterLink(node->link);

    redisLog(REDIS_WARNING,"Address updated for node %.40s, now %s:%d",
        node->name, node->ip, node->port);

    /* Check if this is our master and we have to change the
     * replication target as well. */
    // 如果连接来自当前节点（从节点）的主节点，那么根据新地址设置复制对象
    if (nodeIsSlave(myself) && myself->slaveof == node)
        replicationSetMaster(node->ip, node->port);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8c0(%rcx), %rax
jne 0x6af70
movl $0x0, -0x4(%rbp)
jmp 0x6b06d
leaq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6af10
movq -0x10(%rbp), %rax
movl 0x8b8(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x6afb1
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x888, %rsi            # imm = 0x888
callq 0x1f890
cmpl $0x0, %eax
jne 0x6afb1
movl $0x0, -0x4(%rbp)
jmp 0x6b06d
movq -0x10(%rbp), %rdi
addq $0x888, %rdi            # imm = 0x888
leaq -0x50(%rbp), %rsi
movl $0x2e, %edx
callq 0x1fbf0
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8b8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8c0(%rax)
je 0x6aff5
movq -0x10(%rbp), %rax
movq 0x8c0(%rax), %rdi
callq 0x69ba0
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
movq -0x10(%rbp), %rcx
addq $0x888, %rcx            # imm = 0x888
movq -0x10(%rbp), %rax
movl 0x8b8(%rax), %r8d
movl $0x3, %edi
leaq 0x7b1d7(%rip), %rsi     # 0xe61f6
movb $0x0, %al
callq 0x24fb0
movq 0xbcf4b(%rip), %rax     # 0x127f78
movl 0x30(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x6b066
movq 0xbcf39(%rip), %rax     # 0x127f78
movq 0x850(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x6b066
movq -0x10(%rbp), %rdi
addq $0x888, %rdi            # imm = 0x888
movq -0x10(%rbp), %rax
movl 0x8b8(%rax), %esi
callq 0x42000
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSetMaster
void clusterSetMaster(clusterNode *n) {
    redisAssert(n != myself);
    redisAssert(myself->numslots == 0);

    if (nodeIsMaster(myself)) {
        myself->flags &= ~REDIS_NODE_MASTER;
        myself->flags |= REDIS_NODE_SLAVE;
        clusterCloseAllSlots();
    } else {
        if (myself->slaveof)
            clusterNodeRemoveSlave(myself->slaveof,myself);
    }

    // 将 slaveof 属性指向主节点
    myself->slaveof = n;

    // 设置主节点的 IP 和地址，开始对它进行复制
    clusterNodeAddSlave(n,myself);
    replicationSetMaster(n->ip, n->port);
    resetManualFailover();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq 0xbcc01(%rip), %rax     # 0x127f78
je 0x6b37b
jmp 0x6b39d
leaq 0x7b518(%rip), %rdi     # 0xe689a
leaq 0x7a91c(%rip), %rsi     # 0xe5ca5
movl $0x109a, %edx           # imm = 0x109A
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq 0xbcbd4(%rip), %rax     # 0x127f78
cmpl $0x0, 0x840(%rax)
jne 0x6b3af
jmp 0x6b3d1
leaq 0x7b4f0(%rip), %rdi     # 0xe68a6
leaq 0x7a8e8(%rip), %rsi     # 0xe5ca5
movl $0x109b, %edx           # imm = 0x109B
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq 0xbcba0(%rip), %rax     # 0x127f78
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6b40a
movq 0xbcb8e(%rip), %rax     # 0x127f78
movl 0x30(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x30(%rax)
movq 0xbcb7e(%rip), %rax     # 0x127f78
movl 0x30(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x30(%rax)
callq 0x694d0
jmp 0x6b437
movq 0xbcb67(%rip), %rax     # 0x127f78
cmpq $0x0, 0x850(%rax)
je 0x6b435
movq 0xbcb56(%rip), %rax     # 0x127f78
movq 0x850(%rax), %rdi
movq 0xbcb48(%rip), %rsi     # 0x127f78
callq 0x6a1e0
jmp 0x6b437
movq -0x8(%rbp), %rcx
movq 0xbcb36(%rip), %rax     # 0x127f78
movq %rcx, 0x850(%rax)
movq -0x8(%rbp), %rdi
movq 0xbcb24(%rip), %rsi     # 0x127f78
callq 0x68c10
movq -0x8(%rbp), %rdi
addq $0x888, %rdi            # imm = 0x888
movq -0x8(%rbp), %rax
movl 0x8b8(%rax), %esi
callq 0x42000
callq 0x69650
addq $0x10, %rsp
popq %rbp
retq
nop