LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelGenerateInitialMonitorEvents
void sentinelGenerateInitialMonitorEvents(void) {
    dictIterator *di;
    dictEntry *de;

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);
        sentinelEvent(REDIS_WARNING,"+monitor",ri,"%@ quorum %d",ri->quorum);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq 0xae921(%rip), %rdi     # 0x128240
callq 0x241d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x24270
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x79972
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rax
movl 0xd0(%rax), %r8d
movl $0x3, %edi
leaq 0x6f534(%rip), %rsi     # 0xe8e96
leaq 0x6f536(%rip), %rcx     # 0xe8e9f
movb $0x0, %al
callq 0x79b10
jmp 0x79928
movq -0x8(%rbp), %rdi
callq 0x243d0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: createSentinelAddr
sentinelAddr *createSentinelAddr(char *hostname, int port) {
    char buf[32];
    sentinelAddr *sa;

    // 检查端口号
    if (port <= 0 || port > 65535) {
        errno = EINVAL;
        return NULL;
    }

    // 检查并创建地址
    if (anetResolve(NULL,hostname,buf,sizeof(buf)) == ANET_ERR) {
        errno = ENOENT;
        return NULL;
    }

    // 创建并返回地址结构
    sa = zmalloc(sizeof(*sa));
    sa->ip = sdsnew(buf);
    sa->port = port;
    return sa;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x799ae
cmpl $0xffff, -0x14(%rbp)    # imm = 0xFFFF
jle 0x799c3
callq 0x1f820
movl $0x16, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x79a26
movq -0x10(%rbp), %rsi
leaq -0x40(%rbp), %rdx
xorl %eax, %eax
movl %eax, %edi
movl $0x20, %ecx
callq 0x21ea0
cmpl $-0x1, %eax
jne 0x799f3
callq 0x1f820
movl $0x2, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x79a26
movl $0x10, %edi
callq 0x2e130
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2c0e0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movl -0x14(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelKillTimedoutScripts
void sentinelKillTimedoutScripts(void) {
    listNode *ln;
    listIter li;
    mstime_t now = mstime();

    // 遍历队列中的所有脚本
    listRewind(sentinel.scripts_queue,&li);
    while ((ln = listNext(&li)) != NULL) {
        sentinelScriptJob *sj = ln->value;

        // 选出那些正在执行，并且执行时间超过限制的脚本
        if (sj->flags & SENTINEL_SCRIPT_RUNNING &&
            (now - sj->start_time) > SENTINEL_SCRIPT_MAX_RUNTIME)
        {
            // 发送脚本超时事件
            sentinelEvent(REDIS_WARNING,"-script-timeout",NULL,"%s %ld",
                sj->argv[0], (long)sj->pid);

            // 杀死脚本进程
            kill(sj->pid,SIGKILL);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
callq 0x252e0
movq %rax, -0x20(%rbp)
movq 0xadbf8(%rip), %rdi     # 0x128260
leaq -0x18(%rbp), %rsi
callq 0x202b0
leaq -0x18(%rbp), %rdi
callq 0x20310
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x7a6f9
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7a6f4
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
subq 0x10(%rcx), %rax
cmpq $0xea60, %rax           # imm = 0xEA60
jle 0x7a6f4
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %r8
movq -0x28(%rbp), %rax
movslq 0x18(%rax), %r9
movl $0x3, %edi
leaq 0x6e89a(%rip), %rsi     # 0xe8f6b
xorl %eax, %eax
movl %eax, %edx
leaq 0x69e61(%rip), %rcx     # 0xe453d
movb $0x0, %al
callq 0x79b10
movq -0x28(%rbp), %rax
movl 0x18(%rax), %edi
movl $0x9, %esi
callq 0x1f620
jmp 0x7a671
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelKillLink
void sentinelKillLink(sentinelRedisInstance *ri, redisAsyncContext *c) {
    if (ri->cc == c) {
        ri->cc = NULL;
        ri->pending_commands = 0;
    }
    if (ri->pc == c) ri->pc = NULL;
    c->data = NULL;

    // 打开断线标志
    ri->flags |= SRI_DISCONNECTED;

    // 断开连接
    redisAsyncFree(c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x7af15
movq -0x8(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x7af2f
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
orl $0x8, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x858c0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelRedisInstanceLookupSlave
sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
                sentinelRedisInstance *ri, char *ip, int port)
{
    sds key;
    sentinelRedisInstance *slave;
  
    redisAssert(ri->flags & SRI_MASTER);
    key = sdscatprintf(sdsempty(),
        strchr(ip,':') ? "[%s]:%d" : "%s:%d",
        ip,port);
    slave = dictFetchValue(ri->slaves,key);
    sdsfree(key);
    return slave;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7af83
jmp 0x7afa5
leaq 0x6e077(%rip), %rdi     # 0xe9001
leaq 0x6de57(%rip), %rsi     # 0xe8de8
movl $0x5b1, %edx            # imm = 0x5B1
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
callq 0x2c0c0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3a, %esi
callq 0x1f790
movq -0x30(%rbp), %rdi
movq %rax, %rcx
leaq 0x67aa3(%rip), %rsi     # 0xe2a6d
leaq 0x66187(%rip), %rax     # 0xe1158
cmpq $0x0, %rcx
cmovneq %rax, %rsi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
movb $0x0, %al
callq 0x2cad0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x24050
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2c160
movq -0x28(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: removeMatchingSentinelsFromMaster
int removeMatchingSentinelsFromMaster(sentinelRedisInstance *master, char *ip, int port, char *runid) {
    dictIterator *di;
    dictEntry *de;
    int removed = 0;

    di = dictGetSafeIterator(master->sentinels);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);

        // 运行 ID 相同，或者 IP 和端口号相同，那么移除该实例
        if ((ri->runid && runid && strcmp(ri->runid,runid) == 0) ||
            (ip && strcmp(ri->addr->ip,ip) == 0 && port == ri->addr->port))
        {
            dictDelete(master->sentinels,ri->name);
            removed++;
        }
    }
    dictReleaseIterator(di);

    return removed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x24240
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x24270
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x7b0f3
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7b09d
cmpq $0x0, -0x20(%rbp)
je 0x7b09d
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1f890
cmpl $0x0, %eax
je 0x7b0cd
cmpq $0x0, -0x10(%rbp)
je 0x7b0ee
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1f890
cmpl $0x0, %eax
jne 0x7b0ee
movl -0x14(%rbp), %eax
movq -0x40(%rbp), %rcx
movq 0x20(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jne 0x7b0ee
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x23c30
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7b052
movq -0x28(%rbp), %rdi
callq 0x243d0
movl -0x34(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFlushConfig
void sentinelFlushConfig(void) {
    int fd = -1;
    int saved_hz = server.hz;
    int rewrite_status;

    server.hz = REDIS_DEFAULT_HZ;
    rewrite_status = rewriteConfig(server.configfile);
    server.hz = saved_hz;

    if (rewrite_status == -1) goto werr;
    if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr;
    if (fsync(fd) == -1) goto werr;
    if (close(fd) == EOF) goto werr;
    return;

werr:
    if (fd != -1) close(fd);
    redisLog(REDIS_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
leaq 0x980c2(%rip), %rax     # 0x1138f8
movl 0x8(%rax), %eax
movl %eax, -0x8(%rbp)
leaq 0x980b5(%rip), %rax     # 0x1138f8
movl $0xa, 0x8(%rax)
leaq 0x980a7(%rip), %rax     # 0x1138f8
movq (%rax), %rdi
callq 0x5db90
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %ecx
leaq 0x98092(%rip), %rax     # 0x1138f8
movl %ecx, 0x8(%rax)
cmpl $-0x1, -0xc(%rbp)
jne 0x7b871
jmp 0x7b8ae
leaq 0x98080(%rip), %rax     # 0x1138f8
movq (%rax), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x1f640
movl %eax, -0x4(%rbp)
cmpl $-0x1, %eax
jne 0x7b88e
jmp 0x7b8ae
movl -0x4(%rbp), %edi
callq 0x1f5d0
cmpl $-0x1, %eax
jne 0x7b89d
jmp 0x7b8ae
movl -0x4(%rbp), %edi
callq 0x1f170
cmpl $-0x1, %eax
jne 0x7b8ac
jmp 0x7b8ae
jmp 0x7b8de
cmpl $-0x1, -0x4(%rbp)
je 0x7b8bc
movl -0x4(%rbp), %edi
callq 0x1f170
callq 0x1f820
movl (%rax), %edi
callq 0x1f630
movq %rax, %rdx
movl $0x3, %edi
leaq 0x6db26(%rip), %rsi     # 0xe93fd
movb $0x0, %al
callq 0x24fb0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelDisconnectInstanceFromContext
void sentinelDisconnectInstanceFromContext(const redisAsyncContext *c) {
    sentinelRedisInstance *ri = c->data;
    int pubsub;

    if (ri == NULL) return; /* The instance no longer exists. */

    // 发送断线事件
    pubsub = (ri->pc == c);
    sentinelEvent(REDIS_DEBUG, pubsub ? "-pubsub-link" : "-cmd-link", ri,
        "%@ #%s", c->errstr);

    if (pubsub)
        ri->pc = NULL;
    else
        ri->cc = NULL;

    // 打开标志
    ri->flags |= SRI_DISCONNECTED;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x7c6d4
jmp 0x7c74d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x8(%rbp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
leaq 0x6cd61(%rip), %rsi     # 0xe9456
leaq 0x6cd4d(%rip), %rax     # 0xe9449
cmpl $0x0, %ecx
cmovneq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %r8
xorl %edi, %edi
leaq 0x6cd45(%rip), %rcx     # 0xe9460
movb $0x0, %al
callq 0x79b10
cmpl $0x0, -0x14(%rbp)
je 0x7c736
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x7c742
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
orl $0x8, %ecx
movl %ecx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelLinkEstablishedCallback
void sentinelLinkEstablishedCallback(const redisAsyncContext *c, int status) {
    if (status != REDIS_OK) {
        sentinelDisconnectInstanceFromContext(c);
    } else {
        sentinelRedisInstance *ri = c->data;
        int pubsub = (ri->pc == c);

        // 发送连接事件
        sentinelEvent(REDIS_DEBUG, pubsub ? "+pubsub-link" : "+cmd-link", ri,
            "%@");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x7c780
movq -0x8(%rbp), %rdi
callq 0x7c6b0
jmp 0x7c7d2
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x8(%rbp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
leaq 0x6ccc4(%rip), %rsi     # 0xe9474
leaq 0x6ccb0(%rip), %rax     # 0xe9467
cmpl $0x0, %ecx
cmovneq %rax, %rsi
movq -0x18(%rbp), %rdx
xorl %edi, %edi
leaq 0x6c867(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelSendAuthIfNeeded
void sentinelSendAuthIfNeeded(sentinelRedisInstance *ri, redisAsyncContext *c) {

    // 如果 ri 是主服务器，那么使用实例自己的密码
    // 如果 ri 是从服务器，那么使用主服务器的密码
    char *auth_pass = (ri->flags & SRI_MASTER) ? ri->auth_pass :
                                                 ri->master->auth_pass;

    // 发送 AUTH 命令
    if (auth_pass) {
        if (redisAsyncCommand(c, sentinelDiscardReplyCallback, NULL, "AUTH %s",
            auth_pass) == REDIS_OK) ri->pending_commands++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7c82f
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x7c845
movq -0x8(%rbp), %rax
movq 0xf8(%rax), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x7c889
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %r8
leaq 0x2d(%rip), %rsi        # 0x7c890
xorl %eax, %eax
movl %eax, %edx
leaq 0x6cc10(%rip), %rcx     # 0xe947e
movb $0x0, %al
callq 0x86730
cmpl $0x0, %eax
jne 0x7c887
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
jmp 0x7c889
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelSetClientName
void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char *type) {
    char name[64];

    snprintf(name,sizeof(name),"sentinel-%.8s-%s",server.runid,type);
    if (redisAsyncCommand(c, sentinelDiscardReplyCallback, NULL,
        "CLIENT SETNAME %s", name) == REDIS_OK)
    {
        ri->pending_commands++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x60(%rbp), %rdi
movq -0x18(%rbp), %r8
movl $0x40, %esi
leaq 0x6cb8e(%rip), %rdx     # 0xe9486
leaq 0x96ff9(%rip), %rcx     # 0x1138f8
addq $0x58, %rcx
movb $0x0, %al
callq 0x1f120
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %r8
leaq -0x89(%rip), %rsi       # 0x7c890
xorl %eax, %eax
movl %eax, %edx
leaq 0x6cb73(%rip), %rcx     # 0xe9497
movb $0x0, %al
callq 0x86730
cmpl $0x0, %eax
jne 0x7c93d
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelSendPing
int sentinelSendPing(sentinelRedisInstance *ri) {
    int retval = redisAsyncCommand(ri->cc,
        sentinelPingReplyCallback, NULL, "PING");
    if (retval == REDIS_OK) {
        ri->pending_commands++;
        /* We update the ping time only if we received the pong for
         * the previous ping, otherwise we are technically waiting
         * since the first ping that did not received a reply. */
        if (ri->last_ping_time == 0) ri->last_ping_time = mstime();
        return 1;
    } else {
        return 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
leaq 0xe55(%rip), %rsi       # 0x7dba0
xorl %eax, %eax
movl %eax, %edx
leaq 0x65cf4(%rip), %rcx     # 0xe2a4a
movb $0x0, %al
callq 0x86730
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x7cd97
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x7cd8e
callq 0x252e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x7cd9e
movl $0x0, -0x4(%rbp)
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/sentinel.c
// Function: sentinelReceiveHelloMessages
void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = c->data;
    redisReply *r;

    if (!reply || !ri) return;
    r = reply;

    /* Update the last activity in the pubsub channel. Note that since we
     * receive our messages as well this timestamp can be used to detect
     * if the link is probably disconnected even if it seems otherwise. */
    // 更新最后一次接收频道命令的时间
    ri->pc_last_activity = mstime();
   
    /* Sanity check in the reply we expect, so that the code that follows
     * can avoid to check for details. */
    // 只处理频道发来的信息，不处理订阅时和退订时产生的信息
    if (r->type != REDIS_REPLY_ARRAY ||
        r->elements != 3 ||
        r->element[0]->type != REDIS_REPLY_STRING ||
        r->element[1]->type != REDIS_REPLY_STRING ||
        r->element[2]->type != REDIS_REPLY_STRING ||
        strcmp(r->element[0]->str,"message") != 0) return;

    /* We are not interested in meeting ourselves */
    // 只处理非自己发送的信息
    if (strstr(r->element[2]->str,server.runid) != NULL) return;

    sentinelProcessHelloMessage(r->element[2]->str, r->element[2]->len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x7cde1
cmpq $0x0, -0x20(%rbp)
jne 0x7cde6
jmp 0x7ceb2
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x252e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x28(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x7ce64
movq -0x28(%rbp), %rax
cmpq $0x3, 0x20(%rax)
jne 0x7ce64
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x7ce64
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x1, (%rax)
jne 0x7ce64
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x1, (%rax)
jne 0x7ce64
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x6caa0(%rip), %rsi     # 0xe98fa
callq 0x1f890
cmpl $0x0, %eax
je 0x7ce66
jmp 0x7ceb2
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x96a7b(%rip), %rsi     # 0x1138f8
addq $0x58, %rsi
callq 0x1f660
cmpq $0x0, %rax
je 0x7ce8e
jmp 0x7ceb2
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movl 0x10(%rax), %esi
callq 0x7dd90
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelSendSlaveOf
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
    char portstr[32];
    int retval;

    ll2string(portstr,sizeof(portstr),port);

    if (host == NULL) {
        host = "NO";
        memcpy(portstr,"ONE",4);
    }

    // 发送 SLAVEOF NO ONE
    retval = redisAsyncCommand(ri->cc,
        sentinelDiscardReplyCallback, NULL, "SLAVEOF %s %s", host, portstr);
    if (retval == REDIS_ERR) return retval;

    ri->pending_commands++;

    // 发送 CONFIG REWRITE
    if (redisAsyncCommand(ri->cc,
        sentinelDiscardReplyCallback, NULL, "CONFIG REWRITE") == REDIS_OK)
    {
        ri->pending_commands++;
    }

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
movl $0x20, %esi
callq 0x39660
cmpq $0x0, -0x18(%rbp)
jne 0x7daa0
leaq 0x6c2ba(%rip), %rax     # 0xe9d4d
movq %rax, -0x18(%rbp)
movl 0x6c2b3(%rip), %eax     # 0xe9d50
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x18(%rbp), %r8
leaq -0x40(%rbp), %r9
leaq -0x1227(%rip), %rsi     # 0x7c890
xorl %eax, %eax
movl %eax, %edx
leaq 0x6c292(%rip), %rcx     # 0xe9d54
movb $0x0, %al
callq 0x86730
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x7dada
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7db21
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
leaq -0x1266(%rip), %rsi     # 0x7c890
xorl %eax, %eax
movl %eax, %edx
leaq 0x669ee(%rip), %rcx     # 0xe44ef
movb $0x0, %al
callq 0x86730
cmpl $0x0, %eax
jne 0x7db1a
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelInfoReplyCallback
void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = c->data;
    redisReply *r;

    if (ri) ri->pending_commands--;
    if (!reply || !ri) return;
    r = reply;

    if (r->type == REDIS_REPLY_STRING) {
        sentinelRefreshInstanceInfo(ri,r->str);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7db67
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x7db75
cmpq $0x0, -0x20(%rbp)
jne 0x7db77
jmp 0x7db99
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x7db99
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x7cf30
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelPublishReplyCallback
void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = c->data;
    redisReply *r;

    if (ri) ri->pending_commands--;
    if (!reply || !ri) return;
    r = reply;

    /* Only update pub_time if we actually published our message. Otherwise
     * we'll retry against in 100 milliseconds. */
    // 如果命令发送成功，那么更新 last_pub_time
    if (r->type != REDIS_REPLY_ERROR)
        ri->last_pub_time = mstime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7dd57
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x7dd65
cmpq $0x0, -0x20(%rbp)
jne 0x7dd67
jmp 0x7dd88
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x6, (%rax)
je 0x7dd88
callq 0x252e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x70(%rax)
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelGetMasterByNameOrReplyError
sentinelRedisInstance *sentinelGetMasterByNameOrReplyError(redisClient *c,
                        robj *name)
{
    sentinelRedisInstance *ri;

    ri = dictFetchValue(sentinel.masters,c->argv[2]->ptr);
    if (!ri) {
        addReplyError(c,"No such master with that name");
        return NULL;
    }
    return ri;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq 0xa9369(%rip), %rdi     # 0x128240
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x24050
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7ef11
movq -0x10(%rbp), %rdi
leaq 0x6aa20(%rip), %rsi     # 0xe9922
callq 0x35d40
movq $0x0, -0x8(%rbp)
jmp 0x7ef19
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%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/sentinel.c
// Function: sentinelStartFailover
void sentinelStartFailover(sentinelRedisInstance *master) {
    redisAssert(master->flags & SRI_MASTER);

    // 更新故障转移状态
    master->failover_state = SENTINEL_FAILOVER_STATE_WAIT_START;

    // 更新主服务器状态
    master->flags |= SRI_FAILOVER_IN_PROGRESS;

    // 更新纪元
    master->failover_epoch = ++sentinel.current_epoch;

    sentinelEvent(REDIS_WARNING,"+new-epoch",master,"%llu",
        (unsigned long long) sentinel.current_epoch);

    sentinelEvent(REDIS_WARNING,"+try-failover",master,"%@");

    // 记录故障转移状态的变更时间
    master->failover_start_time = mstime()+rand()%SENTINEL_MAX_DESYNC;
    master->failover_state_change_time = mstime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7f28c
jmp 0x7f2ae
leaq 0x6aacf(%rip), %rdi     # 0xe9d62
leaq 0x69b4e(%rip), %rsi     # 0xe8de8
movl $0x1065, %edx           # imm = 0x1065
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
movl $0x1, 0x130(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
orl $0x80, %ecx
movl %ecx, (%rax)
movq 0xa8f67(%rip), %rcx     # 0x128238
addq $0x1, %rcx
movq %rcx, 0xa8f5c(%rip)     # 0x128238
movq -0x8(%rbp), %rax
movq %rcx, 0x128(%rax)
movq -0x8(%rbp), %rdx
movq 0xa8f46(%rip), %r8      # 0x128238
movl $0x3, %edi
leaq 0x6a3a9(%rip), %rsi     # 0xe96a7
leaq 0x6a0f3(%rip), %rcx     # 0xe93f8
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0x6aa61(%rip), %rsi     # 0xe9d7d
leaq 0x69d0f(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
callq 0x252e0
movq %rax, -0x10(%rbp)
callq 0x1fb10
movq -0x10(%rbp), %rcx
movl $0x3e8, %esi            # imm = 0x3E8
cltd
idivl %esi
movslq %edx, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x140(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x138(%rax)
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelLeaderIncr
int sentinelLeaderIncr(dict *counters, char *runid) {
    dictEntry *de = dictFind(counters,runid);
    uint64_t oldval;

    if (de) {
        oldval = dictGetUnsignedIntegerVal(de);
        dictSetUnsignedIntegerVal(de,oldval+1);
        return oldval+1;
    } else {
        de = dictAddRaw(counters,runid);
        redisAssert(de != NULL);
        dictSetUnsignedIntegerVal(de,1);
        return 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x23aa0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7feb1
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x4(%rbp)
jmp 0x7ff02
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x23760
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7fecb
jmp 0x7feed
leaq 0x61942(%rip), %rdi     # 0xe1814
leaq 0x68f0f(%rip), %rsi     # 0xe8de8
movl $0xfc2, %edx            # imm = 0xFC2
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
jmp 0x7feef
movq -0x20(%rbp), %rax
movq $0x1, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: compareSlavesForPromotion
int compareSlavesForPromotion(const void *a, const void *b) {
    sentinelRedisInstance **sa = (sentinelRedisInstance **)a,
                          **sb = (sentinelRedisInstance **)b;
    char *sa_runid, *sb_runid;

    // 优先级较小的从服务器胜出
    if ((*sa)->slave_priority != (*sb)->slave_priority)
        return (*sa)->slave_priority - (*sb)->slave_priority;

    /* If priority is the same, select the slave with greater replication
     * offset (processed more data frmo the master). */
    // 如果优先级相同，那么复制偏移量较大的那个从服务器胜出
    // （偏移量较大表示从主服务器获取的数据更多，更完整）
    if ((*sa)->slave_repl_offset > (*sb)->slave_repl_offset) {
        return -1; /* a < b */
    } else if ((*sa)->slave_repl_offset < (*sb)->slave_repl_offset) {
        return 1; /* b > a */
    }

    /* If the replication offset is the same select the slave with that has
     * the lexicographically smaller runid. Note that we try to handle runid
     * == NULL as there are old Redis versions that don't publish runid in
     * INFO. A NULL runid is considered bigger than any other runid. */
    // 如果复制偏移量也相同，那么选出运行 ID 较低的那个从服务器
    // 注意，对于没有运行 ID 的旧版 Redis 来说，默认的运行 ID 为 NULL
    sa_runid = (*sa)->runid;
    sb_runid = (*sb)->runid;
    if (sa_runid == NULL && sb_runid == NULL) return 0;
    else if (sa_runid == NULL) return 1;  /* a > b */
    else if (sb_runid == NULL) return -1; /* a < b */
    return strcasecmp(sa_runid, sb_runid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl 0xe8(%rax), %eax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0xe8(%rcx), %eax
je 0x802ce
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl 0xe8(%rax), %eax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
subl 0xe8(%rcx), %eax
movl %eax, -0x4(%rbp)
jmp 0x8038a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x110(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x110(%rcx), %rax
jbe 0x802f8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8038a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x110(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x110(%rcx), %rax
jae 0x8031f
movl $0x1, -0x4(%rbp)
jmp 0x8038a
jmp 0x80321
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x80356
cmpq $0x0, -0x38(%rbp)
jne 0x80356
movl $0x0, -0x4(%rbp)
jmp 0x8038a
cmpq $0x0, -0x30(%rbp)
jne 0x80366
movl $0x1, -0x4(%rbp)
jmp 0x8038a
cmpq $0x0, -0x38(%rbp)
jne 0x80376
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8038a
jmp 0x80378
jmp 0x8037a
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x1f2f0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelAbortFailover
void sentinelAbortFailover(sentinelRedisInstance *ri) {
    redisAssert(ri->flags & SRI_FAILOVER_IN_PROGRESS);
    redisAssert(ri->failover_state <= SENTINEL_FAILOVER_STATE_WAIT_PROMOTION);

    // 移除相关标识
    ri->flags &= ~(SRI_FAILOVER_IN_PROGRESS|SRI_FORCE_FAILOVER);

    // 清除状态
    ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
    ri->failover_state_change_time = mstime();

    // 清除新主服务器的升级标识
    if (ri->promoted_slave) {
        ri->promoted_slave->flags &= ~SRI_PROMOTED;
        // 清空新服务器
        ri->promoted_slave = NULL;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8050e
jmp 0x80530
leaq 0x699f4(%rip), %rdi     # 0xe9f09
leaq 0x688cc(%rip), %rsi     # 0xe8de8
movl $0x12d4, %edx           # imm = 0x12D4
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
cmpl $0x4, 0x130(%rax)
jg 0x8053f
jmp 0x80561
leaq 0x699e8(%rip), %rdi     # 0xe9f2e
leaq 0x6889b(%rip), %rsi     # 0xe8de8
movl $0x12d5, %edx           # imm = 0x12D5
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xffffef7f, %ecx       # imm = 0xFFFFEF7F
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x130(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x158(%rax)
je 0x805c2
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rax
movl (%rax), %ecx
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x158(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFailoverSelectSlave
void sentinelFailoverSelectSlave(sentinelRedisInstance *ri) {

    // 在旧主服务器所属的从服务器中，选择新服务器
    sentinelRedisInstance *slave = sentinelSelectSlave(ri);

    /* We don't handle the timeout in this state as the function aborts
     * the failover or go forward in the next state. */
    // 没有合适的从服务器，直接终止故障转移操作
    if (slave == NULL) {

        // 没有可用的从服务器可以提升为新主服务器，故障转移操作无法执行
        sentinelEvent(REDIS_WARNING,"-failover-abort-no-good-slave",ri,"%@");

        // 中止故障转移
        sentinelAbortFailover(ri);

    } else {

        // 成功选定新主服务器

        // 发送事件
        sentinelEvent(REDIS_WARNING,"+selected-slave",slave,"%@");

        // 打开实例的升级标记
        slave->flags |= SRI_PROMOTED;

        // 记录被选中的从服务器
        ri->promoted_slave = slave;

        // 更新故障转移状态
        ri->failover_state = SENTINEL_FAILOVER_STATE_SEND_SLAVEOF_NOONE;

        // 更新状态改变时间
        ri->failover_state_change_time = mstime();

        // 发送事件
        sentinelEvent(REDIS_NOTICE,"+failover-state-send-slaveof-noone",
            slave, "%@");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7f0c0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x80619
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0x6980f(%rip), %rsi     # 0xe9e0f
leaq 0x68a2b(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rdi
callq 0x804f0
jmp 0x80693
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x69804(%rip), %rsi     # 0xe9e2d
leaq 0x68a02(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
movq -0x10(%rbp), %rax
movl (%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x8(%rbp), %rax
movl $0x3, 0x130(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x10(%rbp), %rdx
movl $0x2, %edi
leaq 0x697b8(%rip), %rsi     # 0xe9e3d
leaq 0x689a6(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFailoverSendSlaveOfNoOne
void sentinelFailoverSendSlaveOfNoOne(sentinelRedisInstance *ri) {
    int retval;

    /* We can't send the command to the promoted slave if it is now
     * disconnected. Retry again and again with this state until the timeout
     * is reached, then abort the failover. */
    // 如果选中的从服务器断线了，那么在给定的时间内重试
    // 如果给定时间内选中的从服务器也没有上线，那么终止故障迁移操作
    // （一般来说出现这种情况的机会很小，因为在选择新的主服务器时，
    // 已经断线的从服务器是不会被选中的，所以这种情况只会出现在
    // 从服务器被选中，并且发送 SLAVEOF NO ONE 命令之前的这段时间内）
    if (ri->promoted_slave->flags & SRI_DISCONNECTED) {

        // 如果超过时限，就不再重试
        if (mstime() - ri->failover_state_change_time > ri->failover_timeout) {
            sentinelEvent(REDIS_WARNING,"-failover-abort-slave-timeout",ri,"%@");
            sentinelAbortFailover(ri);
        }
        return;
    }

    /* Send SLAVEOF NO ONE command to turn the slave into a master.
     *
     * 向被升级的从服务器发送 SLAVEOF NO ONE 命令，将它变为一个主服务器。
     *
     * We actually register a generic callback for this command as we don't
     * really care about the reply. We check if it worked indirectly observing
     * if INFO returns a different role (master instead of slave). 
     *
     * 这里没有为命令回复关联一个回调函数，因为从服务器是否已经转变为主服务器可以
     * 通过向从服务器发送 INFO 命令来确认
     */
    retval = sentinelSendSlaveOf(ri->promoted_slave,NULL,0);
    if (retval != REDIS_OK) return;
    sentinelEvent(REDIS_NOTICE, "+failover-state-wait-promotion",
        ri->promoted_slave,"%@");

    // 更新状态
    // 这个状态会让 Sentinel 等待被选中的从服务器升级为主服务器
    ri->failover_state = SENTINEL_FAILOVER_STATE_WAIT_PROMOTION;

    // 更新状态改变的时间
    ri->failover_state_change_time = mstime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x80707
callq 0x252e0
movq -0x8(%rbp), %rcx
subq 0x138(%rcx), %rax
movq -0x8(%rbp), %rcx
cmpq 0x148(%rcx), %rax
jle 0x80705
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0x69772(%rip), %rsi     # 0xe9e60
leaq 0x6893d(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rdi
callq 0x804f0
jmp 0x8076e
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x7da60
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x80728
jmp 0x8076e
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rdx
movl $0x2, %edi
leaq 0x6973f(%rip), %rsi     # 0xe9e7e
leaq 0x688ec(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rax
movl $0x4, 0x130(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x138(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFailoverWaitPromotion
void sentinelFailoverWaitPromotion(sentinelRedisInstance *ri) {
    /* Just handle the timeout. Switching to the next state is handled
     * by the function parsing the INFO command of the promoted slave. */
    if (mstime() - ri->failover_state_change_time > ri->failover_timeout) {
        sentinelEvent(REDIS_WARNING,"-failover-abort-slave-timeout",ri,"%@");
        sentinelAbortFailover(ri);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
callq 0x252e0
movq -0x8(%rbp), %rcx
subq 0x138(%rcx), %rax
movq -0x8(%rbp), %rcx
cmpq 0x148(%rcx), %rax
jle 0x807d0
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0x696a7(%rip), %rsi     # 0xe9e60
leaq 0x68872(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rdi
callq 0x804f0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFailoverSwitchToPromotedSlave
void sentinelFailoverSwitchToPromotedSlave(sentinelRedisInstance *master) {

    /// 选出要添加的 master
    sentinelRedisInstance *ref = master->promoted_slave ?
                                 master->promoted_slave : master;

    // 发送更新 master 事件
    sentinelEvent(REDIS_WARNING,"+switch-master",master,"%s %s %d %s %d",
        // 原 master 信息
        master->name, master->addr->ip, master->addr->port,
        // 新 master 信息
        ref->addr->ip, ref->addr->port);

    // 用新主服务器的信息代替原 master 的信息
    sentinelResetMasterAndChangeAddress(master,ref->addr->ip,ref->addr->port);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x158(%rax)
je 0x80c0b
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x80c13
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %r9
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %r11d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %r10
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
movl $0x3, %edi
leaq 0x68a66(%rip), %rsi     # 0xe96c6
leaq 0x68a6e(%rip), %rcx     # 0xe96d5
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x79b10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %edx
callq 0x7b5c0
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelFailoverStateMachine
void sentinelFailoverStateMachine(sentinelRedisInstance *ri) {
    redisAssert(ri->flags & SRI_MASTER);

    // master 未进入故障转移状态，直接返回
    if (!(ri->flags & SRI_FAILOVER_IN_PROGRESS)) return;

    switch(ri->failover_state) {

        // 等待故障转移开始
        case SENTINEL_FAILOVER_STATE_WAIT_START:
            sentinelFailoverWaitStart(ri);
            break;

        // 选择新主服务器
        case SENTINEL_FAILOVER_STATE_SELECT_SLAVE:
            sentinelFailoverSelectSlave(ri);
            break;
        
        // 升级被选中的从服务器为新主服务器
        case SENTINEL_FAILOVER_STATE_SEND_SLAVEOF_NOONE:
            sentinelFailoverSendSlaveOfNoOne(ri);
            break;

        // 等待升级生效，如果升级超时，那么重新选择新主服务器
        // 具体情况请看 sentinelRefreshInstanceInfo 函数
        case SENTINEL_FAILOVER_STATE_WAIT_PROMOTION:
            sentinelFailoverWaitPromotion(ri);
            break;

        // 向从服务器发送 SLAVEOF 命令，让它们同步新主服务器
        case SENTINEL_FAILOVER_STATE_RECONF_SLAVES:
            sentinelFailoverReconfNextSlave(ri);
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x80cbc
jmp 0x80cde
leaq 0x6833e(%rip), %rdi     # 0xe9001
leaq 0x6811e(%rip), %rsi     # 0xe8de8
movl $0x12a4, %edx           # imm = 0x12A4
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x80cf0
jmp 0x80d50
movq -0x8(%rbp), %rax
movl 0x130(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x4, %eax
ja 0x80d50
movq -0x10(%rbp), %rax
leaq 0x680c2(%rip), %rcx     # 0xe8dd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
callq 0x803a0
jmp 0x80d50
movq -0x8(%rbp), %rdi
callq 0x805d0
jmp 0x80d50
movq -0x8(%rbp), %rdi
callq 0x806a0
jmp 0x80d50
movq -0x8(%rbp), %rdi
callq 0x80780
jmp 0x80d50
movq -0x8(%rbp), %rdi
callq 0x809f0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelCheckTiltCondition
void sentinelCheckTiltCondition(void) {

    // 计算当前时间
    mstime_t now = mstime();

    // 计算上次运行 sentinel 和当前时间的差
    mstime_t delta = now - sentinel.previous_time;

    // 如果差为负数，或者大于 2 秒钟，那么进入 TILT 模式
    if (delta < 0 || delta > SENTINEL_TILT_TRIGGER) {
        // 打开标记
        sentinel.tilt = 1;
        // 记录进入 TILT 模式的开始时间
        sentinel.tilt_start_time = mstime();
        // 打印事件
        sentinelEvent(REDIS_WARNING,"+tilt",NULL,"#tilt mode entered");
    }

    // 更新最后一次 sentinel 运行时间
    sentinel.previous_time = mstime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
callq 0x252e0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
subq 0xa735c(%rip), %rax     # 0x128258
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jl 0x80f11
cmpq $0x7d0, -0x10(%rbp)     # imm = 0x7D0
jle 0x80f45
movl $0x1, 0xa732d(%rip)     # 0x128248
callq 0x252e0
movq %rax, 0xa7329(%rip)     # 0x128250
movl $0x3, %edi
leaq 0x69050(%rip), %rsi     # 0xe9f83
xorl %eax, %eax
movl %eax, %edx
leaq 0x6904b(%rip), %rcx     # 0xe9f89
movb $0x0, %al
callq 0x79b10
callq 0x252e0
movq %rax, 0xa7307(%rip)     # 0x128258
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/notify.c
// Function: keyspaceEventsStringToFlags
int keyspaceEventsStringToFlags(char *classes) {
    char *p = classes;
    int c, flags = 0;

    while((c = *p++) != '\0') {
        switch(c) {
        case 'A': flags |= REDIS_NOTIFY_ALL; break;
        case 'g': flags |= REDIS_NOTIFY_GENERIC; break;
        case '$': flags |= REDIS_NOTIFY_STRING; break;
        case 'l': flags |= REDIS_NOTIFY_LIST; break;
        case 's': flags |= REDIS_NOTIFY_SET; break;
        case 'h': flags |= REDIS_NOTIFY_HASH; break;
        case 'z': flags |= REDIS_NOTIFY_ZSET; break;
        case 'x': flags |= REDIS_NOTIFY_EXPIRED; break;
        case 'e': flags |= REDIS_NOTIFY_EVICTED; break;
        case 'K': flags |= REDIS_NOTIFY_KEYSPACE; break;
        case 'E': flags |= REDIS_NOTIFY_KEYEVENT; break;
        // 不能识别
        default: return -1;
        }
    }

    return flags;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movsbl (%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
je 0x812cd
movl -0x1c(%rbp), %eax
addl $-0x24, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x56, %eax
ja 0x812bf
movq -0x28(%rbp), %rax
leaq 0x68d67(%rip), %rcx     # 0xe9f9c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x20(%rbp), %eax
orl $0x3fc, %eax            # imm = 0x3FC
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl -0x20(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x20(%rbp)
jmp 0x812c8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x812d3
jmp 0x811f7
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/blocked.c
// Function: getTimeoutFromObjectOrReply
int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout, int unit) {
    long long tval;

    if (getLongLongFromObjectOrReply(c,object,&tval,
        "timeout is not an integer or out of range") != REDIS_OK)
        return REDIS_ERR;

    if (tval < 0) {
        addReplyError(c,"timeout is negative");
        return REDIS_ERR;
    }

    if (tval > 0) {
        if (unit == UNIT_SECONDS) tval *= 1000;
        tval += mstime();
    }
    *timeout = tval;

    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq 0x6835c(%rip), %rcx     # 0xea116
callq 0x3b8e0
cmpl $0x0, %eax
je 0x81dcd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x81e25
cmpq $0x0, -0x30(%rbp)
jge 0x81ded
movq -0x10(%rbp), %rdi
leaq 0x68361(%rip), %rsi     # 0xea140
callq 0x35d40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x81e25
cmpq $0x0, -0x30(%rbp)
jle 0x81e13
cmpl $0x0, -0x24(%rbp)
jne 0x81e06
imulq $0x3e8, -0x30(%rbp), %rax # imm = 0x3E8
movq %rax, -0x30(%rbp)
callq 0x252e0
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop