// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/replication.c
// Function: startBgsaveForReplication
int startBgsaveForReplication(int mincapa) {
    int retval;
    int socket_target = server.repl_diskless_sync && (mincapa & SLAVE_CAPA_EOF);
    listIter li;
    listNode *ln;

    serverLog(LL_NOTICE,"Starting BGSAVE for SYNC with target: %s",
        socket_target ? "slaves sockets" : "disk");

    if (socket_target)
        retval = rdbSaveToSlavesSockets();
    else
        retval = rdbSaveBackground(server.rdb_filename);

    /* If we failed to BGSAVE, remove the slaves waiting for a full
     * resynchorinization from the list of salves, inform them with
     * an error about what happened, close the connection ASAP. */
    if (retval == C_ERR) {
        serverLog(LL_WARNING,"BGSAVE for replication failed");
        listRewind(server.slaves,&li);
        while((ln = listNext(&li))) {
            client *slave = ln->value;

            if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) {
                slave->flags &= ~CLIENT_SLAVE;
                listDelNode(server.slaves,ln);
                addReplyError(slave,
                    "BGSAVE failed, replication can't continue");
                slave->flags |= CLIENT_CLOSE_AFTER_REPLY;
            }
        }
        return retval;
    }

    /* If the target is socket, rdbSaveToSlavesSockets() already setup
     * the salves for a full resync. Otherwise for disk target do it now.*/
    if (!socket_target) {
        listRewind(server.slaves,&li);
        while((ln = listNext(&li))) {
            client *slave = ln->value;

            if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) {
                    replicationSetupSlaveForFullResync(slave,
                            getPsyncInitialOffset());
            }
        }
    }

    /* Flush the script cache, since we need that slave differences are
     * accumulated without requiring slaves to match our cached scripts. */
    if (retval == C_OK) replicationScriptCacheFlush();
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
xorl %eax, %eax
leaq 0x1298a4(%rip), %rcx    # 0x1781d8
cmpl $0x0, 0x814(%rcx)
movb %al, -0x39(%rbp)
je 0x4e94f
movl -0x8(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
leaq 0xedcaf(%rip), %rdx     # 0x13c613
leaq 0xed550(%rip), %rax     # 0x13bebb
cmpl $0x0, %ecx
cmovneq %rax, %rdx
movl $0x2, %edi
leaq 0xed514(%rip), %rsi     # 0x13be92
movb $0x0, %al
callq 0x2fc60
cmpl $0x0, -0x10(%rbp)
je 0x4e995
callq 0x56fd0
movl %eax, -0xc(%rbp)
jmp 0x4e9ab
leaq 0x12983c(%rip), %rax    # 0x1781d8
movq 0x748(%rax), %rdi
callq 0x55360
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x4ea62
movl $0x3, %edi
leaq 0xed509(%rip), %rsi     # 0x13beca
movb $0x0, %al
callq 0x2fc60
leaq 0x129809(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x27320
leaq -0x20(%rbp), %rdi
callq 0x27380
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x4ea5a
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x6, 0xa0(%rax)
jne 0x4ea58
movq -0x30(%rbp), %rax
movl 0x98(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x98(%rax)
leaq 0x1297b3(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x271e0
movq -0x30(%rbp), %rdi
leaq 0xed4a8(%rip), %rsi     # 0x13bee8
callq 0x42f90
movq -0x30(%rbp), %rax
movl 0x98(%rax), %ecx
orl $0x40, %ecx
movl %ecx, 0x98(%rax)
jmp 0x4e9df
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4ead9
cmpl $0x0, -0x10(%rbp)
jne 0x4eac8
leaq 0x129769(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x27320
leaq -0x20(%rbp), %rdi
callq 0x27380
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x4eac6
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x6, 0xa0(%rax)
jne 0x4eac4
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x4e4c0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x4e500
jmp 0x4ea7f
jmp 0x4eac8
cmpl $0x0, -0xc(%rbp)
jne 0x4ead3
callq 0x4eaf0
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)