// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
orl %edi, %ebp
je 0x42b43
movl %esi, %edx
testl %esi, %esi
setne %al
testl %edi, %edi
sete %cl
orb %al, %cl
jne 0x42b56
leaq 0x71a94(%rip), %rsi     # 0xb45d3
pushq $0x3
jmp 0x42b4c
leaq 0x71a59(%rip), %rsi     # 0xb45a3
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2b699
jmp 0x42b67
leaq 0x71a90(%rip), %rsi     # 0xb45ed
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x2b699
leaq 0xb6d3a(%rip), %r15     # 0xf98a8
orl $-0x1, 0x730(%r15)
andl $0x0, 0x77c(%r15)
orq $-0x1, 0x770(%r15)
pushq $0x8
popq %rdi
callq 0x327b9
movq %rax, %rbx
andq $0x0, (%rax)
testl %ebp, %ebp
movl %ebp, 0x4(%rsp)
jne 0x42bf0
movl 0x78c(%r15), %edi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x26340
cmpq $0x8, %rax
jne 0x42bf0
movl (%rbx), %eax
shll $0x4, %eax
movslq %eax, %r14
leaq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x32863
movq %rax, %rbx
testl %r14d, %r14d
je 0x42bf0
movl 0x78c(%r15), %edi
movq %rbx, %rsi
addq $0x8, %rsi
movq %r14, %rdx
callq 0x26340
cmpq %r14, %rax
je 0x42bf0
andq $0x0, (%rbx)
movl 0x78c(%r15), %edi
callq 0x26180
movl 0x788(%r15), %edi
callq 0x26180
movq 0x1e0(%r15), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x2702c
leaq 0x10(%rbx), %rbp
movq %r14, %rdi
callq 0x27046
testq %rax, %rax
je 0x42cf8
movq 0x10(%rax), %r13
cmpl $0x7, 0xa0(%r13)
jne 0x42c20
movq (%rbx), %rcx
movq %rbp, %rax
movq %rcx, %rdx
subq $0x1, %rdx
jb 0x42c61
movq (%r13), %rsi
cmpq -0x8(%rax), %rsi
je 0x42c66
addq $0x10, %rax
movq %rdx, %rcx
jmp 0x42c48
xorl %r12d, %r12d
jmp 0x42c7c
movq (%rax), %r12
testq %rcx, %rcx
sete %al
testl %r12d, %r12d
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x42cbf
movq %r13, %rdi
callq 0x3cc38
movq %rax, %r15
leaq 0x719c2(%rip), %rcx     # 0xb4650
testl %r12d, %r12d
je 0x42c9e
movl %r12d, %edi
callq 0x26680
movq %rax, %rcx
pushq $0x3
popq %rdi
leaq 0x71971(%rip), %rsi     # 0xb4619
movq %r15, %rdx
xorl %eax, %eax
callq 0x2b699
movq %r13, %rdi
callq 0x37527
jmp 0x42c20
movq %r13, %rdi
callq 0x3cc38
pushq $0x3
popq %rdi
leaq 0x7199a(%rip), %rsi     # 0xb466b
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
movl 0x8(%r13), %esi
xorl %edi, %edi
callq 0x2929c
movl 0x8(%r13), %esi
xorl %edi, %edi
xorl %edx, %edx
callq 0x294a4
jmp 0x42c20
movq %rbx, %rdi
callq 0x328f9
xorl %edi, %edi
negl 0x4(%rsp)
sbbl %edi, %edi
pushq $0x2
popq %rsi
callq 0x3e097
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq