// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/aof.c
// Function: feedAppendOnlyFile
void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int argc) {
    sds buf = sdsempty();
    robj *tmpargv[3];

    /* The DB this command was targeting is not the same as the last command
     * we appended. To issue a SELECT command is needed. */
    if (dictid != server.aof_selected_db) {
        char seldb[64];

        snprintf(seldb,sizeof(seldb),"%d",dictid);
        buf = sdscatprintf(buf,"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n",
            (unsigned long)strlen(seldb),seldb);
        server.aof_selected_db = dictid;
    }

    if (cmd->proc == expireCommand || cmd->proc == pexpireCommand ||
        cmd->proc == expireatCommand) {
        /* Translate EXPIRE/PEXPIRE/EXPIREAT into PEXPIREAT */
        buf = catAppendOnlyExpireAtCommand(buf,cmd,argv[1],argv[2]);
    } else if (cmd->proc == setexCommand || cmd->proc == psetexCommand) {
        /* Translate SETEX/PSETEX to SET and PEXPIREAT */
        tmpargv[0] = createStringObject("SET",3);
        tmpargv[1] = argv[1];
        tmpargv[2] = argv[3];
        buf = catAppendOnlyGenericCommand(buf,3,tmpargv);
        decrRefCount(tmpargv[0]);
        buf = catAppendOnlyExpireAtCommand(buf,cmd,argv[1],argv[2]);
    } else if (cmd->proc == setCommand && argc > 3) {
        int i;
        robj *exarg = NULL, *pxarg = NULL;
        /* Translate SET [EX seconds][PX milliseconds] to SET and PEXPIREAT */
        buf = catAppendOnlyGenericCommand(buf,3,argv);
        for (i = 3; i < argc; i ++) {
            if (!strcasecmp(argv[i]->ptr, "ex")) exarg = argv[i+1];
            if (!strcasecmp(argv[i]->ptr, "px")) pxarg = argv[i+1];
        }
        serverAssert(!(exarg && pxarg));
        if (exarg)
            buf = catAppendOnlyExpireAtCommand(buf,server.expireCommand,argv[1],
                                               exarg);
        if (pxarg)
            buf = catAppendOnlyExpireAtCommand(buf,server.pexpireCommand,argv[1],
                                               pxarg);
    } else {
        /* All the other commands don't need translation or need the
         * same translation already operated in the command vector
         * for the replication itself. */
        buf = catAppendOnlyGenericCommand(buf,argc,argv);
    }

    /* Append to the AOF buffer. This will be flushed on disk just before
     * of re-entering the event loop, so before the client will get a
     * positive reply about the operation performed. */
    if (server.aof_state == AOF_ON)
        server.aof_buf = sdscatlen(server.aof_buf,buf,sdslen(buf));

    /* If a background append only file rewriting is in progress we want to
     * accumulate the differences between the child DB and the current one
     * in a buffer, so that when the child process will do its work we
     * can append the differences to the new append only file. */
    if (server.aof_child_pid != -1)
        aofRewriteBufferAppend((unsigned char*)buf,sdslen(buf));

    sdsfree(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, %rbx
callq 0x3628d
movq %rax, %r15
leaq 0xa3b48(%rip), %r13     # 0x1018a8
cmpl %r12d, 0x6b4(%r13)
je 0x5ddb7
leaq 0x68d40(%rip), %rdx     # 0xc6ab0
leaq 0x20(%rsp), %r13
movl $0x40, %esi
movq %r13, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x26120
movq %r13, %rdi
callq 0x26500
leaq 0x6760f(%rip), %rsi     # 0xc53a5
movq %r15, %rdi
movq %rax, %rdx
movq %r13, %rcx
leaq 0xa3b02(%rip), %r13     # 0x1018a8
xorl %eax, %eax
callq 0x36f2d
movq %rax, %r15
movl %r12d, 0x6b4(%r13)
movq 0x8(%rbx), %rax
cmpq 0x9f20e(%rip), %rax     # 0xfcfd0
je 0x5de36
cmpq 0x9f15d(%rip), %rax     # 0xfcf28
je 0x5de36
cmpq 0x9f1dc(%rip), %rax     # 0xfcfb0
je 0x5de36
cmpq 0x9f203(%rip), %rax     # 0xfcfe0
setne %cl
cmpq 0x9f1a1(%rip), %rax     # 0xfcf88
setne %dl
testb %dl, %cl
jne 0x5de8b
leaq 0x6f5bb(%rip), %rdi     # 0xcd3b4
movl $0x3, %esi
callq 0x40744
movq %rax, %r12
leaq 0x20(%rsp), %rdx
movq %rax, (%rdx)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rdx)
movq 0x18(%r14), %rax
movq %rax, 0x10(%rdx)
movq %r15, %rdi
movl $0x3, %esi
callq 0x5dae4
movq %rax, %r15
movq %r12, %rdi
callq 0x40c8f
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5dc43
movq %rax, %rbx
cmpl $0x1, 0x668(%r13)
jne 0x5dfb9
movq 0x6a8(%r13), %rdi
movzbl -0x1(%rbx), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x5dfa8
leaq 0x67072(%rip), %rcx     # 0xc4eec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x5dfaa
cmpq 0x9f166(%rip), %rax     # 0xfcff8
setne %al
cmpl $0x4, %ebp
setl %cl
movq %r15, %rdi
orb %al, %cl
jne 0x5df82
movl $0x3, %esi
movq %r14, %rdx
callq 0x5dae4
movq %rax, 0x18(%rsp)
movl %ebp, %ebx
addq $-0x3, %rbx
xorl %r12d, %r12d
leaq 0x63088(%rip), %r13     # 0xc0f50
leaq 0x674f1(%rip), %rbp     # 0xc53c0
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x18(%r14,%r12,8), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x262f0
testl %eax, %eax
jne 0x5df03
movq 0x20(%r14,%r12,8), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x262f0
testl %eax, %eax
jne 0x5df1c
movq 0x20(%r14,%r12,8), %rax
movq %rax, 0x10(%rsp)
incq %r12
cmpq %r12, %rbx
jne 0x5dee1
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
leaq 0xa3975(%rip), %r13     # 0x1018a8
movq 0x10(%rsp), %r15
je 0x5df43
testq %r15, %r15
jne 0x5e01e
testq %rcx, %rcx
movq 0x18(%rsp), %rbx
je 0x5df63
movq 0x378(%r13), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x5dc43
movq %rax, %rbx
testq %r15, %r15
je 0x5de4c
movq 0x380(%r13), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
movq %r15, %rcx
jmp 0x5de44
movl %ebp, %esi
movq %r14, %rdx
callq 0x5dae4
jmp 0x5de49
movq -0x11(%rbx), %rdx
jmp 0x5dfaa
movzwl -0x5(%rbx), %edx
jmp 0x5dfaa
movl -0x9(%rbx), %edx
jmp 0x5dfaa
movzbl -0x3(%rbx), %edx
jmp 0x5dfaa
xorl %edx, %edx
movq %rbx, %rsi
callq 0x36ad1
movq %rax, 0x6a8(%r13)
cmpl $-0x1, 0x69c(%r13)
je 0x5e007
movzbl -0x1(%rbx), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x5dffd
leaq 0x66f28(%rip), %rcx     # 0xc4f00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x5dfff
movq -0x11(%rbx), %rsi
jmp 0x5dfff
movzwl -0x5(%rbx), %esi
jmp 0x5dfff
movl -0x9(%rbx), %esi
jmp 0x5dfff
movzbl -0x3(%rbx), %esi
jmp 0x5dfff
xorl %esi, %esi
movq %rbx, %rdi
callq 0x5ce3f
movq %rbx, %rdi
callq 0x36330
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6739e(%rip), %rdi     # 0xc53c3
leaq 0x66f4f(%rip), %rsi     # 0xc4f7b
movl $0x224, %edx            # imm = 0x224
callq 0x61908
movl $0x1, %edi
callq 0x263c0