// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x107a11(%rip), %rax    # 0x1781d8
movq 0x6a0(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x707eb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x707f3
xorl %eax, %eax
movq %rax, -0x38(%rbp)
jmp 0x707f3
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x70958
cmpq $0x0, -0x20(%rbp)
je 0x7089e
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0x7082d
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x70835
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x7089c
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movq -0x20(%rbp), %rax
addq (%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x26c60
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x7089e
cmpq $0x0, -0x10(%rbp)
je 0x70953
movl $0xa00010, %edi         # imm = 0xA00010
callq 0x3acd0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq $0xa00000, 0x8(%rax)    # imm = 0xA00000
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
leaq 0x107903(%rip), %rax    # 0x1781d8
movq 0x6a0(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x27000
leaq 0x1078ec(%rip), %rax    # 0x1781d8
movq 0x6a0(%rax), %rax
movq 0x28(%rax), %rax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x70951
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl $0x2, %eax
movl $0x3, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x44(%rbp)
callq 0x70600
movl -0x44(%rbp), %edi
movq %rax, %rdx
shrq $0x14, %rdx
leaq 0xce9ee(%rip), %rsi     # 0x13f338
movb $0x0, %al
callq 0x2fc60
jmp 0x70953
jmp 0x707fb
leaq 0x107879(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
leaq 0x10786e(%rip), %rax    # 0x1781d8
movl 0x6f8(%rax), %esi
callq 0x2ac40
cmpl $0x0, %eax
jne 0x709a8
leaq 0x107857(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
leaq 0x10784c(%rip), %rax    # 0x1781d8
movl 0x6f8(%rax), %esi
movl $0x2, %edx
leaq -0x32e(%rip), %rcx      # 0x70670
xorl %eax, %eax
movl %eax, %r8d
callq 0x2a8f0
addq $0x50, %rsp
popq %rbp
retq
nop