// File: /workspace/github_c_makefile_star2_O2/erikdubbelboer[P]discnt/src/ddb.c
// Function: ddbSaveBackground
int ddbSaveBackground(char *filename) {
    pid_t childpid;
    long long start;

    if (server.ddb_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);
        serverSetProcTitle("discnt-ddb-bgsave");
        retval = ddbSave(filename);
        if (retval == C_OK) {
            size_t private_dirty = zmalloc_get_private_dirty();

            if (private_dirty) {
                serverLog(LL_NOTICE,
                    "DDB: %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.ddb_save_time_start = time(NULL);
        server.ddb_child_pid = childpid;
        server.ddb_child_type = DDB_CHILD_TYPE_DISK;
        updateDictResizePolicy();
        return C_OK;
    }
    return C_OK; /* unreached */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x3e928(%rip), %r12     # 0x6a088
pushq $-0x1
popq %rbx
cmpl $-0x1, 0x6b0(%r12)
je 0x2b779
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r14
movq 0x6a0(%r12), %rax
movq %rax, 0x6a8(%r12)
xorl %edi, %edi
callq 0x12540
movq %rax, 0x6e0(%r12)
callq 0x15d90
movq %rax, %r15
callq 0x12930
testl %eax, %eax
je 0x2b889
movl %eax, %ebp
callq 0x15d90
subq %r15, %rax
movq %rax, 0x390(%r12)
callq 0x1acf0
movq %rax, %xmm0
punpckldq 0x2695c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x26964(%rip), %xmm0    # 0x52140
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x23fd8(%rip), %xmm1    # 0x4f7c8
movq 0x390(%r12), %rax
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
mulsd 0x20bc7(%rip), %xmm1    # 0x4c3d0
movsd %xmm1, 0x398(%r12)
movq 0x670(%r12), %rcx
testq %rcx, %rcx
je 0x2b83e
movl $0x3e8, %esi            # imm = 0x3E8
cqto
idivq %rsi
cmpq %rcx, %rax
jl 0x2b83e
leaq 0x26a28(%rip), %rdi     # 0x5225e
movq %rax, %rsi
callq 0x28f22
cmpl $-0x1, %ebp
je 0x2b8e0
leaq 0x26a38(%rip), %rsi     # 0x52286
xorl %ebx, %ebx
pushq $0x2
popq %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x15b9e
xorl %edi, %edi
callq 0x12540
movq %rax, 0x6f0(%r12)
movl %ebp, 0x6b0(%r12)
movl $0x1, 0x6f8(%r12)
callq 0x1608a
jmp 0x2b76e
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x17cdd
leaq 0x26987(%rip), %rdi     # 0x52220
callq 0x18d52
movq %r14, %rdi
callq 0x2b5bc
movl %eax, %ebp
testl %eax, %eax
jne 0x2b8ce
callq 0x1af16
testq %rax, %rax
je 0x2b8ce
shrq $0x14, %rax
leaq 0x26971(%rip), %rsi     # 0x52232
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x15b9e
xorl %edi, %edi
testl %ebp, %ebp
setne %dil
callq 0x15de8
jmp 0x2b76e
orl $-0x1, 0x6fc(%r12)
callq 0x120d0
movl (%rax), %edi
callq 0x128e0
leaq 0x26967(%rip), %rsi     # 0x52263
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x15b9e
jmp 0x2b76e