// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelSendPeriodicCommands
void sentinelSendPeriodicCommands(sentinelRedisInstance *ri) {
    mstime_t now = mstime();
    mstime_t info_period, ping_period;
    int retval;

    /* Return ASAP if we have already a PING or INFO already pending, or
     * in the case the instance is not properly connected. */
    if (ri->link->disconnected) return;

    /* For INFO, PING, PUBLISH that are not critical commands to send we
     * also have a limit of SENTINEL_MAX_PENDING_COMMANDS. We don't
     * want to use a lot of memory just because a link is not working
     * properly (note that anyway there is a redundant protection about this,
     * that is, the link will be disconnected and reconnected if a long
     * timeout condition is detected. */
    if (ri->link->pending_commands >=
        SENTINEL_MAX_PENDING_COMMANDS * ri->link->refcount) return;

    /* If this is a slave of a master in O_DOWN condition we start sending
     * it INFO every second, instead of the usual SENTINEL_INFO_PERIOD
     * period. In this state we want to closely monitor slaves in case they
     * are turned into masters by another Sentinel, or by the sysadmin.
     *
     * Similarly we monitor the INFO output more often if the slave reports
     * to be disconnected from the master, so that we can have a fresh
     * disconnection time figure. */
    if ((ri->flags & SRI_SLAVE) &&
        ((ri->master->flags & (SRI_O_DOWN|SRI_FAILOVER_IN_PROGRESS)) ||
         (ri->master_link_down_time != 0)))
    {
        info_period = 1000;
    } else {
        info_period = SENTINEL_INFO_PERIOD;
    }

    /* We ping instances every time the last received pong is older than
     * the configured 'down-after-milliseconds' time, but every second
     * anyway if 'down-after-milliseconds' is greater than 1 second. */
    ping_period = ri->down_after_period;
    if (ping_period > SENTINEL_PING_PERIOD) ping_period = SENTINEL_PING_PERIOD;

    if ((ri->flags & SRI_SENTINEL) == 0 &&
        (ri->info_refresh == 0 ||
        (now - ri->info_refresh) > info_period))
    {
        /* Send INFO to masters and slaves, not sentinels. */
        retval = redisAsyncCommand(ri->link->cc,
            sentinelInfoReplyCallback, ri, "INFO");
        if (retval == C_OK) ri->link->pending_commands++;
    } else if ((now - ri->link->last_pong_time) > ping_period &&
               (now - ri->link->last_ping_time) > ping_period/2) {
        /* Send PING to all the three kinds of instances. */
        sentinelSendPing(ri);
    } else if ((now - ri->last_pub_time) > SENTINEL_PUBLISH_PERIOD) {
        /* PUBLISH hello messages to all the three kinds of instances. */
        sentinelSendHello(ri);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x330c8
movq 0x28(%rbx), %rcx
cmpl $0x0, 0x4(%rcx)
jne 0x7ded4
imull $0x64, (%rcx), %edx
cmpl %edx, 0x8(%rcx)
jge 0x7ded4
movl (%rbx), %edi
testb $0x2, %dil
jne 0x7de16
movl $0x2710, %esi           # imm = 0x2710
jmp 0x7de31
movq 0xb8(%rbx), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
testb $0x50, (%rdx)
jne 0x7de31
cmpq $0x0, 0xa0(%rbx)
je 0x7de0f
movq 0x58(%rbx), %r8
movl $0x3e8, %edx            # imm = 0x3E8
cmpq %rdx, %r8
cmovlq %r8, %rdx
testb $0x4, %dil
jne 0x7de91
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
sete %r8b
movq %rax, %r9
subq %rdi, %r9
cmpq %rsi, %r9
setg %sil
orb %r8b, %sil
cmpb $0x1, %sil
jne 0x7de91
movq 0x10(%rcx), %rdi
leaq -0x688(%rip), %rsi      # 0x7d7eb
leaq 0x51cbc(%rip), %rcx     # 0xcfb36
movq %rbx, %rdx
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7ded4
movq 0x28(%rbx), %rax
incl 0x8(%rax)
jmp 0x7ded4
movq %rax, %rsi
subq 0x50(%rcx), %rsi
cmpq %rdx, %rsi
jle 0x7debf
movq %rax, %rsi
subq 0x48(%rcx), %rsi
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
cmpq %rcx, %rsi
jle 0x7debf
movq %rbx, %rdi
popq %rbx
jmp 0x7cb46
subq 0x30(%rbx), %rax
cmpq $0x7d1, %rax            # imm = 0x7D1
jl 0x7ded4
movq %rbx, %rdi
popq %rbx
jmp 0x7dc6b
popq %rbx
retq