// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 0x2b8ae
movq 0x28(%rbx), %rdx
cmpl $0x0, 0x4(%rdx)
jne 0x6db87
movq %rax, %rcx
imull $0x64, (%rdx), %eax
cmpl %eax, 0x8(%rdx)
jge 0x6db87
movl (%rbx), %edi
testb $0x2, %dil
jne 0x6dacd
movl $0x2710, %esi           # imm = 0x2710
jmp 0x6dae8
movq 0xb8(%rbx), %rax
movl $0x3e8, %esi            # imm = 0x3E8
testb $0x50, (%rax)
jne 0x6dae8
cmpq $0x0, 0xa0(%rbx)
je 0x6dac6
movq 0x58(%rbx), %r8
movl $0x3e8, %eax            # imm = 0x3E8
cmpq %rax, %r8
cmovlq %r8, %rax
testb $0x4, %dil
jne 0x6db48
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
sete %r8b
movq %rcx, %r9
subq %rdi, %r9
cmpq %rsi, %r9
setg %sil
orb %r8b, %sil
cmpb $0x1, %sil
jne 0x6db48
movq 0x10(%rdx), %rdi
leaq -0x624(%rip), %rsi      # 0x6d506
leaq 0x4fd51(%rip), %rcx     # 0xbd882
movq %rbx, %rdx
xorl %eax, %eax
callq 0x7597e
testl %eax, %eax
jne 0x6db87
movq 0x28(%rbx), %rax
incl 0x8(%rax)
jmp 0x6db87
movq %rcx, %rsi
subq 0x50(%rdx), %rsi
cmpq %rax, %rsi
jle 0x6db71
movq %rcx, %rsi
subq 0x48(%rdx), %rsi
pushq $0x2
popq %rdi
cqto
idivq %rdi
cmpq %rax, %rsi
jle 0x6db71
movq %rbx, %rdi
popq %rbx
jmp 0x6cab2
subq 0x30(%rbx), %rcx
cmpq $0x7d1, %rcx            # imm = 0x7D1
jl 0x6db87
movq %rbx, %rdi
popq %rbx
jmp 0x6d944
popq %rbx
retq