// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelFailoverReconfNextSlave
void sentinelFailoverReconfNextSlave(sentinelRedisInstance *master) {
    dictIterator *di;
    dictEntry *de;
    int in_progress = 0;

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

        if (slave->flags & (SRI_RECONF_SENT|SRI_RECONF_INPROG))
            in_progress++;
    }
    dictReleaseIterator(di);

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

        /* Skip the promoted slave, and already configured slaves. */
        if (slave->flags & (SRI_PROMOTED|SRI_RECONF_DONE)) continue;

        /* If too much time elapsed without the slave moving forward to
         * the next state, consider it reconfigured even if it is not.
         * Sentinels will detect the slave as misconfigured and fix its
         * configuration later. */
        if ((slave->flags & SRI_RECONF_SENT) &&
            (mstime() - slave->slave_reconf_sent_time) >
            SENTINEL_SLAVE_RECONF_TIMEOUT)
        {
            sentinelEvent(LL_NOTICE,"-slave-reconf-sent-timeout",slave,"%@");
            slave->flags &= ~SRI_RECONF_SENT;
            slave->flags |= SRI_RECONF_DONE;
        }

        /* Nothing to do for instances that are disconnected or already
         * in RECONF_SENT state. */
        if (slave->flags & (SRI_RECONF_SENT|SRI_RECONF_INPROG)) continue;
        if (slave->link->disconnected) continue;

        /* Send SLAVEOF <new master>. */
        retval = sentinelSendSlaveOf(slave,
                master->promoted_slave->addr->ip,
                master->promoted_slave->addr->port);
        if (retval == C_OK) {
            slave->flags |= SRI_RECONF_SENT;
            slave->slave_reconf_sent_time = mstime();
            sentinelEvent(LL_NOTICE,"+slave-reconf-sent",slave,"%@");
            in_progress++;
        }
    }
    dictReleaseIterator(di);

    /* Check if all the slaves are reconfigured and handle timeout. */
    sentinelFailoverDetectEnd(master);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x88(%rdi), %rdi
callq 0x2a99f
movq %rax, %r14
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x6f558
movq 0x8(%rax), %rax
movb 0x1(%rax), %al
andb $0x3, %al
cmpb $0x1, %al
sbbl $-0x1, %r12d
jmp 0x6f53a
movq %r14, %rdi
callq 0x2aa94
movq 0x88(%rbx), %rdi
callq 0x2a99f
movq %rax, %r14
pushq $0x2
popq %rbp
leaq 0x4ed8a(%rip), %r13     # 0xbe303
cmpl 0x94(%rbx), %r12d
jge 0x6f653
movq %r14, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x6f653
movq 0x8(%rax), %r15
movl (%r15), %eax
testw $0x480, %ax             # imm = 0x480
jne 0x6f579
btl $0x8, %eax
jae 0x6f5eb
callq 0x2b8ae
subq 0xb0(%r15), %rax
cmpq $0x2710, %rax           # imm = 0x2710
jle 0x6f5e8
movl %ebp, %edi
movq %r13, %rsi
movq %r15, %rdx
leaq 0x4db7f(%rip), %rcx     # 0xbd14c
xorl %eax, %eax
callq 0x6a7bb
movl (%r15), %eax
movl $0xfffffaff, %ecx       # imm = 0xFFFFFAFF
andl %ecx, %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, (%r15)
jmp 0x6f5eb
movl (%r15), %eax
testw $0x300, %ax             # imm = 0x300
jne 0x6f579
movq 0x28(%r15), %rax
cmpl $0x0, 0x4(%rax)
jne 0x6f579
movq 0x118(%rbx), %rax
movq 0x20(%rax), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
movq %r15, %rdi
callq 0x6d3ed
testl %eax, %eax
jne 0x6f579
orb $0x1, 0x1(%r15)
callq 0x2b8ae
movq %rax, 0xb0(%r15)
movl %ebp, %edi
leaq 0x4ece4(%rip), %rsi     # 0xbe31e
movq %r15, %rdx
leaq 0x4db08(%rip), %rcx     # 0xbd14c
xorl %eax, %eax
callq 0x6a7bb
incl %r12d
jmp 0x6f579
movq %r14, %rdi
callq 0x2aa94
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6f3a5