// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelFailoverDetectEnd
void sentinelFailoverDetectEnd(sentinelRedisInstance *master) {
    int not_reconfigured = 0, timeout = 0;
    dictIterator *di;
    dictEntry *de;
    mstime_t elapsed = mstime() - master->failover_state_change_time;

    /* We can't consider failover finished if the promoted slave is
     * not reachable. */
    if (master->promoted_slave == NULL ||
        master->promoted_slave->flags & SRI_S_DOWN) return;

    /* The failover terminates once all the reachable slaves are properly
     * configured. */
    di = dictGetIterator(master->slaves);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *slave = dictGetVal(de);

        if (slave->flags & (SRI_PROMOTED|SRI_RECONF_DONE)) continue;
        if (slave->flags & SRI_S_DOWN) continue;
        not_reconfigured++;
    }
    dictReleaseIterator(di);

    /* Force end of failover on timeout. */
    if (elapsed > master->failover_timeout) {
        not_reconfigured = 0;
        timeout = 1;
        sentinelEvent(LL_WARNING,"+failover-end-for-timeout",master,"%@");
    }

    if (not_reconfigured == 0) {
        sentinelEvent(LL_WARNING,"+failover-end",master,"%@");
        master->failover_state = SENTINEL_FAILOVER_STATE_UPDATE_CONFIG;
        master->failover_state_change_time = mstime();
    }

    /* If I'm the leader it is a good idea to send a best effort SLAVEOF
     * command to all the slaves still not reconfigured to replicate with
     * the new master. */
    if (timeout) {
        dictIterator *di;
        dictEntry *de;

        di = dictGetIterator(master->slaves);
        while((de = dictNext(di)) != NULL) {
            sentinelRedisInstance *slave = dictGetVal(de);
            int retval;

            if (slave->flags & (SRI_RECONF_DONE|SRI_RECONF_SENT)) continue;
            if (slave->link->disconnected) continue;

            retval = sentinelSendSlaveOf(slave,
                    master->promoted_slave->addr->ip,
                    master->promoted_slave->addr->port);
            if (retval == C_OK) {
                sentinelEvent(LL_NOTICE,"+slave-reconf-sent-be",slave,"%@");
                slave->flags |= SRI_RECONF_SENT;
            }
        }
        dictReleaseIterator(di);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
callq 0x2ff70
movq -0x8(%rbp), %rcx
subq 0xf8(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x118(%rax)
je 0x9c1d1
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9c1d6
jmp 0x9c394
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x2e400
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2e4a0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x9c236
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x480, %eax            # imm = 0x480
cmpl $0x0, %eax
je 0x9c21b
jmp 0x9c1ea
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9c22b
jmp 0x9c1ea
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9c1ea
movq -0x18(%rbp), %rdi
callq 0x2e600
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x108(%rcx), %rax
jle 0x9c27c
movl $0x0, -0xc(%rbp)
movl $0x1, -0x10(%rbp)
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0xab117(%rip), %rsi     # 0x147385
leaq 0xa9f97(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
cmpl $0x0, -0xc(%rbp)
jne 0x9c2c1
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0xab10d(%rip), %rsi     # 0x14739f
leaq 0xa9f73(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
movq -0x8(%rbp), %rax
movl $0x6, 0xf0(%rax)
callq 0x2ff70
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xf8(%rax)
cmpl $0x0, -0x10(%rbp)
je 0x9c394
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x2e400
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2e4a0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x9c38b
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
andl $0x500, %eax            # imm = 0x500
cmpl $0x0, %eax
je 0x9c314
jmp 0x9c2df
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x0, 0x4(%rax)
je 0x9c324
jmp 0x9c2df
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rax
movq 0x20(%rax), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %edx
callq 0x98fc0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x9c386
movq -0x48(%rbp), %rdx
movl $0x2, %edi
leaq 0xab043(%rip), %rsi     # 0x1473ad
leaq 0xa9e9b(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
movq -0x48(%rbp), %rax
movl (%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, (%rax)
jmp 0x9c2df
movq -0x38(%rbp), %rdi
callq 0x2e600
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)