// File: /workspace/github_c_makefile_star2_O3/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 0x3c537(%rip), %r12     # 0x6f088
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, 0x6b0(%r12)
je 0x32b6c
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 0x19e04
movq %rax, %r15
callq 0x12930
testl %eax, %eax
je 0x32c92
movl %eax, %ebp
callq 0x19e04
subq %r15, %rax
movq %rax, 0x390(%r12)
callq 0x1fd86
movq %rax, %xmm0
punpckldq 0x25eb9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x25ec1(%rip), %xmm0    # 0x58a90
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x233cd(%rip), %xmm1    # 0x55fb0
movq 0x390(%r12), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
mulsd 0x1f8b1(%rip), %xmm1    # 0x524b0
movsd %xmm1, 0x398(%r12)
movq 0x670(%r12), %rcx
testq %rcx, %rcx
je 0x32c45
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
cmpq %rcx, %rdx
jl 0x32c45
leaq 0x25f71(%rip), %rdi     # 0x58bae
movq %rdx, %rsi
callq 0x2fd96
cmpl $-0x1, %ebp
je 0x32ceb
leaq 0x25f81(%rip), %rsi     # 0x58bd6
xorl %ebx, %ebx
movl $0x2, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x19c06
xorl %edi, %edi
callq 0x12540
movq %rax, 0x6f0(%r12)
movl %ebp, 0x6b0(%r12)
movl $0x1, 0x6f8(%r12)
callq 0x1a288
jmp 0x32b61
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x1c18c
leaq 0x25ece(%rip), %rdi     # 0x58b70
callq 0x1d3e5
movq %r14, %rdi
callq 0x32996
movl %eax, %ebp
testl %eax, %eax
jne 0x32cd9
callq 0x1ffaa
testq %rax, %rax
je 0x32cd9
shrq $0x14, %rax
leaq 0x25eb8(%rip), %rsi     # 0x58b82
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19c06
xorl %edi, %edi
testl %ebp, %ebp
setne %dil
callq 0x19e8a
jmp 0x32b61
movl $0xffffffff, 0x6fc(%r12) # imm = 0xFFFFFFFF
callq 0x120d0
movl (%rax), %edi
callq 0x128e0
leaq 0x25ea9(%rip), %rsi     # 0x58bb3
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19c06
jmp 0x32b61