// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/aof.c
// Function: rewriteAppendOnlyFileBackground
int rewriteAppendOnlyFileBackground(void) {
    pid_t childpid;
    long long start;

    if (server.aof_child_pid != -1 || server.rdb_child_pid != -1) return C_ERR;
    if (aofCreatePipes() != C_OK) return C_ERR;
    start = ustime();
    if ((childpid = fork()) == 0) {
        char tmpfile[256];

        /* Child */
        closeListeningSockets(0);
        redisSetProcTitle("redis-aof-rewrite");
        snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid());
        if (rewriteAppendOnlyFile(tmpfile) == C_OK) {
            size_t private_dirty = zmalloc_get_private_dirty();

            if (private_dirty) {
                serverLog(LL_NOTICE,
                    "AOF rewrite: %zu MB of memory used by copy-on-write",
                    private_dirty/(1024*1024));
            }
            exitFromChild(0);
        } else {
            exitFromChild(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) {
            serverLog(LL_WARNING,
                "Can't rewrite append only file in background: fork: %s",
                strerror(errno));
            aofClosePipes();
            return C_ERR;
        }
        serverLog(LL_NOTICE,
            "Background append only file rewriting started by pid %d",childpid);
        server.aof_rewrite_scheduled = 0;
        server.aof_rewrite_time_start = time(NULL);
        server.aof_child_pid = childpid;
        updateDictResizePolicy();
        /* We set appendseldb to -1 in order to force the next call to the
         * feedAppendOnlyFile() to issue a SELECT command, so the differences
         * accumulated by the parent into server.aof_rewrite_buf will start
         * with a SELECT statement and it will be safe to merge. */
        server.aof_selected_db = -1;
        replicationScriptCacheFlush();
        return C_OK;
    }
    return C_OK; /* unreached */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
leaq 0x106c26(%rip), %rax    # 0x1781d8
cmpl $-0x1, 0x69c(%rax)
jne 0x715cb
leaq 0x106c16(%rip), %rax    # 0x1781d8
cmpl $-0x1, 0x730(%rax)
je 0x715d7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7183c
callq 0x74040
cmpl $0x0, %eax
je 0x715ed
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7183c
callq 0x2ff30
movq %rax, -0x10(%rbp)
callq 0x26ab0
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0x716a6
xorl %edi, %edi
callq 0x34f40
leaq 0xce782(%rip), %rdi     # 0x13fd97
callq 0x37840
leaq -0x110(%rbp), %rax
movq %rax, -0x120(%rbp)
callq 0x26420
movq -0x120(%rbp), %rdi
movl %eax, %ecx
movl $0x100, %esi            # imm = 0x100
leaq 0xce767(%rip), %rdx     # 0x13fda9
movb $0x0, %al
callq 0x26120
leaq -0x110(%rbp), %rdi
callq 0x73630
cmpl $0x0, %eax
jne 0x71697
callq 0x3b4a0
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x118(%rbp)
je 0x7168e
movq -0x118(%rbp), %rdx
shrq $0x14, %rdx
movl $0x2, %edi
leaq 0xce73c(%rip), %rsi     # 0x13fdc3
movb $0x0, %al
callq 0x2fc60
xorl %edi, %edi
callq 0x2ff90
jmp 0x716a1
movl $0x1, %edi
callq 0x2ff90
jmp 0x71835
callq 0x2ff30
movq %rax, %rcx
movq -0x10(%rbp), %rax
subq %rax, %rcx
leaq 0x106b1c(%rip), %rax    # 0x1781d8
movq %rcx, 0x3c8(%rax)
callq 0x3b090
movq %rax, %xmm0
movaps 0xc5dcc(%rip), %xmm1    # 0x1374a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xc5dd0(%rip), %xmm1    # 0x1374b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xcb9f1(%rip), %xmm1    # 0x13d0e8
mulsd %xmm1, %xmm0
leaq 0x106ad6(%rip), %rax    # 0x1781d8
cvtsi2sdq 0x3c8(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xc5d69(%rip), %xmm1    # 0x137480
divsd %xmm1, %xmm0
leaq 0x106ab6(%rip), %rax    # 0x1781d8
movsd %xmm0, 0x3d0(%rax)
leaq 0x106aa7(%rip), %rax    # 0x1781d8
cmpq $0x0, 0xa18(%rax)
je 0x7178a
leaq 0x106a96(%rip), %rax    # 0x1781d8
movq 0x3c8(%rax), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
leaq 0x106a7e(%rip), %rcx    # 0x1781d8
cmpq 0xa18(%rcx), %rax
jl 0x7178a
leaq 0x106a6e(%rip), %rax    # 0x1781d8
movq 0x3c8(%rax), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rsi
leaq 0xcbbfc(%rip), %rdi     # 0x13d381
callq 0xa1210
cmpl $-0x1, -0x8(%rbp)
jne 0x717c0
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xce64c(%rip), %rsi     # 0x13fdf7
movb $0x0, %al
callq 0x2fc60
callq 0x71300
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7183c
movl -0x8(%rbp), %edx
movl $0x2, %edi
leaq 0xce65f(%rip), %rsi     # 0x13fe2e
movb $0x0, %al
callq 0x2fc60
leaq 0x1069fb(%rip), %rax    # 0x1781d8
movl $0x0, 0x698(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x26ce0
movq %rax, %rcx
leaq 0x1069de(%rip), %rax    # 0x1781d8
movq %rcx, 0x6d0(%rax)
movl -0x8(%rbp), %ecx
leaq 0x1069cd(%rip), %rax    # 0x1781d8
movl %ecx, 0x69c(%rax)
callq 0x305c0
leaq 0x1069bb(%rip), %rax    # 0x1781d8
movl $0xffffffff, 0x6b4(%rax) # imm = 0xFFFFFFFF
callq 0x4eaf0
movl $0x0, -0x4(%rbp)
jmp 0x7183c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax,%rax)