LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelRoleCommand
void sentinelRoleCommand(client *c) {
    dictIterator *di;
    dictEntry *de;

    addReplyMultiBulkLen(c,2);
    addReplyBulkCBuffer(c,"sentinel",8);
    addReplyMultiBulkLen(c,dictSize(sentinel.masters));

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);

        addReplyBulkCString(c,ri->name);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x2, %esi
callq 0x4063b
leaq 0x559bb(%rip), %rsi     # 0xcfac6
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4070f
movq 0xa1591(%rip), %rax     # 0x11b6b0
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
movq %rbx, %rdi
callq 0x4063b
movq 0xa157a(%rip), %rdi     # 0x11b6b0
callq 0x320bb
movq %rax, %r14
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7a160
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x404b9
movq %r14, %rdi
jmp 0x7a141
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x321d3
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: initSentinel
void initSentinel(void) {
    unsigned int j;

    /* Remove usual Redis commands from the command table, then just add
     * the SENTINEL command. */
    dictEmpty(server.commands,NULL);
    for (j = 0; j < sizeof(sentinelcmds)/sizeof(sentinelcmds[0]); j++) {
        int retval;
        struct redisCommand *cmd = sentinelcmds+j;

        retval = dictAdd(server.commands, sdsnew(cmd->name), cmd);
        serverAssert(retval == DICT_OK);
    }

    /* Initialize various data structures. */
    sentinel.current_epoch = 0;
    sentinel.masters = dictCreate(&instancesDictType,NULL);
    sentinel.tilt = 0;
    sentinel.tilt_start_time = 0;
    sentinel.previous_time = mstime();
    sentinel.running_scripts = 0;
    sentinel.scripts_queue = listCreate();
    sentinel.announce_ip = NULL;
    sentinel.announce_port = 0;
    sentinel.simfailure_flags = SENTINEL_SIMFAILURE_NONE;
    memset(sentinel.myid,0,sizeof(sentinel.myid));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x8c6c7(%rip), %r15     # 0x106858
movq 0x30(%r15), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x3261e
leaq 0x8c0ca(%rip), %r13     # 0x106270
leaq (%r12,%r13), %rbx
movq 0x30(%r15), %r14
movq (%r12,%r13), %rdi
callq 0x39245
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x31a95
testl %eax, %eax
jne 0x7a259
addq $0x50, %r12
cmpq $0x370, %r12            # imm = 0x370
jne 0x7a1a6
xorl %ebx, %ebx
movq %rbx, 0xa14c5(%rip)     # 0x11b6a8
leaq 0x8c026(%rip), %rdi     # 0x106210
xorl %esi, %esi
callq 0x31774
movq %rax, 0xa14b8(%rip)     # 0x11b6b0
movl %ebx, 0xa14ba(%rip)     # 0x11b6b8
movq %rbx, 0xa14bb(%rip)     # 0x11b6c0
callq 0x330c8
movq %rax, 0xa14b7(%rip)     # 0x11b6c8
movl %ebx, 0xa14a5(%rip)     # 0x11b6bc
callq 0x2e33c
movq %rax, 0xa14ad(%rip)     # 0x11b6d0
movq %rbx, 0xa14ae(%rip)     # 0x11b6d8
movl %ebx, 0xa14b0(%rip)     # 0x11b6e0
movq %rbx, 0xa14b1(%rip)     # 0x11b6e8
xorps %xmm0, %xmm0
movups %xmm0, 0xa1437(%rip)    # 0x11b678
movups %xmm0, 0xa1440(%rip)    # 0x11b688
movups %xmm0, 0xa1442(%rip)    # 0x11b691
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x49c6c(%rip), %rdi     # 0xc3ecc
leaq 0x54ee9(%rip), %rsi     # 0xcf150
movl $0x1c9, %edx            # imm = 0x1C9
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelIsRunning
void sentinelIsRunning(void) {
    int j;

    if (server.configfile == NULL) {
        serverLog(LL_WARNING,
            "Sentinel started without a config file. Exiting...");
        exit(1);
    } else if (access(server.configfile,W_OK) == -1) {
        serverLog(LL_WARNING,
            "Sentinel config file %s is not writable: %s. Exiting...",
            server.configfile,strerror(errno));
        exit(1);
    }

    /* If this Sentinel has yet no ID set in the configuration file, we
     * pick a random one and persist the config on disk. From now on this
     * will be this Sentinel ID across restarts. */
    for (j = 0; j < CONFIG_RUN_ID_SIZE; j++)
        if (sentinel.myid[j] != 0) break;

    if (j == CONFIG_RUN_ID_SIZE) {
        /* Pick ID and presist the config. */
        getRandomHexChars(sentinel.myid,CONFIG_RUN_ID_SIZE);
        sentinelFlushConfig();
    }

    /* Log its ID to make debugging of issues simpler. */
    serverLog(LL_WARNING,"Sentinel ID is %s", sentinel.myid);

    /* We want to generate a +monitor event for every configured master
     * at startup. */
    sentinelGenerateInitialMonitorEvents();
}

// Assembly:
pushq %rbx
leaq 0x8c5d5(%rip), %rbx     # 0x106858
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x7a2f3
movl $0x2, %esi
callq 0x26ab0
cmpl $-0x1, %eax
je 0x7a308
xorl %eax, %eax
leaq 0xa13d4(%rip), %rcx     # 0x11b678
cmpb $0x0, (%rax,%rcx)
jne 0x7a2b8
incq %rax
cmpq $0x28, %rax
jne 0x7a2a4
movl $0x28, %eax
cmpl $0x28, %eax
jne 0x7a2d3
leaq 0xa13b4(%rip), %rdi     # 0x11b678
movl $0x28, %esi
callq 0x43699
callq 0x7a33b
leaq 0x54eec(%rip), %rsi     # 0xcf1c6
leaq 0xa1397(%rip), %rdx     # 0x11b678
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
popq %rbx
jmp 0x7a3d0
leaq 0x54e61(%rip), %rsi     # 0xcf15b
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
jmp 0x7a331
movq 0x8(%rbx), %rbx
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x54e6f(%rip), %rsi     # 0xcf18e
movl $0x3, %edi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x32ea6
movl $0x1, %edi
callq 0x262d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelFlushConfig
void sentinelFlushConfig(void) {
    int fd = -1;
    int saved_hz = server.hz;
    int rewrite_status;

    server.hz = CONFIG_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);
    serverLog(LL_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x8c512(%rip), %r14     # 0x106858
movl 0x20(%r14), %ebx
movl $0xa, 0x20(%r14)
movq 0x8(%r14), %rdi
callq 0x5ffd9
movl %ebx, 0x20(%r14)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x7a39e
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x266a0
cmpl $-0x1, %eax
je 0x7a39e
movl %eax, %ebp
movl %eax, %edi
callq 0x26610
cmpl $-0x1, %eax
je 0x7a39c
movl %ebp, %edi
callq 0x26180
movl %ebp, %ebx
cmpl $-0x1, %eax
je 0x7a39e
popq %rbx
popq %r14
popq %rbp
retq
movl %ebp, %ebx
cmpl $-0x1, %ebx
je 0x7a3aa
movl %ebx, %edi
callq 0x26180
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x55474(%rip), %rsi     # 0xcf831
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x32ea6
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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(LL_WARNING,"+monitor",ri,"%@ quorum %d",ri->quorum);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0xa12d4(%rip), %rdi     # 0x11b6b0
callq 0x320bb
movq %rax, %rbx
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7a429
leaq 0x54e03(%rip), %r14     # 0xcf1fb
leaq 0x54e05(%rip), %r15     # 0xcf204
movq 0x8(%rax), %rdx
movl 0x90(%rdx), %r8d
movl $0x3, %edi
movq %r14, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x7a50c
movq %rbx, %rdi
callq 0x32116
testq %rax, %rax
jne 0x7a3ff
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x321d3
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: createSentinelAddr
sentinelAddr *createSentinelAddr(char *hostname, int port) {
    char ip[NET_IP_STR_LEN];
    sentinelAddr *sa;

    if (port < 0 || port > 65535) {
        errno = EINVAL;
        return NULL;
    }
    if (anetResolve(NULL,hostname,ip,sizeof(ip)) == ANET_ERR) {
        errno = ENOENT;
        return NULL;
    }
    sa = zmalloc(sizeof(*sa));
    sa->ip = sdsnew(ip);
    sa->port = port;
    return sa;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebx
cmpl $0x10000, %esi          # imm = 0x10000
jb 0x7a454
callq 0x26890
movl $0x16, (%rax)
jmp 0x7a494
movq %rdi, %rsi
movq %rsp, %rdx
movl $0x2e, %ecx
xorl %edi, %edi
callq 0x30b1b
cmpl $-0x1, %eax
je 0x7a489
movl $0x10, %edi
callq 0x3b29d
movq %rax, %r14
movq %rsp, %rdi
callq 0x39245
movq %rax, (%r14)
movl %ebx, 0x8(%r14)
jmp 0x7a497
callq 0x26890
movl $0x2, (%rax)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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(LL_WARNING,"-script-timeout",NULL,"%s %ld",
                sj->argv[0], (long)sj->pid);
            kill(sj->pid,SIGKILL);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
callq 0x330c8
movq %rax, %rbx
movq 0xa09bc(%rip), %rdi     # 0x11b6d0
movq %rsp, %r14
movq %r14, %rsi
callq 0x2e582
movq %r14, %rdi
callq 0x2e59f
testq %rax, %rax
je 0x7ad91
movq %rsp, %r14
leaq 0x5459a(%rip), %r15     # 0xcf2d0
leaq 0x4cf53(%rip), %r12     # 0xc7c90
movq 0x10(%rax), %r13
testb $0x1, (%r13)
je 0x7ad84
movq %rbx, %rax
subq 0x10(%r13), %rax
cmpq $0xea61, %rax           # imm = 0xEA61
jl 0x7ad84
movq 0x8(%r13), %rax
movq (%rax), %r8
movslq 0x18(%r13), %r9
movl $0x3, %edi
movq %r15, %rsi
xorl %edx, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x7a50c
movl 0x18(%r13), %edi
movl $0x9, %esi
callq 0x26670
movq %r14, %rdi
callq 0x2e59f
testq %rax, %rax
jne 0x7ad3d
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: createInstanceLink
instanceLink *createInstanceLink(void) {
    instanceLink *link = zmalloc(sizeof(*link));

    link->refcount = 1;
    link->disconnected = 1;
    link->pending_commands = 0;
    link->cc = NULL;
    link->pc = NULL;
    link->cc_conn_time = 0;
    link->pc_conn_time = 0;
    link->last_reconn_time = 0;
    link->pc_last_activity = 0;
    /* We set the act_ping_time to "now" even if we actually don't have yet
     * a connection with the node, nor we sent a ping.
     * This is useful to detect a timeout in case we'll not be able to connect
     * with the node at all. */
    link->act_ping_time = mstime();
    link->last_ping_time = 0;
    link->last_avail_time = mstime();
    link->last_pong_time = mstime();
    return link;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x60, %edi
callq 0x3b29d
movq %rax, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%rbx)
movl $0x0, 0x8(%rbx)
xorl %r14d, %r14d
movq %r14, 0x58(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
movq %r14, 0x30(%rbx)
callq 0x330c8
movq %rax, 0x40(%rbx)
movq %r14, 0x48(%rbx)
callq 0x330c8
movq %rax, 0x38(%rbx)
callq 0x330c8
movq %rax, 0x50(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: instanceLinkCloseConnection
void instanceLinkCloseConnection(instanceLink *link, redisAsyncContext *c) {
    if (c == NULL) return;

    if (link->cc == c) {
        link->cc = NULL;
        link->pending_commands = 0;
    }
    if (link->pc == c) link->pc = NULL;
    c->data = NULL;
    link->disconnected = 1;
    redisAsyncFree(c);
}

// Assembly:
testq %rsi, %rsi
je 0x7b082
cmpq %rsi, 0x10(%rdi)
jne 0x7b05a
movq $0x0, 0x10(%rdi)
movl $0x0, 0x8(%rdi)
cmpq %rsi, 0x18(%rdi)
jne 0x7b068
movq $0x0, 0x18(%rdi)
movq $0x0, 0xb0(%rsi)
movl $0x1, 0x4(%rdi)
movq %rsi, %rdi
jmp 0x85c87
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: releaseInstanceLink
instanceLink *releaseInstanceLink(instanceLink *link, sentinelRedisInstance *ri)
{
    serverAssert(link->refcount > 0);
    link->refcount--;
    if (link->refcount != 0) {
        if (ri && ri->link->cc) {
            /* This instance may have pending callbacks in the hiredis async
             * context, having as 'privdata' the instance that we are going to
             * free. Let's rewrite the callback list, directly exploiting
             * hiredis internal data structures, in order to bind them with
             * a callback that will ignore the reply at all. */
            redisCallback *cb;
            redisCallbackList *callbacks = &link->cc->replies;

            cb = callbacks->head;
            while(cb) {
                if (cb->privdata == ri) {
                    cb->fn = sentinelDiscardReplyCallback;
                    cb->privdata = NULL; /* Not strictly needed. */
                }
                cb = cb->next;
            }
        }
        return link; /* Other active users. */
    }

    instanceLinkCloseConnection(link,link->cc);
    instanceLinkCloseConnection(link,link->pc);
    zfree(link);
    return NULL;
}

// Assembly:
pushq %rbx
movl (%rdi), %eax
testl %eax, %eax
jle 0x7b0fd
movq %rdi, %rbx
decl %eax
movl %eax, (%rdi)
je 0x7b0d6
testq %rsi, %rsi
je 0x7b0f8
movq 0x28(%rsi), %rax
cmpq $0x0, 0x10(%rax)
je 0x7b0f8
movq 0x10(%rbx), %rax
movq 0xf8(%rax), %rax
testq %rax, %rax
je 0x7b0f8
leaq 0x65(%rip), %rcx        # 0x7b11f
cmpq %rsi, 0x10(%rax)
jne 0x7b0cc
movq %rcx, 0x8(%rax)
movq $0x0, 0x10(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x7b0ba
jmp 0x7b0f8
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x7b040
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
callq 0x7b040
movq %rbx, %rdi
callq 0x3b3df
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
leaq 0x5420f(%rip), %rdi     # 0xcf313
leaq 0x54045(%rip), %rsi     # 0xcf150
movl $0x3d0, %edx            # imm = 0x3D0
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelTryConnectionSharing
int sentinelTryConnectionSharing(sentinelRedisInstance *ri) {
    serverAssert(ri->flags & SRI_SENTINEL);
    dictIterator *di;
    dictEntry *de;

    if (ri->runid == NULL) return C_ERR; /* No way to identify it. */
    if (ri->link->refcount > 1) return C_ERR; /* Already shared. */

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *master = dictGetVal(de), *match;
        /* We want to share with the same physical Sentinel referenced
         * in other masters, so skip our master. */
        if (master == ri->master) continue;
        match = getSentinelRedisInstanceByAddrAndRunID(master->sentinels,
                                                       NULL,0,ri->runid);
        if (match == NULL) continue; /* No match. */
        if (match == ri) continue; /* Should never happen but... safer. */

        /* We identified a matching Sentinel, great! Let's free our link
         * and use the one of the matching Sentinel. */
        releaseInstanceLink(ri->link,NULL);
        ri->link = match->link;
        match->link->refcount++;
        return C_OK;
    }
    dictReleaseIterator(di);
    return C_ERR;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testb $0x4, (%rdi)
je 0x7b1e6
movq %rdi, %r14
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%rdi)
je 0x7b1d8
movq 0x28(%r14), %rax
cmpl $0x1, (%rax)
jg 0x7b1d8
movq 0xa054d(%rip), %rdi     # 0x11b6b0
callq 0x320bb
movq %rax, %r15
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7b1b1
movq 0x8(%rax), %rax
cmpq 0xb8(%r14), %rax
je 0x7b1ac
movq 0x80(%rax), %rdi
movq 0x10(%r14), %rcx
xorl %esi, %esi
xorl %edx, %edx
callq 0x7b208
movq %rax, %r12
testq %rax, %rax
sete %al
cmpq %r14, %r12
sete %cl
orb %al, %cl
je 0x7b1bb
movq %r15, %rdi
jmp 0x7b16e
movq %r15, %rdi
callq 0x321d3
jmp 0x7b1d8
movq 0x28(%r14), %rdi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x7b083
movq 0x28(%r12), %rax
movq %rax, 0x28(%r14)
movq 0x28(%r12), %rax
incl (%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x54139(%rip), %rdi     # 0xcf326
leaq 0x53f5c(%rip), %rsi     # 0xcf150
movl $0x3fb, %edx            # imm = 0x3FB
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelUpdateSentinelAddressInAllMasters
int sentinelUpdateSentinelAddressInAllMasters(sentinelRedisInstance *ri) {
    serverAssert(ri->flags & SRI_SENTINEL);
    dictIterator *di;
    dictEntry *de;
    int reconfigured = 0;

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *master = dictGetVal(de), *match;
        match = getSentinelRedisInstanceByAddrAndRunID(master->sentinels,
                                                       NULL,0,ri->runid);
        /* If there is no match, this master does not know about this
         * Sentinel, try with the next one. */
        if (match == NULL) continue;

        /* Disconnect the old links if connected. */
        if (match->link->cc != NULL)
            instanceLinkCloseConnection(match->link,match->link->cc);
        if (match->link->pc != NULL)
            instanceLinkCloseConnection(match->link,match->link->pc);

        if (match == ri) continue; /* Address already updated for it. */

        /* Update the address of the matching Sentinel by copying the address
         * of the Sentinel object that received the address update. */
        releaseSentinelAddr(match->addr);
        match->addr = dupSentinelAddr(ri->addr);
        reconfigured++;
    }
    dictReleaseIterator(di);
    if (reconfigured)
        sentinelEvent(LL_NOTICE,"+sentinel-address-update", ri,
                    "%@ %d additional matching instances", reconfigured);
    return reconfigured;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testb $0x4, (%rdi)
je 0x7b3f6
movq %rdi, %rbx
movq 0xa03af(%rip), %rdi     # 0x11b6b0
callq 0x320bb
movq %rax, %r15
movq %rax, %rdi
callq 0x32116
xorl %r14d, %r14d
testq %rax, %rax
je 0x7b3b7
movq 0x8(%rax), %rax
movq 0x80(%rax), %rdi
movq 0x10(%rbx), %rcx
xorl %esi, %esi
xorl %edx, %edx
callq 0x7b208
testq %rax, %rax
je 0x7b3aa
movq %rax, %r12
movq 0x28(%rax), %rdi
movq 0x10(%rdi), %rsi
testq %rsi, %rsi
je 0x7b34f
callq 0x7b040
movq 0x28(%r12), %rdi
movq 0x18(%rdi), %rsi
testq %rsi, %rsi
je 0x7b362
callq 0x7b040
cmpq %rbx, %r12
je 0x7b3aa
movq 0x20(%r12), %r13
movq (%r13), %rdi
callq 0x392b6
movq %r13, %rdi
callq 0x3b3df
movq 0x20(%rbx), %rbp
movl $0x10, %edi
callq 0x3b29d
movq %rax, %r13
movq (%rbp), %rdi
callq 0x39245
movq %rax, (%r13)
movl 0x8(%rbp), %eax
movl %eax, 0x8(%r13)
movq %r13, 0x20(%r12)
incl %r14d
movq %r15, %rdi
callq 0x32116
jmp 0x7b314
movq %r15, %rdi
callq 0x321d3
testl %r14d, %r14d
je 0x7b3e4
leaq 0x53f74(%rip), %rsi     # 0xcf33f
leaq 0x53f86(%rip), %rcx     # 0xcf358
movl $0x2, %edi
movq %rbx, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x7a50c
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x53f29(%rip), %rdi     # 0xcf326
leaq 0x53d4c(%rip), %rsi     # 0xcf150
movl $0x41f, %edx            # imm = 0x41F
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelRedisInstanceLookupSlave
sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
                sentinelRedisInstance *ri, char *ip, int port)
{
    sds key;
    sentinelRedisInstance *slave;
    char buf[NET_PEER_ID_LEN];

    serverAssert(ri->flags & SRI_MASTER);
    anetFormatAddr(buf,sizeof(buf),ip,port);
    key = sdsnew(buf);
    slave = dictFetchValue(ri->slaves,key);
    sdsfree(key);
    return slave;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
testb $0x1, (%rdi)
je 0x7b763
movl %edx, %ecx
movq %rsi, %rdx
movq %rdi, %rbx
movq %rsp, %r14
movl $0x4e, %esi
movq %r14, %rdi
callq 0x3144a
movq %r14, %rdi
callq 0x39245
movq %rax, %r14
movq 0x88(%rbx), %rdi
movq %rax, %rsi
callq 0x32019
movq %rax, %rbx
movq %r14, %rdi
callq 0x392b6
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r14
retq
leaq 0x53c65(%rip), %rdi     # 0xcf3cf
leaq 0x539df(%rip), %rsi     # 0xcf150
movl $0x4f9, %edx            # imm = 0x4F9
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: removeMatchingSentinelFromMaster
int removeMatchingSentinelFromMaster(sentinelRedisInstance *master, char *runid) {
    dictIterator *di;
    dictEntry *de;
    int removed = 0;

    if (runid == NULL) return 0;

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

        if (ri->runid && strcmp(ri->runid,runid) == 0) {
            dictDelete(master->sentinels,ri->name);
            removed++;
        }
    }
    dictReleaseIterator(di);
    return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x7b7f7
movq %rsi, %rbx
movq %rdi, %r14
movq 0x80(%rdi), %rdi
callq 0x320e5
movq %rax, %r15
movq %rax, %rdi
callq 0x32116
xorl %ebp, %ebp
testq %rax, %rax
je 0x7b7ed
movq 0x8(%rax), %r12
movq 0x10(%r12), %rdi
testq %rdi, %rdi
je 0x7b7e3
movq %rbx, %rsi
callq 0x26900
testl %eax, %eax
jne 0x7b7e3
movq 0x80(%r14), %rdi
movq 0x8(%r12), %rsi
callq 0x31dba
incl %ebp
movq %r15, %rdi
callq 0x32116
jmp 0x7b7b1
movq %r15, %rdi
callq 0x321d3
jmp 0x7b7f9
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelResetMaster
void sentinelResetMaster(sentinelRedisInstance *ri, int flags) {
    serverAssert(ri->flags & SRI_MASTER);
    dictRelease(ri->slaves);
    ri->slaves = dictCreate(&instancesDictType,NULL);
    if (!(flags & SENTINEL_RESET_NO_SENTINELS)) {
        dictRelease(ri->sentinels);
        ri->sentinels = dictCreate(&instancesDictType,NULL);
    }
    instanceLinkCloseConnection(ri->link,ri->link->cc);
    instanceLinkCloseConnection(ri->link,ri->link->pc);
    ri->flags &= SRI_MASTER;
    if (ri->leader) {
        sdsfree(ri->leader);
        ri->leader = NULL;
    }
    ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
    ri->failover_state_change_time = 0;
    ri->failover_start_time = 0; /* We can failover again ASAP. */
    ri->promoted_slave = NULL;
    sdsfree(ri->runid);
    sdsfree(ri->slave_master_host);
    ri->runid = NULL;
    ri->slave_master_host = NULL;
    ri->link->act_ping_time = mstime();
    ri->link->last_ping_time = 0;
    ri->link->last_avail_time = mstime();
    ri->link->last_pong_time = mstime();
    ri->role_reported_time = mstime();
    ri->role_reported = SRI_MASTER;
    if (flags & SENTINEL_GENERATE_EVENT)
        sentinelEvent(LL_WARNING,"+reset-master",ri,"%@");
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testb $0x1, (%rdi)
je 0x7b9e1
movl %esi, %ebp
movq %rdi, %rbx
movq 0x88(%rdi), %rdi
callq 0x31ff3
leaq 0x8a942(%rip), %rdi     # 0x106210
xorl %esi, %esi
callq 0x31774
movq %rax, 0x88(%rbx)
testb $0x1, %bpl
jne 0x7b903
movq 0x80(%rbx), %rdi
callq 0x31ff3
leaq 0x8a91b(%rip), %rdi     # 0x106210
xorl %esi, %esi
callq 0x31774
movq %rax, 0x80(%rbx)
movq 0x28(%rbx), %rdi
movq 0x10(%rdi), %rsi
callq 0x7b040
movq 0x28(%rbx), %rdi
movq 0x18(%rdi), %rsi
callq 0x7b040
andl $0x1, (%rbx)
movq 0xd8(%rbx), %rdi
testq %rdi, %rdi
je 0x7b93c
callq 0x392b6
movq $0x0, 0xd8(%rbx)
movl $0x0, 0xf0(%rbx)
xorl %r14d, %r14d
movq %r14, 0x118(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x392b6
movq 0xc0(%rbx), %rdi
callq 0x392b6
movq %r14, 0x10(%rbx)
movq %r14, 0xc0(%rbx)
callq 0x330c8
movq 0x28(%rbx), %rcx
movq %rax, 0x40(%rcx)
movq %r14, 0x48(%rcx)
callq 0x330c8
movq 0x28(%rbx), %rcx
movq %rax, 0x38(%rcx)
callq 0x330c8
movq 0x28(%rbx), %rcx
movq %rax, 0x50(%rcx)
callq 0x330c8
movq %rax, 0x70(%rbx)
movl $0x1, 0x68(%rbx)
btl $0x10, %ebp
jb 0x7b9c0
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x53a2b(%rip), %rsi     # 0xcf3f2
leaq 0x53a32(%rip), %rcx     # 0xcf400
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x7a50c
leaq 0x539e7(%rip), %rdi     # 0xcf3cf
leaq 0x53761(%rip), %rsi     # 0xcf150
movl $0x577, %edx            # imm = 0x577
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelSendAuthIfNeeded
void sentinelSendAuthIfNeeded(sentinelRedisInstance *ri, redisAsyncContext *c) {
    char *auth_pass = (ri->flags & SRI_MASTER) ? ri->auth_pass :
                                                 ri->master->auth_pass;

    if (auth_pass) {
        if (redisAsyncCommand(c, sentinelDiscardReplyCallback, ri, "AUTH %s",
            auth_pass) == C_OK) ri->link->pending_commands++;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testb $0x1, (%rdi)
movq %rdi, %rax
jne 0x7c7d1
movq 0xb8(%rbx), %rax
movq 0x98(%rax), %r8
testq %r8, %r8
je 0x7c806
leaq -0x16c5(%rip), %rax     # 0x7b11f
leaq 0x53092(%rip), %rcx     # 0xcf87d
movq %rsi, %rdi
movq %rax, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7c806
movq 0x28(%rbx), %rax
incl 0x8(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelSetClientName
void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char *type) {
    char name[64];

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdx, %r8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x53064(%rip), %rdx     # 0xcf885
leaq 0x9ee50(%rip), %rcx     # 0x11b678
movq %rsp, %r15
movl $0x40, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x26120
leaq -0x1722(%rip), %rsi     # 0x7b11f
leaq 0x5304e(%rip), %rcx     # 0xcf896
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7c863
movq 0x28(%rbx), %rax
incl 0x8(%rax)
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelSendPing
int sentinelSendPing(sentinelRedisInstance *ri) {
    int retval = redisAsyncCommand(ri->link->cc,
        sentinelPingReplyCallback, ri, "PING");
    if (retval == C_OK) {
        ri->link->pending_commands++;
        ri->link->last_ping_time = mstime();
        /* We update the active 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->link->act_ping_time == 0)
            ri->link->act_ping_time = ri->link->last_ping_time;
        return 1;
    } else {
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq 0x10(%rax), %rdi
leaq 0xcc2(%rip), %rsi       # 0x7d81d
leaq 0x4847b(%rip), %rcx     # 0xc4fdd
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7cb96
movq 0x28(%rbx), %rax
incl 0x8(%rax)
callq 0x330c8
movq 0x28(%rbx), %rcx
movq %rax, 0x48(%rcx)
movl $0x1, %ebp
cmpq $0x0, 0x40(%rcx)
jne 0x7cb96
movq %rax, 0x40(%rcx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelReceiveHelloMessages
void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = privdata;
    redisReply *r;
    UNUSED(c);

    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->link->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,sentinel.myid) != NULL) return;

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
jne 0x7cc1d
movq %rdx, %r14
movq %rsi, %rbx
callq 0x330c8
movq 0x28(%r14), %rcx
movq %rax, 0x30(%rcx)
cmpl $0x2, (%rbx)
jne 0x7cc1d
cmpq $0x3, 0x20(%rbx)
jne 0x7cc1d
movq 0x28(%rbx), %rcx
movq (%rcx), %rax
cmpl $0x1, (%rax)
jne 0x7cc1d
movq 0x8(%rcx), %rdx
cmpl $0x1, (%rdx)
jne 0x7cc1d
movq 0x10(%rcx), %r14
cmpl $0x1, (%r14)
jne 0x7cc1d
movq 0x18(%rax), %rdi
leaq 0x5313b(%rip), %rsi     # 0xcfd37
callq 0x26900
testl %eax, %eax
jne 0x7cc1d
movq 0x18(%r14), %rbx
leaq 0x9ea68(%rip), %rsi     # 0x11b678
movq %rbx, %rdi
callq 0x266c0
testq %rax, %rax
je 0x7cc25
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl 0x10(%r14), %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7d94b
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelForceHelloUpdateForMaster
int sentinelForceHelloUpdateForMaster(sentinelRedisInstance *master) {
    if (!(master->flags & SRI_MASTER)) return C_ERR;
    if (master->last_pub_time >= (SENTINEL_PUBLISH_PERIOD+1))
        master->last_pub_time -= (SENTINEL_PUBLISH_PERIOD+1);
    sentinelForceHelloUpdateDictOfRedisInstances(master->sentinels);
    sentinelForceHelloUpdateDictOfRedisInstances(master->slaves);
    return C_OK;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, (%rdi)
je 0x7d6cd
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rax
cmpq $0x7d1, %rax            # imm = 0x7D1
jl 0x7d6b2
addq $-0x7d1, %rax           # imm = 0xF82F
movq %rax, 0x30(%rbx)
movq 0x80(%rbx), %rdi
callq 0x7dda4
movq 0x88(%rbx), %rdi
callq 0x7dda4
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelInfoReplyCallback
void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = privdata;
    instanceLink *link = c->data;
    redisReply *r;

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

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

// Assembly:
movq 0xb0(%rdi), %rax
testq %rsi, %rsi
setne %cl
testq %rax, %rax
setne %dil
andb %cl, %dil
cmpb $0x1, %dil
jne 0x7d81c
decl 0x8(%rax)
cmpl $0x1, (%rsi)
jne 0x7d81c
movq 0x18(%rsi), %rsi
movq %rdx, %rdi
jmp 0x7cc6a
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelPingReplyCallback
void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = privdata;
    instanceLink *link = c->data;
    redisReply *r;

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

    if (r->type == REDIS_REPLY_STATUS ||
        r->type == REDIS_REPLY_ERROR) {
        /* Update the "instance available" field only if this is an
         * acceptable reply. */
        if (strncmp(r->str,"PONG",4) == 0 ||
            strncmp(r->str,"LOADING",7) == 0 ||
            strncmp(r->str,"MASTERDOWN",10) == 0)
        {
            link->last_avail_time = mstime();
            link->act_ping_time = 0; /* Flag the pong as received. */
        } else {
            /* Send a SCRIPT KILL command if the instance appears to be
             * down because of a busy script. */
            if (strncmp(r->str,"BUSY",4) == 0 &&
                (ri->flags & SRI_S_DOWN) &&
                !(ri->flags & SRI_SCRIPT_KILL_SENT))
            {
                if (redisAsyncCommand(ri->link->cc,
                        sentinelDiscardReplyCallback, ri,
                        "SCRIPT KILL") == C_OK)
                    ri->link->pending_commands++;
                ri->flags |= SRI_SCRIPT_KILL_SENT;
            }
        }
    }
    link->last_pong_time = mstime();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0xb0(%rdi), %r15
testq %rsi, %rsi
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7d914
decl 0x8(%r15)
movl (%rsi), %eax
addl $-0x5, %eax
cmpl $0x1, %eax
ja 0x7d90b
movq %rdx, %rbx
movq 0x18(%rsi), %r14
leaq 0x521f4(%rip), %rsi     # 0xcfa54
movl $0x4, %edx
movq %r14, %rdi
callq 0x26360
testl %eax, %eax
je 0x7d8fa
leaq 0x521dd(%rip), %rsi     # 0xcfa59
movl $0x7, %edx
movq %r14, %rdi
callq 0x26360
testl %eax, %eax
je 0x7d8fa
leaq 0x521cd(%rip), %rsi     # 0xcfa61
movl $0xa, %edx
movq %r14, %rdi
callq 0x26360
testl %eax, %eax
je 0x7d8fa
leaq 0x521c0(%rip), %rsi     # 0xcfa6c
movl $0x4, %edx
movq %r14, %rdi
callq 0x26360
testl %eax, %eax
jne 0x7d90b
movl $0x1008, %eax           # imm = 0x1008
andl (%rbx), %eax
cmpl $0x8, %eax
jne 0x7d90b
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rdi
leaq -0x27b9(%rip), %rsi     # 0x7b11f
leaq 0x52192(%rip), %rcx     # 0xcfa71
movq %rbx, %rdx
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7d8f4
movq 0x28(%rbx), %rax
incl 0x8(%rax)
orb $0x10, 0x1(%rbx)
jmp 0x7d90b
callq 0x330c8
movq %rax, 0x38(%r15)
movq $0x0, 0x40(%r15)
callq 0x330c8
movq %rax, 0x50(%r15)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelPublishReplyCallback
void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = privdata;
    instanceLink *link = c->data;
    redisReply *r;

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

    /* Only update pub_time if we actually published our message. Otherwise
     * we'll retry again in 100 milliseconds. */
    if (r->type != REDIS_REPLY_ERROR)
        ri->last_pub_time = mstime();
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
movq 0xb0(%rdi), %rax
testq %rsi, %rsi
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7d949
decl 0x8(%rax)
cmpl $0x6, (%rsi)
je 0x7d949
callq 0x330c8
movq %rax, 0x30(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelForceHelloUpdateDictOfRedisInstances
void sentinelForceHelloUpdateDictOfRedisInstances(dict *instances) {
    dictIterator *di;
    dictEntry *de;

    di = dictGetSafeIterator(instances);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);
        if (ri->last_pub_time >= (SENTINEL_PUBLISH_PERIOD+1))
            ri->last_pub_time -= (SENTINEL_PUBLISH_PERIOD+1);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %rbx
callq 0x320e5
movq %rax, %rbx
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7dddb
movq 0x8(%rax), %rax
movq 0x30(%rax), %rcx
cmpq $0x7d1, %rcx            # imm = 0x7D1
jl 0x7ddd6
addq $-0x7d1, %rcx           # imm = 0xF82F
movq %rcx, 0x30(%rax)
movq %rbx, %rdi
jmp 0x7ddb0
movq %rbx, %rdi
popq %rbx
jmp 0x321d3
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelIsQuorumReachable
int sentinelIsQuorumReachable(sentinelRedisInstance *master, int *usableptr) {
    dictIterator *di;
    dictEntry *de;
    int usable = 1; /* Number of usable Sentinels. Init to 1 to count myself. */
    int result = SENTINEL_ISQR_OK;
    int voters = dictSize(master->sentinels)+1; /* Known Sentinels + myself. */

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

        if (ri->flags & (SRI_S_DOWN|SRI_O_DOWN)) continue;
        usable++;
    }
    dictReleaseIterator(di);

    if (usable < (int)master->quorum) result |= SENTINEL_ISQR_NOQUORUM;
    if (usable < voters/2+1) result |= SENTINEL_ISQR_NOAUTH;
    if (usableptr) *usableptr = usable;
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x80(%rdi), %rdi
movq 0x28(%rdi), %r12
movq 0x48(%rdi), %r13
callq 0x320bb
movq %rax, %r15
movq %rax, %rdi
callq 0x32116
movl $0x1, %ebp
testq %rax, %rax
je 0x7e6a1
movq 0x8(%rax), %rax
movl (%rax), %eax
andl $0x18, %eax
cmpl $0x1, %eax
adcl $0x0, %ebp
movq %r15, %rdi
callq 0x32116
jmp 0x7e683
movq %r15, %rdi
callq 0x321d3
movl 0x90(%r14), %eax
testq %rbx, %rbx
je 0x7e6b7
movl %ebp, (%rbx)
leal (%r12,%r13), %ecx
leal (%r12,%r13), %edx
incl %edx
shrl $0x1f, %edx
addl %edx, %ecx
incl %ecx
sarl %ecx
xorl %edx, %edx
cmpl %eax, %ebp
setl %dl
leal 0x2(%rdx), %eax
cmpl %ecx, %ebp
cmovgl %edx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelStartFailover
void sentinelStartFailover(sentinelRedisInstance *master) {
    serverAssert(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(LL_WARNING,"+new-epoch",master,"%llu",
        (unsigned long long) sentinel.current_epoch);
    sentinelEvent(LL_WARNING,"+try-failover",master,"%@");
    master->failover_start_time = mstime()+rand()%SENTINEL_MAX_DESYNC;
    master->failover_state_change_time = mstime();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl (%rdi), %eax
testb $0x1, %al
je 0x7ea24
movq %rdi, %rbx
movl $0x1, 0xf0(%rdi)
orl $0x40, %eax
movl %eax, (%rdi)
movq 0x9cd1a(%rip), %r8      # 0x11b6a8
incq %r8
movq %r8, 0x9cd10(%rip)      # 0x11b6a8
movq %r8, 0xe8(%rdi)
leaq 0x51129(%rip), %rsi     # 0xcfacf
leaq 0x4c6b4(%rip), %rcx     # 0xcb061
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x7a50c
leaq 0x51a96(%rip), %rsi     # 0xd0459
leaq 0x50a36(%rip), %rcx     # 0xcf400
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x7a50c
callq 0x330c8
movq %rax, %r14
callq 0x26b80
cltq
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x26, %rcx
addl %edx, %ecx
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
cltq
addq %r14, %rax
movq %rax, 0x100(%rbx)
callq 0x330c8
movq %rax, 0xf8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x51a13(%rip), %rdi     # 0xd043e
leaq 0x5071e(%rip), %rsi     # 0xcf150
movl $0xed5, %edx            # imm = 0xED5
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelCheckObjectivelyDown
void sentinelCheckObjectivelyDown(sentinelRedisInstance *master) {
    dictIterator *di;
    dictEntry *de;
    unsigned int quorum = 0, odown = 0;

    if (master->flags & SRI_S_DOWN) {
        /* Is down for enough sentinels? */
        quorum = 1; /* the current sentinel. */
        /* Count all the other sentinels. */
        di = dictGetIterator(master->sentinels);
        while((de = dictNext(di)) != NULL) {
            sentinelRedisInstance *ri = dictGetVal(de);

            if (ri->flags & SRI_MASTER_DOWN) quorum++;
        }
        dictReleaseIterator(di);
        if (quorum >= master->quorum) odown = 1;
    }

    /* Set the flag accordingly to the outcome. */
    if (odown) {
        if ((master->flags & SRI_O_DOWN) == 0) {
            sentinelEvent(LL_WARNING,"+odown",master,"%@ #quorum %d/%d",
                quorum, master->quorum);
            master->flags |= SRI_O_DOWN;
            master->o_down_since_time = mstime();
        }
    } else {
        if (master->flags & SRI_O_DOWN) {
            sentinelEvent(LL_WARNING,"-odown",master,"%@");
            master->flags &= ~SRI_O_DOWN;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
testb $0x8, (%rdi)
jne 0x7ef41
xorl %ebp, %ebp
movb $0x1, %al
jmp 0x7ef88
movq 0x80(%rbx), %rdi
callq 0x320bb
movq %rax, %r14
movq %rax, %rdi
callq 0x32116
movl $0x1, %ebp
testq %rax, %rax
je 0x7ef77
movq 0x8(%rax), %rax
btl $0x5, (%rax)
adcl $0x0, %ebp
movq %r14, %rdi
callq 0x32116
jmp 0x7ef5d
movq %r14, %rdi
callq 0x321d3
cmpl 0x90(%rbx), %ebp
setb %al
movl (%rbx), %ecx
testb %al, %al
je 0x7efb5
testb $0x10, %cl
je 0x7efed
leaq 0x513b6(%rip), %rsi     # 0xd0350
leaq 0x5045f(%rip), %rcx     # 0xcf400
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x7a50c
andb $-0x11, (%rbx)
jmp 0x7efed
testb $0x10, %cl
jne 0x7efed
movl 0x90(%rbx), %r9d
leaq 0x51370(%rip), %rsi     # 0xd0338
leaq 0x51370(%rip), %rcx     # 0xd033f
movl $0x3, %edi
movq %rbx, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x7a50c
orb $0x10, (%rbx)
callq 0x330c8
movq %rax, 0x50(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelReceiveIsMasterDownReply
void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = privdata;
    instanceLink *link = c->data;
    redisReply *r;

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

    /* Ignore every error or unexpected reply.
     * Note that if the command returns an error for any reason we'll
     * end clearing the SRI_MASTER_DOWN flag for timeout anyway. */
    if (r->type == REDIS_REPLY_ARRAY && r->elements == 3 &&
        r->element[0]->type == REDIS_REPLY_INTEGER &&
        r->element[1]->type == REDIS_REPLY_STRING &&
        r->element[2]->type == REDIS_REPLY_INTEGER)
    {
        ri->last_master_down_reply_time = mstime();
        if (r->element[0]->integer == 1) {
            ri->flags |= SRI_MASTER_DOWN;
        } else {
            ri->flags &= ~SRI_MASTER_DOWN;
        }
        if (strcmp(r->element[1]->str,"*")) {
            /* If the runid in the reply is not "*" the Sentinel actually
             * replied with a vote. */
            sdsfree(ri->leader);
            if ((long long)ri->leader_epoch != r->element[2]->integer)
                serverLog(LL_WARNING,
                    "%s voted for %s %llu", ri->name,
                    r->element[1]->str,
                    (unsigned long long) r->element[2]->integer);
            ri->leader = sdsnew(r->element[1]->str);
            ri->leader_epoch = r->element[2]->integer;
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq 0xb0(%rdi), %rax
testq %rsi, %rsi
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7f104
movq %rsi, %r14
decl 0x8(%rax)
cmpl $0x2, (%rsi)
jne 0x7f104
cmpq $0x3, 0x20(%r14)
jne 0x7f104
movq 0x28(%r14), %rax
movq (%rax), %rcx
cmpl $0x3, (%rcx)
jne 0x7f104
movq 0x8(%rax), %rcx
cmpl $0x1, (%rcx)
jne 0x7f104
movq 0x10(%rax), %rax
cmpl $0x3, (%rax)
jne 0x7f104
callq 0x330c8
movq %rax, 0x40(%rbx)
movq 0x28(%r14), %rax
movq (%rax), %rcx
xorl %edx, %edx
cmpq $0x1, 0x8(%rcx)
sete %dl
movl (%rbx), %ecx
andl $-0x21, %ecx
shll $0x5, %edx
orl %ecx, %edx
movl %edx, (%rbx)
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x40af9(%rip), %rsi     # 0xbfb89
callq 0x26900
testl %eax, %eax
je 0x7f104
movq 0xd8(%rbx), %rdi
callq 0x392b6
movq 0x28(%r14), %rax
movq 0x10(%rax), %rcx
movq 0x8(%rcx), %r8
cmpq %r8, 0xe0(%rbx)
je 0x7f0d9
movq 0x8(%rbx), %rdx
movq 0x8(%rax), %rax
movq 0x18(%rax), %rcx
leaq 0x5128a(%rip), %rsi     # 0xd0357
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
movq 0x28(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x39245
movq %rax, 0xd8(%rbx)
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0xe0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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);
        serverAssert(de != NULL);
        dictSetUnsignedIntegerVal(de,1);
        return 1;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x31cca
testq %rax, %rax
je 0x7f260
movq %rax, %rcx
movq 0x8(%rax), %rax
incq %rax
movq %rax, 0x8(%rcx)
jmp 0x7f27d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x31ad8
testq %rax, %rax
je 0x7f285
movq $0x1, 0x8(%rax)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x44de5(%rip), %rdi     # 0xc4071
leaq 0x4febd(%rip), %rsi     # 0xcf150
movl $0xe44, %edx            # imm = 0xE44
callq 0x654e1
movl $0x1, %edi
callq 0x263d0
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 from 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; /* a > b */
    }

    /* 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. */
    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:
movq (%rdi), %rcx
movl 0xa8(%rcx), %eax
movq (%rsi), %rdx
subl 0xa8(%rdx), %eax
jne 0x7f56c
movq 0xd0(%rdx), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rsi, 0xd0(%rcx)
ja 0x7f56c
movl $0x1, %eax
jb 0x7f56c
movq 0x10(%rcx), %rdi
movq 0x10(%rdx), %rsi
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %r8b
xorl %ecx, %ecx
movq %rdi, %rdx
orq %rsi, %rdx
setne %dl
orb %al, %r8b
xorl %eax, %eax
movq %rdi, %r9
negq %r9
sbbl %eax, %eax
testb %r8b, %r8b
je 0x26300
movb %dl, %cl
orl %ecx, %eax
retq