// File: /workspace/github_c_makefile_star2_O3/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 0x2efbb
movq %rax, %r14
movq %rax, %rdi
callq 0x2f015
xorl %r15d, %r15d
testq %rax, %rax
je 0x7bff3
movl $0x300, %ebp            # imm = 0x300
movq 0x8(%rax), %rax
movl (%rax), %eax
andl %ebp, %eax
cmpl $0x1, %eax
sbbl $-0x1, %r15d
movq %r14, %rdi
callq 0x2f015
testq %rax, %rax
jne 0x7bfd7
movq %r14, %rdi
callq 0x2f0dd
movq 0x88(%rbx), %rdi
callq 0x2efbb
movq %rax, %r14
cmpl 0x94(%rbx), %r15d
jge 0x7c0f5
leaq 0x504e2(%rip), %r12     # 0xcc500
leaq 0x51692(%rip), %r13     # 0xcd6b7
movq %r14, %rdi
callq 0x2f015
testq %rax, %rax
je 0x7c0f5
movq 0x8(%rax), %rbp
movl (%rbp), %eax
testl $0x480, %eax            # imm = 0x480
jne 0x7c0e8
btl $0x8, %eax
jae 0x7c08e
callq 0x2ffce
subq 0xb0(%rbp), %rax
cmpq $0x2710, %rax           # imm = 0x2710
jle 0x7c08b
movl $0x2, %edi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x76a24
movl (%rbp), %eax
movl $0xfffffaff, %ecx       # imm = 0xFFFFFAFF
andl %ecx, %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, (%rbp)
jmp 0x7c08e
movl (%rbp), %eax
testl $0x300, %eax            # imm = 0x300
jne 0x7c0e8
movq 0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x7c0e8
movq 0x118(%rbx), %rax
movq 0x20(%rax), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
movq %rbp, %rdi
callq 0x79c10
testl %eax, %eax
jne 0x7c0e8
orb $0x1, 0x1(%rbp)
callq 0x2ffce
movq %rax, 0xb0(%rbp)
movl $0x2, %edi
leaq 0x515fa(%rip), %rsi     # 0xcd6d2
movq %rbp, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x76a24
incl %r15d
cmpl 0x94(%rbx), %r15d
jl 0x7c025
movq %r14, %rdi
callq 0x2f0dd
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7bdd2