LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movq 0x8c5ef(%rip), %rax     # 0xde628
cmpq %rdi, %rax
je 0x52126
cmpl $0x0, 0x840(%rax)
jne 0x5213b
movq %rdi, %rbx
movl 0x30(%rax), %ecx
testb $0x1, %cl
jne 0x5208f
movq 0x850(%rax), %r14
testq %r14, %r14
je 0x520ce
movslq 0x844(%r14), %rcx
testq %rcx, %rcx
jle 0x520ce
movq 0x848(%r14), %rsi
xorl %edx, %edx
cmpq %rax, (%rsi,%rdx,8)
je 0x52105
incq %rdx
cmpq %rdx, %rcx
jne 0x5207b
jmp 0x520ce
andl $-0x4, %ecx
orl $0x2, %ecx
movl %ecx, 0x30(%rax)
leaq 0x77f09(%rip), %r14     # 0xc9fa8
movq 0x7d0(%r14), %rdi
addq $0x28, %rdi
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x1f110
movl $0x20028, %edi          # imm = 0x20028
addq 0x7d0(%r14), %rdi
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x1f110
movq 0x8c553(%rip), %rsi     # 0xde628
movq %rbx, 0x850(%rsi)
movq %rbx, %rdi
callq 0x504e5
movl 0x8b8(%rbx), %esi
addq $0x888, %rbx            # imm = 0x888
movq %rbx, %rdi
callq 0x35339
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x50bd9
leaq (%rsi,%rdx,8), %rdi
leaq (%rsi,%rdx,8), %rsi
addq $0x8, %rsi
notl %edx
addl %ecx, %edx
movslq %edx, %rdx
callq 0x1f780
decl 0x844(%r14)
jmp 0x520ce
leaq 0x4a745(%rip), %rdi     # 0x9c872
leaq 0x49b49(%rip), %rsi     # 0x9bc7d
movl $0x109a, %edx           # imm = 0x109A
jmp 0x5214e
leaq 0x4a73c(%rip), %rdi     # 0x9c87e
leaq 0x49b34(%rip), %rsi     # 0x9bc7d
movl $0x109b, %edx           # imm = 0x109B
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterHandleConfigEpochCollision
void clusterHandleConfigEpochCollision(clusterNode *sender) {
    /* Prerequisites: nodes have the same configEpoch and are both masters. */
    if (sender->configEpoch != myself->configEpoch ||
        !nodeIsMaster(sender) || !nodeIsMaster(myself)) return;
    /* Don't act if the colliding node has a smaller Node ID. */
    if (memcmp(sender->name,myself->name,REDIS_CLUSTER_NAMELEN) <= 0) return;
    /* Get the next ID available at the best of this node knowledge. */
    server.cluster->currentEpoch++;
    myself->configEpoch = server.cluster->currentEpoch;
    clusterSaveConfigOrDie(1);
    redisLog(REDIS_VERBOSE,
        "WARNING: configEpoch collision with node %.40s."
        " Updating my configEpoch to %llu",
        sender->name,
        (unsigned long long) myself->configEpoch);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x38(%rdi), %rax
movq 0x8c4bc(%rip), %r14     # 0xde628
cmpq 0x38(%r14), %rax
jne 0x5219b
movq %rdi, %rbx
testb $0x1, 0x30(%rdi)
je 0x5219b
testb $0x1, 0x30(%r14)
je 0x5219b
addq $0x8, %rbx
leaq 0x8(%r14), %rsi
movl $0x28, %edx
movq %rbx, %rdi
callq 0x1f940
testl %eax, %eax
jg 0x521a3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x77dfe(%rip), %rax     # 0xc9fa8
movq 0x7d0(%rax), %rax
movq 0x8(%rax), %rcx
incq %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x38(%r14)
movl $0x1, %edi
callq 0x50787
movq 0x8c457(%rip), %rax     # 0xde628
movq 0x38(%rax), %rcx
leaq 0x4a08e(%rip), %rsi     # 0x9c26a
movl $0x1, %edi
movq %rbx, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x23064
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterDelNodeSlots
int clusterDelNodeSlots(clusterNode *node) {
    int deleted = 0, j;

    for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
        // 如果这个槽由该节点负责，那么删除它
        if (clusterNodeGetSlotBit(node,j)) clusterDelSlot(j);
        deleted++;
    }
    return deleted;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %ebp, %ebp
movl %ebp, %eax
shrl $0x3, %eax
movzbl 0x40(%rbx,%rax), %eax
movl %ebp, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jae 0x52dd5
movl %ebp, %edi
callq 0x50e15
incl %ebp
cmpl $0x4000, %ebp           # imm = 0x4000
jne 0x52dba
movl $0x4000, %eax           # imm = 0x4000
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSendUpdate
void clusterSendUpdate(clusterLink *link, clusterNode *node) {
    unsigned char buf[sizeof(clusterMsg)];
    clusterMsg *hdr = (clusterMsg*) buf;

    if (link == NULL) return;

    // 创建消息
    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_UPDATE);

    // 设置节点名
    memcpy(hdr->data.update.nodecfg.nodename,node->name,REDIS_CLUSTER_NAMELEN);

    // 设置配置纪元
    hdr->data.update.nodecfg.configEpoch = htonu64(node->configEpoch);

    // 更新节点的槽位图
    memcpy(hdr->data.update.nodecfg.slots,node->slots,sizeof(node->slots));

    // 发送信息
    clusterSendMessage(link,buf,ntohl(hdr->totlen));
}

// Assembly:
testq %rdi, %rdi
je 0x52e81
pushq %r15
pushq %r14
pushq %rbx
subq $0x10d0, %rsp           # imm = 0x10D0
movq %rsi, %r15
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
movl $0x7, %esi
callq 0x53105
movq 0x28(%r15), %rax
movq %rax, 0x8c8(%r14)
movups 0x8(%r15), %xmm0
movups 0x18(%r15), %xmm1
movups %xmm1, 0x8b8(%r14)
movups %xmm0, 0x8a8(%r14)
movq 0x38(%r15), %rdi
callq 0x566c1
movq %rax, 0x8a0(%r14)
leaq 0x8d0(%rsp), %rdi
addq $0x40, %r15
movl $0x800, %edx            # imm = 0x800
movq %r15, %rsi
callq 0x1fbd0
movl 0x4(%r14), %edx
bswapl %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53033
addq $0x10d0, %rsp           # imm = 0x10D0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterWriteHandler
void clusterWriteHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    clusterLink *link = (clusterLink*) privdata;
    ssize_t nwritten;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(mask);

    // 写入信息
    nwritten = write(fd, link->sndbuf, sdslen(link->sndbuf));

    // 写入错误
    if (nwritten <= 0) {
        redisLog(REDIS_DEBUG,"I/O error writing to node link: %s",
            strerror(errno));
        handleLinkIOError(link);
        return;
    }

    // 删除已写入的部分
    sdsrange(link->sndbuf,nwritten,-1);

    // 如果所有当前节点输出缓冲区里面的所有内容都已经写入完毕
    // （缓冲区为空）
    // 那么删除写事件处理器
    if (sdslen(link->sndbuf) == 0)
        aeDeleteFileEvent(server.el, link->fd, AE_WRITABLE);
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
movl %esi, %edi
movq 0x10(%rdx), %rsi
movslq -0x8(%rsi), %rdx
callq 0x1fb30
testq %rax, %rax
jle 0x52ff2
movq 0x10(%rbx), %rdi
movl %eax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x28c31
movq 0x10(%rbx), %rax
cmpl $0x0, -0x8(%rax)
je 0x5301a
popq %rbx
retq
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x494ea(%rip), %rsi     # 0x9c4ef
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
movq %rbx, %rdi
popq %rbx
jmp 0x51014
leaq 0x76f87(%rip), %rax     # 0xc9fa8
movq 0x28(%rax), %rdi
movl 0x8(%rbx), %esi
movl $0x2, %edx
popq %rbx
jmp 0x20a9d
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterBroadcastMessage
void clusterBroadcastMessage(void *buf, size_t len) {
    dictIterator *di;
    dictEntry *de;

    // 遍历所有已知节点
    di = dictGetSafeIterator(server.cluster->nodes);
    while((de = dictNext(di)) != NULL) {
        clusterNode *node = dictGetVal(de);

        // 不向未连接节点发送信息
        if (!node->link) continue;

        // 不向节点自身或者 HANDSHAKE 状态的节点发送信息
        if (node->flags & (REDIS_NODE_MYSELF|REDIS_NODE_HANDSHAKE))
            continue;

        // 发送信息
        clusterSendMessage(node->link,buf,len);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x76ef6(%rip), %rax     # 0xc9fa8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x228e4
movq %rax, %r15
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x530f8
movq 0x8(%rax), %rax
movq 0x8c0(%rax), %rdi
testq %rdi, %rdi
je 0x530f3
testb $0x30, 0x30(%rax)
jne 0x530f3
movq %r14, %rsi
movq %rbx, %rdx
callq 0x53033
movq %r15, %rdi
jmp 0x530c8
movq %r15, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x229b9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterBroadcastPong
void clusterBroadcastPong(int target) {
    dictIterator *di;
    dictEntry *de;

    // 遍历所有节点
    di = dictGetSafeIterator(server.cluster->nodes);
    while((de = dictNext(di)) != NULL) {
        clusterNode *node = dictGetVal(de);

        // 不向未建立连接的节点发送
        if (!node->link) continue;
        if (node == myself || nodeInHandshake(node)) continue;
        if (target == CLUSTER_BROADCAST_LOCAL_SLAVES) {
            int local_slave =
                nodeIsSlave(node) && node->slaveof &&
                (node->slaveof == myself || node->slaveof == myself->slaveof);
            if (!local_slave) continue;
        }
        // 发送 PONG 信息
        clusterSendPing(node->link,CLUSTERMSG_TYPE_PONG);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x76d0a(%rip), %rax     # 0xc9fa8
movq 0x7d0(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x228e4
movq %rax, %r14
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x53315
movq 0x8(%rax), %rcx
movq 0x8c0(%rcx), %rdi
testq %rdi, %rdi
je 0x53310
movq 0x8b353(%rip), %rax     # 0xde628
cmpq %rax, %rcx
je 0x53310
movl 0x30(%rcx), %edx
testb $0x20, %dl
jne 0x53310
cmpl $0x1, %ebx
jne 0x53306
testb $0x2, %dl
je 0x53310
movq 0x850(%rcx), %rcx
testq %rcx, %rcx
je 0x53310
cmpq %rax, %rcx
je 0x53306
cmpq 0x850(%rax), %rcx
jne 0x53310
movl $0x1, %esi
callq 0x52bc7
movq %r14, %rdi
jmp 0x532b4
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x229b9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSendPublish
void clusterSendPublish(clusterLink *link, robj *channel, robj *message) {
    unsigned char buf[sizeof(clusterMsg)], *payload;
    clusterMsg *hdr = (clusterMsg*) buf;
    uint32_t totlen;
    uint32_t channel_len, message_len;

    // 频道
    channel = getDecodedObject(channel);

    // 消息
    message = getDecodedObject(message);

    // 频道和消息的长度
    channel_len = sdslen(channel->ptr);
    message_len = sdslen(message->ptr);

    // 构建消息
    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_PUBLISH);
    totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
    totlen += sizeof(clusterMsgDataPublish) + channel_len + message_len;

    hdr->data.publish.msg.channel_len = htonl(channel_len);
    hdr->data.publish.msg.message_len = htonl(message_len);
    hdr->totlen = htonl(totlen);

    /* Try to use the local buffer if possible */
    if (totlen < sizeof(buf)) {
        payload = buf;
    } else {
        payload = zmalloc(totlen);
        memcpy(payload,hdr,sizeof(*hdr));
        hdr = (clusterMsg*) payload;
    }

    // 保存频道和消息到消息结构中
    memcpy(hdr->data.publish.msg.bulk_data,channel->ptr,sdslen(channel->ptr));
    memcpy(hdr->data.publish.msg.bulk_data+sdslen(channel->ptr),
        message->ptr,sdslen(message->ptr));

    // 选择发送到节点还是广播至整个集群
    if (link)
        clusterSendMessage(link,payload,totlen);
    else
        clusterBroadcastMessage(payload,totlen);

    decrRefCount(channel);
    decrRefCount(message);
    if (payload != buf) zfree(payload);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10e8, %rsp           # imm = 0x10E8
movq %rdx, %r14
movq %rdi, 0x8(%rsp)
movq %rsi, %rdi
callq 0x30ac3
movq %rax, %rbx
movq %r14, %rdi
callq 0x30ac3
movq %rax, %r14
movq 0x8(%rbx), %rax
movl -0x8(%rax), %ebp
movq 0x8(%r14), %rax
movl -0x8(%rax), %r12d
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x4, %esi
callq 0x53105
leal (%r12,%rbp), %r13d
addl $0x8b0, %r13d           # imm = 0x8B0
bswapl %ebp
movl %ebp, 0x8a0(%r15)
bswapl %r12d
movl %r12d, 0x8a4(%r15)
movl %r13d, %eax
bswapl %eax
movl %eax, 0x4(%r15)
cmpl $0x10d0, %r13d          # imm = 0x10D0
jb 0x533c1
movq %r13, %rdi
callq 0x29709
movq %rax, %r15
leaq 0x10(%rsp), %rsi
movl $0x10d0, %edx           # imm = 0x10D0
movq %rax, %rdi
callq 0x1fbd0
leaq 0x8a8(%r15), %rdi
movq 0x8(%rbx), %rsi
movslq -0x8(%rsi), %rdx
callq 0x1fbd0
movq 0x8(%rbx), %rax
movslq -0x8(%rax), %rax
leaq (%r15,%rax), %rdi
addq $0x8a8, %rdi            # imm = 0x8A8
movq 0x8(%r14), %rsi
movslq -0x8(%rsi), %rdx
callq 0x1fbd0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5340c
movq %r15, %rsi
movq %r13, %rdx
callq 0x53033
jmp 0x53417
movq %r15, %rdi
movq %r13, %rsi
callq 0x530a0
movq %rbx, %rdi
callq 0x30834
movq %r14, %rdi
callq 0x30834
leaq 0x10(%rsp), %rax
cmpq %rax, %r15
je 0x53439
movq %r15, %rdi
callq 0x2984b
addq $0x10e8, %rsp           # imm = 0x10E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSendFailoverAuth
void clusterSendFailoverAuth(clusterNode *node) {
    unsigned char buf[sizeof(clusterMsg)];
    clusterMsg *hdr = (clusterMsg*) buf;
    uint32_t totlen;

    if (!node->link) return;
    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK);
    totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
    hdr->totlen = htonl(totlen);
    clusterSendMessage(node->link,buf,totlen);
}

// Assembly:
cmpq $0x0, 0x8c0(%rdi)
je 0x534f5
pushq %r14
pushq %rbx
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
movl $0x6, %esi
callq 0x53105
movl $0xa0080000, 0x4(%r14)  # imm = 0xA0080000
movq 0x8c0(%rbx), %rdi
movl $0x8a0, %edx            # imm = 0x8A0
movq %r14, %rsi
callq 0x53033
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterSendMFStart
void clusterSendMFStart(clusterNode *node) {
    unsigned char buf[sizeof(clusterMsg)];
    clusterMsg *hdr = (clusterMsg*) buf;
    uint32_t totlen;

    if (!node->link) return;
    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_MFSTART);
    totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
    hdr->totlen = htonl(totlen);
    clusterSendMessage(node->link,buf,totlen);
}

// Assembly:
cmpq $0x0, 0x8c0(%rdi)
je 0x53543
pushq %r14
pushq %rbx
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
movl $0x8, %esi
callq 0x53105
movl $0xa0080000, 0x4(%r14)  # imm = 0xA0080000
movq 0x8c0(%rbx), %rdi
movl $0x8a0, %edx            # imm = 0x8A0
movq %r14, %rsi
callq 0x53033
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterGetSlaveRank
int clusterGetSlaveRank(void) {
    long long myoffset;
    int j, rank = 0;
    clusterNode *master;

    redisAssert(nodeIsSlave(myself));
    master = myself->slaveof;
    if (master == NULL) return 0; /* Never called by slaves without master. */

    myoffset = replicationGetSlaveOffset();
    for (j = 0; j < master->numslaves; j++)
        if (master->slaves[j] != myself &&
            master->slaves[j]->repl_offset > myoffset) rank++;
    return rank;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x8b0d9(%rip), %rax     # 0xde628
testb $0x2, 0x30(%rax)
je 0x535b2
movq 0x850(%rax), %r14
xorl %ebx, %ebx
testq %r14, %r14
je 0x535a8
callq 0x359bd
movslq 0x844(%r14), %rcx
testq %rcx, %rcx
jle 0x535a8
movq 0x848(%r14), %rdx
xorl %esi, %esi
movq 0x8b0a4(%rip), %rdi     # 0xde628
xorl %ebx, %ebx
movq (%rdx,%rsi,8), %r8
cmpq %rdi, %r8
je 0x535a0
xorl %r9d, %r9d
cmpq %rax, 0x880(%r8)
setg %r9b
addl %r9d, %ebx
incq %rsi
cmpq %rsi, %rcx
jne 0x53586
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x48fd0(%rip), %rdi     # 0x9c589
leaq 0x486bd(%rip), %rsi     # 0x9bc7d
movl $0xc72, %edx            # imm = 0xC72
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterHandleManualFailover
void clusterHandleManualFailover(void) {
    /* Return ASAP if no manual failover is in progress. */
    if (server.cluster->mf_end == 0) return;

    /* If mf_can_start is non-zero, the failover was alrady triggered so the
     * next steps are performed by clusterHandleSlaveFailover(). */
    if (server.cluster->mf_can_start) return;

    if (server.cluster->mf_master_offset == 0) return; /* Wait for offset... */

    if (server.cluster->mf_master_offset == replicationGetSlaveOffset()) {
        /* Our replication offset matches the master replication offset
         * announced after clients were paused. We can start the failover. */
        server.cluster->mf_can_start = 1;
        redisLog(REDIS_WARNING,
            "All master replication stream processed, "
            "manual failover can start.");
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x76283(%rip), %rbx     # 0xc9fa8
movq 0x7d0(%rbx), %rax
cmpq $0x0, 0x60050(%rax)
je 0x53d3f
cmpl $0x0, 0x60068(%rax)
je 0x53d47
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x60060(%rax), %r14
testq %r14, %r14
je 0x53d3f
callq 0x359bd
cmpq %rax, %r14
jne 0x53d3f
movq 0x7d0(%rbx), %rax
movl $0x1, 0x60068(%rax)
leaq 0x48944(%rip), %rsi     # 0x9c6b9
movl $0x3, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x23064
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: clusterNodeClearSlotBit
int clusterNodeClearSlotBit(clusterNode *n, int slot) {
    int old = bitmapTestBit(n->slots,slot);
    bitmapClearBit(n->slots,slot);
    if (old) n->numslots--;
    return old;
}

// Assembly:
movl %esi, %ecx
leal 0x7(%rcx), %eax
testl %esi, %esi
cmovnsl %esi, %eax
sarl $0x3, %eax
movslq %eax, %rdx
movzbl 0x40(%rdi,%rdx), %esi
andb $0x7, %cl
movl %esi, %eax
shrl %cl, %eax
movl $0x1, %r8d
shll %cl, %r8d
notb %r8b
andb %sil, %r8b
movb %r8b, 0x40(%rdi,%rdx)
andl $0x1, %eax
je 0x543f6
decl 0x840(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: createDumpPayload
void createDumpPayload(rio *payload, robj *o) {
    unsigned char buf[2];
    uint64_t crc;

    /* Serialize the object in a RDB-like format. It consist of an object type
     * byte followed by the serialized object. This is understood by RESTORE. */
    // 将对象序列化为一个 RDB 格式对象
    // 序列化对象以对象类型为首，后跟序列化后的对象
    // 如图
    //
    // |<-- RDB payload  -->|
    //      序列化数据
    // +-------------+------+
    // | 1 byte type | obj  |
    // +-------------+------+
    rioInitWithBuffer(payload,sdsempty());
    redisAssert(rdbSaveObjectType(payload,o));
    redisAssert(rdbSaveObject(payload,o));

    /* Write the footer, this is how it looks like:
     * ----------------+---------------------+---------------+
     * ... RDB payload | 2 bytes RDB version | 8 bytes CRC64 |
     * ----------------+---------------------+---------------+
     * RDB version and CRC are both in little endian.
     */

    /* RDB version */
    // 写入 RDB 版本
    buf[0] = REDIS_RDB_VERSION & 0xff;
    buf[1] = (REDIS_RDB_VERSION >> 8) & 0xff;
    payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,buf,2);

    /* CRC64 */
    // 写入 CRC 校验和
    crc = crc64(0,(unsigned char*)payload->io.buffer.ptr,
                sdslen(payload->io.buffer.ptr));
    memrev64ifbe(&crc);
    payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,&crc,8);

    // 整个数据的结构:
    //
    // | <--- 序列化数据 -->|
    // +-------------+------+---------------------+---------------+
    // | 1 byte type | obj  | 2 bytes RDB version | 8 bytes CRC64 |
    // +-------------+------+---------------------+---------------+

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x281b2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x58e45
movq %rbx, %rdi
movq %r14, %rsi
callq 0x36ca2
testl %eax, %eax
je 0x55619
movq %rbx, %rdi
movq %r14, %rsi
callq 0x36e19
testl %eax, %eax
je 0x5562e
leaq 0xe(%rsp), %rsi
movw $0x6, (%rsi)
movq 0x38(%rbx), %rdi
movl $0x2, %edx
callq 0x28380
movq %rax, 0x38(%rbx)
movslq -0x8(%rax), %rdx
xorl %edi, %edi
movq %rax, %rsi
callq 0x59a00
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq 0x38(%rbx), %rdi
movl $0x8, %edx
callq 0x28380
movq %rax, 0x38(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x479b3(%rip), %rdi     # 0x9cfd3
leaq 0x46656(%rip), %rsi     # 0x9bc7d
movl $0x13ab, %edx           # imm = 0x13AB
jmp 0x55641
leaq 0x479bb(%rip), %rdi     # 0x9cff0
leaq 0x46641(%rip), %rsi     # 0x9bc7d
movl $0x13ac, %edx           # imm = 0x13AC
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: verifyDumpPayload
int verifyDumpPayload(unsigned char *p, size_t len) {
    unsigned char *footer;
    uint16_t rdbver;
    uint64_t crc;

    /* At least 2 bytes of RDB version and 8 of CRC64 should be present. */
    // 因为序列化数据至少包含 2 个字节的 RDB 版本
    // 以及 8 个字节的 CRC64 校验和
    // 所以序列化数据不可能少于 10 个字节
    if (len < 10) return REDIS_ERR;

    // 指向数据的最后 10 个字节
    footer = p+(len-10);

    /* Verify RDB version */
    // 检查序列化数据的版本号，看是否和当前实例使用的版本号一致
    rdbver = (footer[1] << 8) | footer[0];
    if (rdbver != REDIS_RDB_VERSION) return REDIS_ERR;

    /* Verify CRC64 */
    // 检查数据的 CRC64 校验和是否正确
    crc = crc64(0,p,len-8);
    memrev64ifbe(&crc);
    return (memcmp(&crc,footer+2,8) == 0) ? REDIS_OK : REDIS_ERR;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0xa, %rsi
jb 0x55695
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpw $0x6, -0xa(%rdi,%rsi)
jne 0x5568e
leaq -0x8(%rbx), %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x59a00
movq %rax, %rcx
movq %rax, (%rsp)
xorl %eax, %eax
cmpq -0x8(%r14,%rbx), %rcx
setne %al
negl %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: dumpCommand
void dumpCommand(redisClient *c) {
    robj *o, *dumpobj;
    rio payload;

    /* Check if the key is here. */
    // 取出给定键的值
    if ((o = lookupKeyRead(c->db,c->argv[1])) == NULL) {
        addReply(c,shared.nullbulk);
        return;
    }

    /* Create the DUMP encoded representation. */
    // 创建给定值的一个 DUMP 编码表示
    createDumpPayload(&payload,o);

    /* Transfer to the client */
    // 将编码后的键值对数据返回给客户端
    dumpobj = createObject(REDIS_STRING,payload.io.buffer.ptr);
    addReplyBulk(c,dumpobj);
    decrRefCount(dumpobj);

    return;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3136a
testq %rax, %rax
je 0x556ef
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x55592
movq 0x38(%r14), %rsi
xorl %edi, %edi
callq 0x302c4
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2df74
movq %r14, %rdi
callq 0x30834
addq $0x58, %rsp
popq %rbx
popq %r14
retq
leaq 0x7510a(%rip), %rax     # 0xca800
movq 0x50(%rax), %rsi
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r14
jmp 0x2d6f0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: migrateCloseSocket
void migrateCloseSocket(robj *host, robj *port) {
    sds name = sdsempty();
    migrateCachedSocket *cs;

    // 根据 ip 和 port 创建连接的名字
    name = sdscatlen(name,host->ptr,sdslen(host->ptr));
    name = sdscatlen(name,":",1);
    name = sdscatlen(name,port->ptr,sdslen(port->ptr));
    // 查找连接
    cs = dictFetchValue(server.migrate_cached_sockets,name);
    if (!cs) {
        sdsfree(name);
        return;
    }

    // 关闭连接
    close(cs->fd);
    zfree(cs);

    // 从缓存中删除该连接
    dictDelete(server.migrate_cached_sockets,name);
    sdsfree(name);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x281b2
movq 0x8(%r14), %rsi
movslq -0x8(%rsi), %rdx
movq %rax, %rdi
callq 0x28380
leaq 0x45f73(%rip), %rsi     # 0x9ba37
movl $0x1, %edx
movq %rax, %rdi
callq 0x28380
movq 0x8(%rbx), %rsi
movslq -0x8(%rsi), %rdx
movq %rax, %rdi
callq 0x28380
movq %rax, %rbx
leaq 0x744bd(%rip), %r15     # 0xc9fa8
movq 0x2e8(%r15), %rdi
movq %rax, %rsi
callq 0x22813
testq %rax, %rax
je 0x55b20
movq %rax, %r14
movl (%rax), %edi
callq 0x1f170
movq %r14, %rdi
callq 0x2984b
movq 0x2e8(%r15), %rdi
movq %rbx, %rsi
callq 0x225d3
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x28204
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: migrateCloseTimedoutSockets
void migrateCloseTimedoutSockets(void) {
    dictIterator *di = dictGetSafeIterator(server.migrate_cached_sockets);
    dictEntry *de;

    while((de = dictNext(di)) != NULL) {
        migrateCachedSocket *cs = dictGetVal(de);

        // 如果套接字最后一次使用的时间已经超过 MIGRATE_SOCKET_CACHE_TTL 
        // 那么表示该套接字过期，释放它！
        if ((server.unixtime - cs->last_use_time) > MIGRATE_SOCKET_CACHE_TTL) {
            close(cs->fd);
            zfree(cs);
            dictDelete(server.migrate_cached_sockets,dictGetKey(de));
        }
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x7446c(%rip), %r12     # 0xc9fa8
movq 0x2e8(%r12), %rdi
callq 0x228e4
movq %rax, %rbx
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x55ba2
movq %rax, %r14
movq 0x8(%r14), %r15
movq 0x798(%r12), %rax
subq 0x8(%r15), %rax
cmpq $0xb, %rax
jl 0x55b92
movl (%r15), %edi
callq 0x1f170
movq %r15, %rdi
callq 0x2984b
movq 0x2e8(%r12), %rdi
movq (%r14), %rsi
callq 0x225d3
movq %rbx, %rdi
callq 0x22913
movq %rax, %r14
testq %rax, %rax
jne 0x55b5c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x229b9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/cluster.c
// Function: readonlyCommand
void readonlyCommand(redisClient *c) {
    if (server.cluster_enabled == 0) {
        addReplyError(c,"This instance has cluster support disabled");
        return;
    }
    c->flags |= REDIS_READONLY;
    addReply(c,shared.ok);
}

// Assembly:
leaq 0x73d0c(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x7bc(%rax)
je 0x562bc
orb $0x2, 0x92(%rdi)
leaq 0x7454d(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
jmp 0x2d6f0
leaq 0x46647(%rip), %rsi     # 0x9c90a
jmp 0x2d9d7
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/crc16.c
// Function: crc16
uint16_t crc16(const char *buf, int len) {
    int counter;
    uint16_t crc = 0;
    for (counter = 0; counter < len; counter++)
            crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *buf++)&0x00FF];
    return crc;
}

// Assembly:
testl %esi, %esi
jle 0x56674
movl %esi, %ecx
xorl %edx, %edx
leaq 0x46cf5(%rip), %rsi     # 0x9d340
xorl %r8d, %r8d
movl %r8d, %eax
shll $0x8, %eax
movzwl %r8w, %r8d
shrl $0x8, %r8d
movzbl (%rdi,%rdx), %r9d
xorl %r8d, %r9d
xorw (%rsi,%r9,2), %ax
incq %rdx
movl %eax, %r8d
cmpl %edx, %ecx
jne 0x5664e
retq
xorl %eax, %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/slowlog.c
// Function: slowlogFreeEntry
void slowlogFreeEntry(void *septr) {
    slowlogEntry *se = septr;
    int j;

    // 释放参数
    for (j = 0; j < se->argc; j++)
        decrRefCount(se->argv[j]);

    zfree(se->argv);

    zfree(se);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
jle 0x5683d
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x30834
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x56825
movq (%rbx), %rdi
callq 0x2984b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2984b
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/slowlog.c
// Function: slowlogPushEntryIfNeeded
void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) {

    // 慢查询功能未开启，直接返回
    if (server.slowlog_log_slower_than < 0) return; /* Slowlog disabled */

    // 如果执行时间超过服务器设置的上限，那么将命令添加到慢查询日志
    if (duration >= server.slowlog_log_slower_than)
        // 新日志添加到链表表头
        listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration));

    /* Remove old entries if needed. */
    // 如果日志数量过多，那么进行删除
    while (listLength(server.slowlog) > server.slowlog_max_len)
        listDelNode(server.slowlog,listLast(server.slowlog));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x7371d(%rip), %r14     # 0xc9fa8
movq 0x3b8(%r14), %rax
testq %rax, %rax
js 0x568d2
cmpq %rdx, %rax
jg 0x568be
movq 0x3a8(%r14), %rbx
callq 0x566c8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x20400
jmp 0x568be
movq 0x8(%rdi), %rsi
callq 0x20544
movq 0x3a8(%r14), %rdi
movq 0x28(%rdi), %rax
cmpq 0x3c0(%r14), %rax
ja 0x568b5
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: redisProtocolToLuaType_Int
char *redisProtocolToLuaType_Int(lua_State *lua, char *reply) {
    char *p = strchr(reply+1,'\r');
    long long value;

    string2ll(reply+1,p-reply-1,&value);
    lua_pushnumber(lua,(lua_Number)value);
    return p+2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1(%rsi), %r15
movq %r15, %rdi
movl $0xd, %esi
callq 0x1f790
movq %rax, %r12
notq %rbx
addq %rax, %rbx
leaq 0x8(%rsp), %r13
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2fec4
cvtsi2sdq (%r13), %xmm0
movq %r14, %rdi
callq 0x666d1
addq $0x2, %r12
movq %r12, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: redisProtocolToLuaType_Bulk
char *redisProtocolToLuaType_Bulk(lua_State *lua, char *reply) {
    char *p = strchr(reply+1,'\r');
    long long bulklen;

    string2ll(reply+1,p-reply-1,&bulklen);
    if (bulklen == -1) {
        lua_pushboolean(lua,0);
        return p+2;
    } else {
        lua_pushlstring(lua,p+2,bulklen);
        return p+2+bulklen+2;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x1(%rsi), %r12
movq %r12, %rdi
movl $0xd, %esi
callq 0x1f790
movq %rax, %rbx
notq %r15
addq %rax, %r15
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2fec4
movq (%r13), %rdx
cmpq $-0x1, %rdx
je 0x56be4
addq $0x2, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x66700
addq 0x8(%rsp), %rbx
jmp 0x56bee
movq %r14, %rdi
xorl %esi, %esi
callq 0x6691c
addq $0x2, %rbx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: redisProtocolToLuaType_Status
char *redisProtocolToLuaType_Status(lua_State *lua, char *reply) {
    char *p = strchr(reply+1,'\r');

    lua_newtable(lua);
    lua_pushstring(lua,"ok");
    lua_pushlstring(lua,reply+1,p-reply-1);
    lua_settable(lua,-3);
    return p+2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x1(%rsi), %r12
movq %r12, %rdi
movl $0xd, %esi
callq 0x1f790
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x66a47
leaq 0x4afa3(%rip), %rsi     # 0xa1bdb
movq %rbx, %rdi
callq 0x66757
notq %r15
addq %r14, %r15
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x66700
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x66b43
addq $0x2, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: redisProtocolToLuaType_MultiBulk
char *redisProtocolToLuaType_MultiBulk(lua_State *lua, char *reply) {
    char *p = strchr(reply+1,'\r');
    long long mbulklen;
    int j = 0;

    string2ll(reply+1,p-reply-1,&mbulklen);
    p += 2;
    if (mbulklen == -1) {
        lua_pushboolean(lua,0);
        return p;
    }
    lua_newtable(lua);
    for (j = 0; j < mbulklen; j++) {
        lua_pushnumber(lua,j+1);
        p = redisProtocolToLuaType(lua,p);
        lua_settable(lua,-3);
    }
    return p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x1(%rsi), %r12
movq %r12, %rdi
movl $0xd, %esi
callq 0x1f790
movq %rax, %rbx
notq %r15
addq %rax, %r15
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2fec4
addq $0x2, %rbx
cmpq $-0x1, (%r13)
je 0x56d7e
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x66a47
cmpq $0x0, 0x8(%rsp)
jle 0x56d88
xorl %r15d, %r15d
incq %r15
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movq %r14, %rdi
callq 0x666d1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x56ae4
movq %rax, %rbx
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x66b43
cmpq %r15, 0x8(%rsp)
jg 0x56d47
jmp 0x56d88
movq %r14, %rdi
xorl %esi, %esi
callq 0x6691c
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaPushError
void luaPushError(lua_State *lua, char *error) {
    lua_Debug dbg;

    lua_newtable(lua);
    lua_pushstring(lua,"err");

    /* Attempt to figure out where this function was called, if possible */
    if(lua_getstack(lua, 1, &dbg) && lua_getinfo(lua, "nSl", &dbg)) {
        sds msg = sdscatprintf(sdsempty(), "%s: %d: %s",
            dbg.source, dbg.currentline, error);
        lua_pushstring(lua, msg);
        sdsfree(msg);
    } else {
        lua_pushstring(lua, error);
    }
    lua_settable(lua,-3);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
xorl %edx, %edx
callq 0x66a47
leaq 0x3eb67(%rip), %rsi     # 0x9591d
movq %rbx, %rdi
callq 0x66757
movq %rsp, %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x672e5
testl %eax, %eax
je 0x56e22
leaq 0x4682f(%rip), %rsi     # 0x9d608
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x67465
testl %eax, %eax
je 0x56e22
callq 0x281b2
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
leaq 0x4680f(%rip), %rsi     # 0x9d60c
movq %rax, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x28760
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x66757
movq %r14, %rdi
callq 0x28204
jmp 0x56e2d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x66757
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x66b43
addq $0x78, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaSortArray
void luaSortArray(lua_State *lua) {
    /* Initial Stack: array */
    lua_getglobal(lua,"table");
    lua_pushstring(lua,"sort");
    lua_gettable(lua,-2);       /* Stack: array, table, table.sort */
    lua_pushvalue(lua,-3);      /* Stack: array, table, table.sort, array */
    if (lua_pcall(lua,1,0,0)) {
        /* Stack: array, table, error */

        /* We are not interested in the error, we assume that the problem is
         * that there are 'false' elements inside the array, so we try
         * again with a slower function but able to handle this case, that
         * is: table.sort(table, __redis__compare_helper) */
        lua_pop(lua,1);             /* Stack: array, table */
        lua_pushstring(lua,"sort"); /* Stack: array, table, sort */
        lua_gettable(lua,-2);       /* Stack: array, table, table.sort */
        lua_pushvalue(lua,-3);      /* Stack: array, table, table.sort, array */
        lua_getglobal(lua,"__redis__compare_helper");
        /* Stack: array, table, table.sort, array, __redis__compare_helper */
        lua_call(lua,2,0);
    }
    /* Stack: array (sorted), table */
    lua_pop(lua,1);             /* Stack: array (sorted) */
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x4ac08(%rip), %rdx     # 0xa1a55
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x6698e
leaq 0x3d71b(%rip), %rsi     # 0x94579
movq %rbx, %rdi
callq 0x66757
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6696e
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x662d0
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x66dd8
testl %eax, %eax
je 0x56eee
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x660a2
leaq 0x3d6d0(%rip), %rsi     # 0x94579
movq %rbx, %rdi
callq 0x66757
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6696e
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x662d0
leaq 0x46745(%rip), %rdx     # 0x9d617
movq %rbx, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x6698e
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x66da0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
popq %rbx
jmp 0x660a2
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaRedisSha1hexCommand
int luaRedisSha1hexCommand(lua_State *lua) {
    int argc = lua_gettop(lua);
    char digest[41];
    size_t len;
    char *s;

    if (argc != 1) {
        luaPushError(lua, "wrong number of arguments");
        return 1;
    }

    s = (char*)lua_tolstring(lua,1,&len);
    sha1hex(digest,s,len);
    lua_pushstring(lua,digest);
    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x66095
cmpl $0x1, %eax
jne 0x57488
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x6652e
movq (%r14), %rdx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x574a4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x66757
jmp 0x57497
leaq 0x42bfe(%rip), %rsi     # 0x9a08d
movq %rbx, %rdi
callq 0x56d99
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: sha1hex
void sha1hex(char *digest, char *script, size_t len) {
    SHA1_CTX ctx;
    unsigned char hash[20];
    char *cset = "0123456789abcdef";
    int j;

    SHA1Init(&ctx);
    SHA1Update(&ctx,(unsigned char*)script,len);
    SHA1Final(hash,&ctx);

    for (j = 0; j < 20; j++) {
        digest[j*2] = cset[((hash[j]&0xF0)>>4)];
        digest[j*2+1] = cset[(hash[j]&0xF)];
    }
    digest[40] = '\0';
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x1c(%rsp), %r12
movq %r12, %rdi
callq 0x2ba1d
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x2ba38
movq %rsp, %rdi
movq %r12, %rsi
callq 0x2bafb
xorl %eax, %eax
leaq 0x3fde5(%rip), %rcx     # 0x972cc
movzbl (%rsp,%rax), %edx
movl %edx, %esi
shrl $0x4, %esi
movb (%rsi,%rcx), %sil
movb %sil, (%rbx,%rax,2)
andl $0xf, %edx
movb (%rdx,%rcx), %dl
movb %dl, 0x1(%rbx,%rax,2)
incq %rax
cmpq $0x14, %rax
jne 0x574e7
movb $0x0, 0x28(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaRedisReturnSingleFieldTable
int luaRedisReturnSingleFieldTable(lua_State *lua, char *field) {
    if (lua_gettop(lua) != 1 || lua_type(lua,-1) != LUA_TSTRING) {
        luaPushError(lua, "wrong number or type of arguments");
        return 1;
    }

    lua_newtable(lua);
    lua_pushstring(lua, field);
    lua_pushvalue(lua, -3);
    lua_settable(lua, -3);
    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x66095
cmpl $0x1, %eax
jne 0x57574
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x662f0
cmpl $0x4, %eax
jne 0x57574
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x66a47
movq %rbx, %rdi
movq %r14, %rsi
callq 0x66757
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x662d0
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x66b43
jmp 0x57583
leaq 0x461f7(%rip), %rsi     # 0x9d772
movq %rbx, %rdi
callq 0x56d99
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaLogCommand
int luaLogCommand(lua_State *lua) {
    int j, argc = lua_gettop(lua);
    int level;
    sds log;

    if (argc < 2) {
        luaPushError(lua, "redis.log() requires two arguments or more.");
        return 1;
    } else if (!lua_isnumber(lua,-argc)) {
        luaPushError(lua, "First argument must be a number (log level).");
        return 1;
    }
    level = lua_tonumber(lua,-argc);
    if (level < REDIS_DEBUG || level > REDIS_WARNING) {
        luaPushError(lua, "Invalid debug level.");
        return 1;
    }

    /* Glue together all the arguments */
    log = sdsempty();
    for (j = 1; j < argc; j++) {
        size_t len;
        char *s;

        s = (char*)lua_tolstring(lua,(-argc)+j,&len);
        if (s) {
            if (j != 1) log = sdscatlen(log," ",1);
            log = sdscatlen(log,s,len);
        }
    }
    redisLogRaw(level,log);
    sdsfree(log);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x66095
cmpl $0x1, %eax
jg 0x575dc
leaq 0x461ba(%rip), %rsi     # 0x9d794
jmp 0x57614
movl %eax, %r15d
movl %eax, %ebp
negl %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x66349
testl %eax, %eax
je 0x5760d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x664aa
cvttsd2si %xmm0, %eax
cmpl $0x4, %eax
jb 0x57630
leaq 0x461e2(%rip), %rsi     # 0x9d7ed
jmp 0x57614
leaq 0x461ac(%rip), %rsi     # 0x9d7c0
movq %rbx, %rdi
callq 0x56d99
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0xc(%rsp)
callq 0x281b2
movq %rax, %r14
movl $0x1, %ebp
subl %r15d, %ebp
xorl %r12d, %r12d
leaq 0x10(%rsp), %r15
leal (%r12,%rbp), %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x6652e
testq %rax, %rax
je 0x57692
movq %rax, %r13
testl %r12d, %r12d
je 0x5767f
movl $0x1, %edx
movq %r14, %rdi
leaq 0x42d50(%rip), %rsi     # 0x9a3c7
callq 0x28380
movq %rax, %r14
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x28380
movq %rax, %r14
incl %r12d
movl %ebp, %eax
addl %r12d, %eax
jne 0x5764c
movl 0xc(%rsp), %edi
movq %r14, %rsi
callq 0x22f15
movq %r14, %rdi
callq 0x28204
xorl %eax, %eax
jmp 0x57621
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaMaskCountHook
void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
    long long elapsed;
    REDIS_NOTUSED(ar);
    REDIS_NOTUSED(lua);

    // 计算已执行时间
    elapsed = mstime() - server.lua_time_start;
    // 执行已超时
    if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {

        // 打印 LOG
        redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);

        // 设置状态
        server.lua_timedout = 1;

        /* Once the script timeouts we reenter the event loop to permit others
         * to call SCRIPT KILL or SHUTDOWN NOSAVE if needed. For this reason
         * we need to mask the client executing the script from the event loop.
         * If we don't do that the client may disconnect and could no longer be
         * here when the EVAL command will return. */
         // 当脚本运行超时时，将正在执行的客户端从读事件中移除
         // 并允许其他客户端执行 SCRIPT KILL 或者 SHUTDOWN NOSAVE
         aeDeleteFileEvent(server.el, server.lua_caller->fd, AE_READABLE);
    }

    // 在脚本上下文中，启动文件事件处理（等待 SCRIPT KILL 或 SHUTDOWN NOSAVE）
    if (server.lua_timedout) processEventsWhileBlocked();
    // 如果接到 SCRIPT KILL ，那么杀死脚本
    if (server.lua_kill) {
        redisLog(REDIS_WARNING,"Lua script killed by user with SCRIPT KILL.");
        lua_pushstring(lua,"Script killed by user with SCRIPT KILL...");
        lua_error(lua);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x232a3
leaq 0x728de(%rip), %r14     # 0xc9fa8
subq 0x808(%r14), %rax
cmpq 0x800(%r14), %rax
jl 0x5771c
cmpl $0x0, 0x818(%r14)
jne 0x5771c
leaq 0x46117(%rip), %rsi     # 0x9d802
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
movl $0x1, 0x818(%r14)
movq 0x28(%r14), %rdi
movq 0x7f0(%r14), %rax
movl (%rax), %esi
movl $0x1, %edx
callq 0x20a9d
cmpl $0x0, 0x818(%r14)
je 0x5772b
callq 0x2f949
cmpl $0x0, 0x81c(%r14)
je 0x57766
leaq 0x4614a(%rip), %rsi     # 0x9d886
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
leaq 0x46163(%rip), %rsi     # 0x9d8b2
movq %rbx, %rdi
callq 0x66757
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6704e
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaLoadLibraries
void luaLoadLibraries(lua_State *lua) {

    // 基础库
    luaLoadLib(lua, "", luaopen_base);

    // table 库
    luaLoadLib(lua, LUA_TABLIBNAME, luaopen_table);

    // 字符串库
    luaLoadLib(lua, LUA_STRLIBNAME, luaopen_string);

    // 数学库
    luaLoadLib(lua, LUA_MATHLIBNAME, luaopen_math);

    // debug 库
    luaLoadLib(lua, LUA_DBLIBNAME, luaopen_debug); 

    // cjson 库
    luaLoadLib(lua, "cjson", luaopen_cjson);

    // struct 库
    luaLoadLib(lua, "struct", luaopen_struct);

    // cmsgpack 库
    luaLoadLib(lua, "cmsgpack", luaopen_cmsgpack);

#if 0 /* Stuff that we don't load currently, for sandboxing concerns. */
    luaLoadLib(lua, LUA_LOADLIBNAME, luaopen_package);
    luaLoadLib(lua, LUA_OSLIBNAME, luaopen_os);
#endif
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x3fb33(%rip), %rsi     # 0x972e1
leaq 0x1a5d3(%rip), %rdx     # 0x71d88
callq 0x5776e
leaq 0x4a294(%rip), %rsi     # 0xa1a55
leaq 0x1cce8(%rip), %rdx     # 0x744b0
movq %rbx, %rdi
callq 0x5776e
leaq 0x4a1d1(%rip), %rsi     # 0xa19a8
leaq 0x1d6ca(%rip), %rdx     # 0x74ea8
movq %rbx, %rdi
callq 0x5776e
leaq 0x460ef(%rip), %rsi     # 0x9d8dc
leaq 0x1c5b8(%rip), %rdx     # 0x73dac
movq %rbx, %rdi
callq 0x5776e
leaq 0x4bf95(%rip), %rsi     # 0xa3798
leaq 0x1b90a(%rip), %rdx     # 0x73114
movq %rbx, %rdi
callq 0x5776e
leaq 0x460c8(%rip), %rsi     # 0x9d8e1
leaq 0x1f29c(%rip), %rdx     # 0x76abc
movq %rbx, %rdi
callq 0x5776e
leaq 0x460b8(%rip), %rsi     # 0x9d8e7
leaq 0x2097a(%rip), %rdx     # 0x781b0
movq %rbx, %rdi
callq 0x5776e
leaq 0x460a9(%rip), %rsi     # 0x9d8ee
leaq 0x21961(%rip), %rdx     # 0x791ad
movq %rbx, %rdi
popq %rbx
jmp 0x5776e