// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/rdb.c
// Function: rdbSaveBackground
int rdbSaveBackground(char *filename) {
    pid_t childpid;
    long long start;

    if (server.aof_child_pid != -1 || server.rdb_child_pid != -1) return C_ERR;

    server.dirty_before_bgsave = server.dirty;
    server.lastbgsave_try = time(NULL);

    start = ustime();
    if ((childpid = fork()) == 0) {
        int retval;

        /* Child */
        closeListeningSockets(0);
        redisSetProcTitle("redis-rdb-bgsave");
        retval = rdbSave(filename);
        if (retval == C_OK) {
            size_t private_dirty = zmalloc_get_private_dirty();

            if (private_dirty) {
                serverLog(LL_NOTICE,
                    "RDB: %zu MB of memory used by copy-on-write",
                    private_dirty/(1024*1024));
            }
        }
        exitFromChild((retval == C_OK) ? 0 : 1);
    } else {
        /* Parent */
        server.stat_fork_time = ustime()-start;
        server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */
        latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000);
        if (childpid == -1) {
            server.lastbgsave_status = C_ERR;
            serverLog(LL_WARNING,"Can't save in background: fork: %s",
                strerror(errno));
            return C_ERR;
        }
        serverLog(LL_NOTICE,"Background saving started by pid %d",childpid);
        server.rdb_save_time_start = time(NULL);
        server.rdb_child_pid = childpid;
        server.rdb_child_type = RDB_CHILD_TYPE_DISK;
        updateDictResizePolicy();
        return C_OK;
    }
    return C_OK; /* unreached */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0xb9aae(%rip), %r12     # 0x106858
cmpl $-0x1, 0x68c(%r12)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x4cf77
cmpl $-0x1, 0x720(%r12)
jne 0x4cf77
movq %rdi, %r14
movq 0x710(%r12), %rax
movq %rax, 0x718(%r12)
xorl %edi, %edi
callq 0x26ce0
movq %rax, 0x750(%r12)
callq 0x330a5
movq %rax, %r15
callq 0x26ac0
testl %eax, %eax
je 0x4cef3
movl %eax, %ebp
callq 0x330a5
subq %r15, %rax
movq %rax, 0x3b8(%r12)
callq 0x3b446
movq %rax, %xmm0
punpckldq 0x78ab8(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x78ac0(%rip), %xmm0    # 0xc58f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x78abc(%rip), %xmm1    # 0xc5900
movq 0x3b8(%r12), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
mulsd 0x72690(%rip), %xmm1    # 0xbf4f0
movsd %xmm1, 0x3c0(%r12)
movq 0xa08(%r12), %rcx
testq %rcx, %rcx
je 0x4cea6
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
cmpq %rcx, %rdx
jl 0x4cea6
leaq 0x78cd0(%rip), %rdi     # 0xc5b6e
movq %rdx, %rsi
callq 0x825dd
cmpl $-0x1, %ebp
je 0x4cf49
leaq 0x78ce0(%rip), %rsi     # 0xc5b96
xorl %ebx, %ebx
movl $0x2, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x32ea6
xorl %edi, %edi
callq 0x26ce0
movq %rax, 0x760(%r12)
movl %ebp, 0x720(%r12)
movl $0x1, 0x76c(%r12)
callq 0x3351d
jmp 0x4cf77
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x36c98
leaq 0x78c2e(%rip), %rdi     # 0xc5b31
callq 0x38932
movq %r14, %rdi
callq 0x4cb97
movl %eax, %ebp
testl %eax, %eax
jne 0x4cf3a
callq 0x3b67c
testq %rax, %rax
je 0x4cf3a
shrq $0x14, %rax
leaq 0x78c17(%rip), %rsi     # 0xc5b42
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x32ea6
xorl %edi, %edi
testl %ebp, %ebp
setne %dil
callq 0x33106
jmp 0x4cf77
movl $0xffffffff, 0x770(%r12) # imm = 0xFFFFFFFF
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x78c0b(%rip), %rsi     # 0xc5b73
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x32ea6
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq