// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0x320bb
movq %rax, %r14
movq %rax, %rdi
callq 0x32116
xorl %r15d, %r15d
testq %rax, %rax
je 0x7fa5f
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 0x32116
testq %rax, %rax
jne 0x7fa43
movq %r14, %rdi
callq 0x321d3
movq 0x88(%rbx), %rdi
callq 0x320bb
movq %rax, %r14
cmpl 0x94(%rbx), %r15d
jge 0x7fb5b
leaq 0x4f976(%rip), %r12     # 0xcf400
leaq 0x50b26(%rip), %r13     # 0xd05b7
movq %r14, %rdi
callq 0x32116
testq %rax, %rax
je 0x7fb5b
movq 0x8(%rax), %rbp
movl (%rbp), %eax
testl $0x480, %eax            # imm = 0x480
jne 0x7fb4e
btl $0x8, %eax
jae 0x7faf5
callq 0x330c8
subq 0xb0(%rbp), %rax
cmpq $0x2711, %rax           # imm = 0x2711
jl 0x7faf5
movl $0x2, %edi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x7a50c
movl (%rbp), %eax
movl $0xfffffaff, %ecx       # imm = 0xFFFFFAFF
andl %ecx, %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, (%rbp)
testb $0x3, 0x1(%rbp)
jne 0x7fb4e
movq 0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x7fb4e
movq 0x118(%rbx), %rax
movq 0x20(%rax), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
movq %rbp, %rdi
callq 0x7d6ce
testl %eax, %eax
jne 0x7fb4e
orb $0x1, 0x1(%rbp)
callq 0x330c8
movq %rax, 0xb0(%rbp)
movl $0x2, %edi
leaq 0x50a94(%rip), %rsi     # 0xd05d2
movq %rbp, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x7a50c
incl %r15d
cmpl 0x94(%rbx), %r15d
jl 0x7fa91
movq %r14, %rdi
callq 0x321d3
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7f880