// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r14
callq 0x3114c
movq %rax, %r15
leaq 0xa528e(%rip), %r13     # 0xf98a8
cmpl %r12d, 0x6b4(%r13)
je 0x5466f
leaq 0x636c2(%rip), %rdx     # 0xb7cec
leaq 0x10(%rsp), %r13
pushq $0x40
popq %rsi
movq %r13, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x26120
movq %r13, %rdi
callq 0x26500
leaq 0x62043(%rip), %rsi     # 0xb6691
movq %r15, %rdi
movq %rax, %rdx
movq %r13, %rcx
leaq 0xa524a(%rip), %r13     # 0xf98a8
xorl %eax, %eax
callq 0x31a38
movq %rax, %r15
movl %r12d, 0x6b4(%r13)
movq 0x8(%r14), %rax
cmpq 0xa0956(%rip), %rax     # 0xf4fd0
je 0x546ea
cmpq 0xa08a5(%rip), %rax     # 0xf4f28
je 0x546ea
cmpq 0xa0924(%rip), %rax     # 0xf4fb0
je 0x546ea
cmpq 0xa094b(%rip), %rax     # 0xf4fe0
setne %cl
cmpq 0xa08e9(%rip), %rax     # 0xf4f88
setne %dl
testb %dl, %cl
jne 0x54762
leaq 0x6994f(%rip), %rdi     # 0xbe000
pushq $0x3
popq %rsi
callq 0x39e29
movq %rax, %r12
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rdx)
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rdx)
pushq $0x3
popq %rsi
movq %r15, %rdi
callq 0x54403
movq %rax, %r15
movq %r12, %rdi
callq 0x3a265
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
movq %r15, %rdi
movq %r14, %rsi
callq 0x54503
movq %rax, %r14
cmpl $0x1, 0x668(%r13)
jne 0x5472e
movq 0x6a8(%r13), %rbx
movq %r14, %rdi
callq 0x543cb
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x31758
movq %rax, 0x6a8(%r13)
cmpl $-0x1, 0x69c(%r13)
je 0x5474b
movq %r14, %rdi
callq 0x543cb
movq %r14, %rdi
movq %rax, %rsi
callq 0x538da
movq %r14, %rdi
callq 0x311c8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq 0xa088f(%rip), %rax     # 0xf4ff8
setne %al
cmpl $0x4, %ebp
setl %cl
orb %al, %cl
jne 0x547f1
pushq $0x3
popq %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x54403
movq %rax, %r14
movl %ebp, %r12d
addq $-0x3, %r12
xorl %r13d, %r13d
leaq 0x61f14(%rip), %rbp     # 0xb66ac
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
cmpq %r13, %r12
je 0x54803
movq 0x18(%rbx,%r13,8), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
leaq 0x5df8b(%rip), %rsi     # 0xb274c
callq 0x262f0
testl %eax, %eax
jne 0x547d3
movq 0x20(%rbx,%r13,8), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x262f0
testl %eax, %eax
jne 0x547ec
movq 0x20(%rbx,%r13,8), %rax
movq %rax, 0x8(%rsp)
incq %r13
jmp 0x547a9
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x54403
jmp 0x546fd
movq (%rsp), %rcx
testq %rcx, %rcx
movq 0x8(%rsp), %r15
je 0x54816
testq %r15, %r15
jne 0x54857
testq %rcx, %rcx
leaq 0xa5088(%rip), %r13     # 0xf98a8
je 0x54838
movq 0x378(%r13), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x54503
movq %rax, %r14
testq %r15, %r15
je 0x54700
movq 0x380(%r13), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
movq %r15, %rcx
jmp 0x546f8
leaq 0x61e51(%rip), %rdi     # 0xb66af
leaq 0x61a02(%rip), %rsi     # 0xb6267
movl $0x224, %edx            # imm = 0x224
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0