// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
callq 0x2ff70
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x0, 0x4(%rax)
je 0x99a48
jmp 0x99ba4
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
imull $0x64, (%rcx), %ecx
cmpl %ecx, %eax
jl 0x99a67
jmp 0x99ba4
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x99aa2
movq -0x8(%rbp), %rax
movq 0xb8(%rax), %rax
movl (%rax), %eax
andl $0x50, %eax
cmpl $0x0, %eax
jne 0x99a98
movq -0x8(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x99aa2
movq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
jmp 0x99aaa
movq $0x2710, -0x18(%rbp)    # imm = 0x2710
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x3e8, -0x20(%rbp)     # imm = 0x3E8
jle 0x99ac8
movq $0x3e8, -0x20(%rbp)     # imm = 0x3E8
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x99b34
movq -0x8(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x99af3
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
subq 0x60(%rcx), %rax
cmpq -0x18(%rbp), %rax
jle 0x99b34
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rdx
leaq -0x97a(%rip), %rsi      # 0x99190
leaq 0xace31(%rip), %rcx     # 0x146942
movb $0x0, %al
callq 0xa6e80
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x99b32
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x99ba4
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq 0x50(%rcx), %rax
cmpq -0x20(%rbp), %rax
jle 0x99b83
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq 0x48(%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jle 0x99b83
movq -0x8(%rbp), %rdi
callq 0x98160
jmp 0x99ba2
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
subq 0x30(%rcx), %rax
cmpq $0x7d0, %rax            # imm = 0x7D0
jle 0x99ba0
movq -0x8(%rbp), %rdi
callq 0x997b0
jmp 0x99ba2
jmp 0x99ba4
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)