// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/rdb.c
// Function: backgroundSaveDoneHandlerSocket
void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) {
    uint64_t *ok_slaves;

    if (!bysignal && exitcode == 0) {
        serverLog(LL_NOTICE,
            "Background RDB transfer terminated with success");
    } else if (!bysignal && exitcode != 0) {
        serverLog(LL_WARNING, "Background transfer error");
    } else {
        serverLog(LL_WARNING,
            "Background transfer terminated by signal %d", bysignal);
    }
    server.rdb_child_pid = -1;
    server.rdb_child_type = RDB_CHILD_TYPE_NONE;
    server.rdb_save_time_start = -1;

    /* If the child returns an OK exit code, read the set of slave client
     * IDs and the associated status code. We'll terminate all the slaves
     * in error state.
     *
     * If the process returned an error, consider the list of slaves that
     * can continue to be emtpy, so that it's just a special case of the
     * normal code path. */
    ok_slaves = zmalloc(sizeof(uint64_t)); /* Make space for the count. */
    ok_slaves[0] = 0;
    if (!bysignal && exitcode == 0) {
        int readlen = sizeof(uint64_t);

        if (read(server.rdb_pipe_read_result_from_child, ok_slaves, readlen) ==
                 readlen)
        {
            readlen = ok_slaves[0]*sizeof(uint64_t)*2;

            /* Make space for enough elements as specified by the first
             * uint64_t element in the array. */
            ok_slaves = zrealloc(ok_slaves,sizeof(uint64_t)+readlen);
            if (readlen &&
                read(server.rdb_pipe_read_result_from_child, ok_slaves+1,
                     readlen) != readlen)
            {
                ok_slaves[0] = 0;
            }
        }
    }

    close(server.rdb_pipe_read_result_from_child);
    close(server.rdb_pipe_write_result_to_parent);

    /* We can continue the replication process with all the slaves that
     * correctly received the full payload. Others are terminated. */
    listNode *ln;
    listIter li;

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

        if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_END) {
            uint64_t j;
            int errorcode = 0;

            /* Search for the slave ID in the reply. In order for a slave to
             * continue the replication process, we need to find it in the list,
             * and it must have an error code set to 0 (which means success). */
            for (j = 0; j < ok_slaves[0]; j++) {
                if (slave->id == ok_slaves[2*j+1]) {
                    errorcode = ok_slaves[2*j+2];
                    break; /* Found in slaves list. */
                }
            }
            if (j == ok_slaves[0] || errorcode != 0) {
                serverLog(LL_WARNING,
                "Closing slave %s: child->slave RDB transfer failed: %s",
                    replicationGetSlaveName(slave),
                    (errorcode == 0) ? "RDB transfer child aborted"
                                     : strerror(errorcode));
                freeClient(slave);
            } else {
                serverLog(LL_WARNING,
                "Slave %s correctly received the streamed RDB file.",
                    replicationGetSlaveName(slave));
                /* Restore the socket as non-blocking. */
                anetNonBlock(NULL,slave->fd);
                anetSendTimeout(NULL,slave->fd,0);
            }
        }
    }
    zfree(ok_slaves);

    updateSlavesWaitingBgsave((!bysignal && exitcode == 0) ? C_OK : C_ERR, RDB_CHILD_TYPE_SOCKET);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x56c6f
cmpl $0x0, -0x4(%rbp)
jne 0x56c6f
movl $0x2, %edi
leaq 0xe6a10(%rip), %rsi     # 0x13d676
movb $0x0, %al
callq 0x2fc60
jmp 0x56ca8
cmpl $0x0, -0x8(%rbp)
jne 0x56c90
cmpl $0x0, -0x4(%rbp)
je 0x56c90
movl $0x3, %edi
leaq 0xe6a1f(%rip), %rsi     # 0x13d6a6
movb $0x0, %al
callq 0x2fc60
jmp 0x56ca6
movl -0x8(%rbp), %edx
movl $0x3, %edi
leaq 0xe6a21(%rip), %rsi     # 0x13d6c0
movb $0x0, %al
callq 0x2fc60
jmp 0x56ca8
leaq 0x121529(%rip), %rax    # 0x1781d8
movl $0xffffffff, 0x730(%rax) # imm = 0xFFFFFFFF
leaq 0x121518(%rip), %rax    # 0x1781d8
movl $0x0, 0x77c(%rax)
leaq 0x121507(%rip), %rax    # 0x1781d8
movq $-0x1, 0x770(%rax)
movl $0x8, %edi
callq 0x3acd0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
cmpl $0x0, -0x8(%rbp)
jne 0x56d95
cmpl $0x0, -0x4(%rbp)
jne 0x56d95
movl $0x8, -0x14(%rbp)
leaq 0x1214c1(%rip), %rax    # 0x1781d8
movl 0x78c(%rax), %edi
movq -0x10(%rbp), %rsi
movslq -0x14(%rbp), %rdx
callq 0x26340
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
jne 0x56d93
movq -0x10(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
shlq %rax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rsi
addq $0x8, %rsi
callq 0x3ae40
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x56d91
leaq 0x121472(%rip), %rax    # 0x1781d8
movl 0x78c(%rax), %edi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
movslq -0x14(%rbp), %rdx
callq 0x26340
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0x56d91
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
jmp 0x56d93
jmp 0x56d95
leaq 0x12143c(%rip), %rax    # 0x1781d8
movl 0x78c(%rax), %edi
callq 0x26180
leaq 0x12142a(%rip), %rax    # 0x1781d8
movl 0x788(%rax), %edi
callq 0x26180
leaq 0x121418(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x27320
leaq -0x30(%rbp), %rdi
callq 0x27380
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x56f0c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x7, 0xa0(%rax)
jne 0x56f07
movl $0x0, -0x44(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x56e5e
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq %rdx
cmpq 0x8(%rcx,%rdx,8), %rax
jne 0x56e4e
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
movq 0x10(%rax,%rcx,8), %rax
movl %eax, -0x44(%rbp)
jmp 0x56e5e
jmp 0x56e50
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x56e13
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
je 0x56e71
cmpl $0x0, -0x44(%rbp)
je 0x56ec3
movq -0x38(%rbp), %rdi
callq 0x4d700
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x56e91
leaq 0xe6898(%rip), %rax     # 0x13d723
movq %rax, -0x58(%rbp)
jmp 0x56e9d
movl -0x44(%rbp), %edi
callq 0x26690
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x3, %edi
leaq 0xe683b(%rip), %rsi     # 0x13d6ec
movb $0x0, %al
callq 0x2fc60
movq -0x38(%rbp), %rdi
callq 0x43ea0
jmp 0x56f05
movq -0x38(%rbp), %rdi
callq 0x4d700
movq %rax, %rdx
movl $0x3, %edi
leaq 0xe6863(%rip), %rsi     # 0x13d73e
movb $0x0, %al
callq 0x2fc60
movq -0x38(%rbp), %rax
movl 0x8(%rax), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x2b860
movq -0x38(%rbp), %rax
movl 0x8(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rdi
callq 0x2bc40
jmp 0x56f07
jmp 0x56dd0
movq -0x10(%rbp), %rdi
callq 0x3afa0
xorl %eax, %eax
cmpl $0x0, -0x8(%rbp)
movb %al, -0x59(%rbp)
jne 0x56f2a
cmpl $0x0, -0x4(%rbp)
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %cl
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %eax, %eax
testb $0x1, %cl
cmovnel %eax, %edi
movl $0x2, %esi
callq 0x4f670
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)