// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/replication.c
// Function: updateSlavesWaitingBgsave
void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
    listNode *ln;
    int startbgsave = 0;
    int mincapa = -1;
    listIter li;

    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        client *slave = ln->value;

        if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) {
            startbgsave = 1;
            mincapa = (mincapa == -1) ? slave->slave_capa :
                                        (mincapa & slave->slave_capa);
        } else if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_END) {
            struct redis_stat buf;

            /* If this was an RDB on disk save, we have to prepare to send
             * the RDB from disk to the slave socket. Otherwise if this was
             * already an RDB -> Slaves socket transfer, used in the case of
             * diskless replication, our work is trivial, we can just put
             * the slave online. */
            if (type == RDB_CHILD_TYPE_SOCKET) {
                serverLog(LL_NOTICE,
                    "Streamed RDB transfer with slave %s succeeded (socket). Waiting for REPLCONF ACK from slave to enable streaming",
                        replicationGetSlaveName(slave));
                /* Note: we wait for a REPLCONF ACK message from slave in
                 * order to really put it online (install the write handler
                 * so that the accumulated data can be transfered). However
                 * we change the replication state ASAP, since our slave
                 * is technically online now. */
                slave->replstate = SLAVE_STATE_ONLINE;
                slave->repl_put_online_on_ack = 1;
                slave->repl_ack_time = server.unixtime; /* Timeout otherwise. */
            } else {
                if (bgsaveerr != C_OK) {
                    freeClient(slave);
                    serverLog(LL_WARNING,"SYNC failed. BGSAVE child returned an error");
                    continue;
                }
                if ((slave->repldbfd = open(server.rdb_filename,O_RDONLY)) == -1 ||
                    redis_fstat(slave->repldbfd,&buf) == -1) {
                    freeClient(slave);
                    serverLog(LL_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno));
                    continue;
                }
                slave->repldboff = 0;
                slave->repldbsize = buf.st_size;
                slave->replstate = SLAVE_STATE_SEND_BULK;
                slave->replpreamble = sdscatprintf(sdsempty(),"$%lld\r\n",
                    (unsigned long long) slave->repldbsize);

                aeDeleteFileEvent(server.el,slave->fd,AE_WRITABLE);
                if (aeCreateFileEvent(server.el, slave->fd, AE_WRITABLE, sendBulkToSlave, slave) == AE_ERR) {
                    freeClient(slave);
                    continue;
                }
            }
        }
    }
    if (startbgsave) startBgsaveForReplication(mincapa);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x0, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
leaq 0x128b42(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x27320
leaq -0x28(%rbp), %rdi
callq 0x27380
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x4f8dd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x6, 0xa0(%rax)
jne 0x4f716
movl $0x1, -0x14(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x4f6f5
movq -0x30(%rbp), %rax
movl 0x148(%rax), %eax
movl %eax, -0xc4(%rbp)
jmp 0x4f708
movl -0x18(%rbp), %eax
movq -0x30(%rbp), %rcx
andl 0x148(%rcx), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x4f8d8
movq -0x30(%rbp), %rax
cmpl $0x7, 0xa0(%rax)
jne 0x4f8d6
cmpl $0x2, -0x8(%rbp)
jne 0x4f786
movq -0x30(%rbp), %rdi
callq 0x4d700
movq %rax, %rdx
movl $0x2, %edi
leaq 0xecaef(%rip), %rsi     # 0x13c234
movb $0x0, %al
callq 0x2fc60
movq -0x30(%rbp), %rax
movl $0x9, 0xa0(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0xa4(%rax)
leaq 0x128a69(%rip), %rax    # 0x1781d8
movq 0x978(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xd8(%rax)
jmp 0x4f8d4
cmpl $0x0, -0x4(%rbp)
je 0x4f7ad
movq -0x30(%rbp), %rdi
callq 0x43ea0
movl $0x3, %edi
leaq 0xecb03(%rip), %rsi     # 0x13c2a4
movb $0x0, %al
callq 0x2fc60
jmp 0x4f6a6
leaq 0x128a24(%rip), %rax    # 0x1781d8
movq 0x748(%rax), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x266a0
movq -0x30(%rbp), %rcx
movl %eax, 0xa8(%rcx)
cmpl $-0x1, %eax
je 0x4f7ee
movq -0x30(%rbp), %rax
movl 0xa8(%rax), %edi
leaq -0xc0(%rbp), %rsi
callq 0x266f0
cmpl $-0x1, %eax
jne 0x4f81e
movq -0x30(%rbp), %rdi
callq 0x43ea0
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xecabe(%rip), %rsi     # 0x13c2d0
movb $0x0, %al
callq 0x2fc60
jmp 0x4f6a6
movq -0x30(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x30(%rbp), %rax
movl $0x8, 0xa0(%rax)
callq 0x384f0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq 0xb8(%rax), %rdx
leaq 0xeca9a(%rip), %rsi     # 0x13c301
movb $0x0, %al
callq 0x395b0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xc0(%rax)
leaq 0x128955(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x2, %edx
callq 0x2aab0
leaq 0x128939(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %r8
movl $0x2, %edx
leaq -0x51a(%rip), %rcx      # 0x4f3a0
callq 0x2a8f0
cmpl $-0x1, %eax
jne 0x4f8d2
movq -0x30(%rbp), %rdi
callq 0x43ea0
jmp 0x4f6a6
jmp 0x4f8d4
jmp 0x4f8d6
jmp 0x4f8d8
jmp 0x4f6a6
cmpl $0x0, -0x14(%rbp)
je 0x4f8eb
movl -0x18(%rbp), %edi
callq 0x4e920
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)