// File: /workspace/github_c_makefile_star2_O1/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 0x3bec1(%rip), %r12     # 0x6f088
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, 0x6b0(%r12)
je 0x331e2
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 0x12550
movq %rax, 0x6e0(%r12)
callq 0x1a1b0
movq %rax, %r15
callq 0x12940
testl %eax, %eax
je 0x33308
movl %eax, %ebp
callq 0x1a1b0
subq %r15, %rax
movq %rax, 0x390(%r12)
callq 0x2006e
movq %rax, %xmm0
punpckldq 0x25863(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2586b(%rip), %xmm0    # 0x58ab0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x22d6f(%rip), %xmm1    # 0x55fc8
movq 0x390(%r12), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
mulsd 0x1f1eb(%rip), %xmm1    # 0x52460
movsd %xmm1, 0x398(%r12)
movq 0x670(%r12), %rcx
testq %rcx, %rcx
je 0x332bb
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
cmpq %rcx, %rdx
jl 0x332bb
leaq 0x2591b(%rip), %rdi     # 0x58bce
movq %rdx, %rsi
callq 0x30346
cmpl $-0x1, %ebp
je 0x33361
leaq 0x2592b(%rip), %rsi     # 0x58bf6
xorl %ebx, %ebx
movl $0x2, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x19fb1
xorl %edi, %edi
callq 0x12550
movq %rax, 0x6f0(%r12)
movl %ebp, 0x6b0(%r12)
movl $0x1, 0x6f8(%r12)
callq 0x1a634
jmp 0x331d7
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x1c4ca
leaq 0x25878(%rip), %rdi     # 0x58b90
callq 0x1d664
movq %r14, %rdi
callq 0x3300c
movl %eax, %ebp
testl %eax, %eax
jne 0x3334f
callq 0x2029a
testq %rax, %rax
je 0x3334f
shrq $0x14, %rax
leaq 0x25862(%rip), %rsi     # 0x58ba2
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19fb1
xorl %edi, %edi
testl %ebp, %ebp
setne %dil
callq 0x1a236
jmp 0x331d7
movl $0xffffffff, 0x6fc(%r12) # imm = 0xFFFFFFFF
callq 0x120d0
movl (%rax), %edi
callq 0x128f0
leaq 0x25853(%rip), %rsi     # 0x58bd3
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19fb1
jmp 0x331d7