// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/aof.c
// Function: aofRewriteBufferAppend
void aofRewriteBufferAppend(unsigned char *s, unsigned long len) {
    listNode *ln = listLast(server.aof_rewrite_buf_blocks);
    aofrwblock *block = ln ? ln->value : NULL;

    while(len) {
        /* If we already got at least an allocated block, try appending
         * at least some piece into it. */
        if (block) {
            unsigned long thislen = (block->free < len) ? block->free : len;
            if (thislen) {  /* The current block is not already full. */
                memcpy(block->buf+block->used, s, thislen);
                block->used += thislen;
                block->free -= thislen;
                s += thislen;
                len -= thislen;
            }
        }

        if (len) { /* First block to allocate, or need another block. */
            int numblocks;

            block = zmalloc(sizeof(*block));
            block->free = AOF_RW_BUF_BLOCK_SIZE;
            block->used = 0;
            listAddNodeTail(server.aof_rewrite_buf_blocks,block);

            /* Log every time we cross more 10 or 100 blocks, respectively
             * as a notice or warning. */
            numblocks = listLength(server.aof_rewrite_buf_blocks);
            if (((numblocks+1) % 10) == 0) {
                int level = ((numblocks+1) % 100) == 0 ? LL_WARNING :
                                                         LL_NOTICE;
                serverLog(level,"Background AOF buffer size: %lu MB",
                    aofRewriteBufferSize()/(1024*1024));
            }
        }
    }

    /* Install a file event to send data to the rewrite child if there is
     * not one already. */
    if (aeGetFileEvents(server.el,server.aof_pipe_write_data_to_child) == 0) {
        aeCreateFileEvent(server.el, server.aof_pipe_write_data_to_child,
            AE_WRITABLE, aofChildWriteDiffData, NULL);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xa4a51(%rip), %r15     # 0x1018a8
movq 0x6a0(%r15), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x5ce6d
movq 0x10(%rax), %r12
jmp 0x5ce70
xorl %r12d, %r12d
testq %rbx, %rbx
je 0x5cf48
testq %r12, %r12
je 0x5cebb
movq 0x8(%r12), %r13
testq %r13, %r13
je 0x5cebb
cmpq %rbx, %r13
cmovaeq %rbx, %r13
movq (%r12), %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x26c50
addq %r13, (%r12)
subq %r13, 0x8(%r12)
subq %r13, %rbx
je 0x5cf48
addq %r13, %r14
movl $0xa00010, %edi         # imm = 0xA00010
callq 0x382d1
movq %rax, %r12
movq $0xa00000, 0x8(%rax)    # imm = 0xA00000
movq $0x0, (%rax)
movq 0x6a0(%r15), %rdi
movq %rax, %rsi
callq 0x2b24b
movq 0x6a0(%r15), %rax
movl 0x28(%rax), %eax
imull $0xcccccccd, %eax, %ecx # imm = 0xCCCCCCCD
addl $0xe6666665, %ecx       # imm = 0xE6666665
rorl %ecx
cmpl $0x19999998, %ecx       # imm = 0x19999998
ja 0x5ce79
incl %eax
imull $0xc28f5c29, %eax, %eax # imm = 0xC28F5C29
addl $0x51eb850, %eax        # imm = 0x51EB850
rorl $0x2, %eax
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
movl $0x0, %ebp
adcl $0x2, %ebp
callq 0x5cd26
shrq $0x14, %rax
movl %ebp, %edi
leaq 0x68003(%rip), %rsi     # 0xc4f3c
movq %rax, %rdx
xorl %eax, %eax
callq 0x2fdad
jmp 0x5ce79
movq 0x40(%r15), %rdi
movl 0x6f8(%r15), %esi
callq 0x2cfd5
testl %eax, %eax
je 0x5cf6b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%r15), %rdi
movl 0x6f8(%r15), %esi
leaq -0x202(%rip), %rcx      # 0x5cd7b
movl $0x2, %edx
xorl %r8d, %r8d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2ce46