// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationFeedSlaves
void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
    listNode *ln;
    listIter li;
    int j, len;
    char llstr[LONG_STR_SIZE];

    /* If there aren't slaves, and there is no backlog buffer to populate,
     * we can return ASAP. */
    if (server.repl_backlog == NULL && listLength(slaves) == 0) return;

    /* We can't have slaves attached and no backlog. */
    serverAssert(!(listLength(slaves) != 0 && server.repl_backlog == NULL));

    /* Send SELECT command to every slave if needed. */
    if (server.slaveseldb != dictid) {
        robj *selectcmd;

        /* For a few DBs we have pre-computed SELECT command. */
        if (dictid >= 0 && dictid < PROTO_SHARED_SELECT_CMDS) {
            selectcmd = shared.select[dictid];
        } else {
            int dictid_len;

            dictid_len = ll2string(llstr,sizeof(llstr),dictid);
            selectcmd = createObject(OBJ_STRING,
                sdscatprintf(sdsempty(),
                "*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n",
                dictid_len, llstr));
        }

        /* Add the SELECT command into the backlog. */
        if (server.repl_backlog) feedReplicationBacklogWithObject(selectcmd);

        /* Send it to slaves. */
        listRewind(slaves,&li);
        while((ln = listNext(&li))) {
            client *slave = ln->value;
            if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) continue;
            addReply(slave,selectcmd);
        }

        if (dictid < 0 || dictid >= PROTO_SHARED_SELECT_CMDS)
            decrRefCount(selectcmd);
    }
    server.slaveseldb = dictid;

    /* Write the command to the replication backlog if any. */
    if (server.repl_backlog) {
        char aux[LONG_STR_SIZE+3];

        /* Add the multi bulk reply length. */
        aux[0] = '*';
        len = ll2string(aux+1,sizeof(aux)-1,argc);
        aux[len+1] = '\r';
        aux[len+2] = '\n';
        feedReplicationBacklog(aux,len+3);

        for (j = 0; j < argc; j++) {
            long objlen = stringObjectLen(argv[j]);

            /* We need to feed the buffer with the object as a bulk reply
             * not just as a plain string, so create the $..CRLF payload len
             * and add the final CRLF */
            aux[0] = '$';
            len = ll2string(aux+1,sizeof(aux)-1,objlen);
            aux[len+1] = '\r';
            aux[len+2] = '\n';
            feedReplicationBacklog(aux,len+3);
            feedReplicationBacklogWithObject(argv[j]);
            feedReplicationBacklog(aux+len+1,2);
        }
    }

    /* Write the command to every slave. */
    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        client *slave = ln->value;

        /* Don't feed slaves that are still waiting for BGSAVE to start */
        if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) continue;

        /* Feed slaves that are waiting for the initial SYNC (so these commands
         * are queued in the output buffer until the initial SYNC completes),
         * or are already in sync with the master. */

        /* Add the multi bulk length. */
        addReplyMultiBulkLen(slave,argc);

        /* Finally any additional argument that was not stored inside the
         * static buffer if any (from j to argc). */
        for (j = 0; j < argc; j++)
            addReplyBulk(slave,argv[j]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
leaq 0x12a4f8(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x7d0(%rax)
jne 0x4dcfa
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x4dcfa
jmp 0x4dfff
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4dd16
leaq 0x12a4cc(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x7d0(%rax)
je 0x4dd18
jmp 0x4dd3a
leaq 0xede0a(%rip), %rdi     # 0x13bb29
leaq 0xeddd6(%rip), %rsi     # 0x13bafc
movl $0xb8, %edx
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
leaq 0x12a497(%rip), %rax    # 0x1781d8
movl 0x7bc(%rax), %eax
cmpl -0xc(%rbp), %eax
je 0x4de30
cmpl $0x0, -0xc(%rbp)
jl 0x4dd75
cmpl $0xa, -0xc(%rbp)
jge 0x4dd75
movslq -0xc(%rbp), %rcx
leaq 0x12aed9(%rip), %rax    # 0x178c40
movq 0x160(%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
jmp 0x4ddb5
leaq -0x60(%rbp), %rdi
movslq -0xc(%rbp), %rdx
movl $0x15, %esi
callq 0x477e0
movl %eax, -0x6c(%rbp)
callq 0x384f0
movq %rax, %rdi
movl -0x6c(%rbp), %edx
leaq -0x60(%rbp), %rcx
leaq 0xea1e4(%rip), %rsi     # 0x137f84
movb $0x0, %al
callq 0x395b0
movq %rax, %rsi
xorl %edi, %edi
callq 0x48480
movq %rax, -0x68(%rbp)
leaq 0x12a41c(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x7d0(%rax)
je 0x4ddcf
movq -0x68(%rbp), %rdi
callq 0x4dbb0
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x27320
leaq -0x38(%rbp), %rdi
callq 0x27380
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x4de19
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x6, 0xa0(%rax)
jne 0x4de0a
jmp 0x4dddc
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x42cc0
jmp 0x4dddc
cmpl $0x0, -0xc(%rbp)
jl 0x4de25
cmpl $0xa, -0xc(%rbp)
jl 0x4de2e
movq -0x68(%rbp), %rdi
callq 0x48f70
jmp 0x4de30
movl -0xc(%rbp), %ecx
leaq 0x12a39e(%rip), %rax    # 0x1781d8
movl %ecx, 0x7bc(%rax)
leaq 0x12a391(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x7d0(%rax)
je 0x4df70
movb $0x2a, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x1, %rdi
movslq -0x1c(%rbp), %rdx
movl $0x17, %esi
callq 0x477e0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
cltq
movb $0xd, -0x90(%rbp,%rax)
movl -0x40(%rbp), %eax
addl $0x2, %eax
cltq
movb $0xa, -0x90(%rbp,%rax)
leaq -0x90(%rbp), %rdi
movl -0x40(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rsi
callq 0x4da10
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4df6e
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x498c0
movq %rax, -0x98(%rbp)
movb $0x24, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x1, %rdi
movq -0x98(%rbp), %rdx
movl $0x17, %esi
callq 0x477e0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
cltq
movb $0xd, -0x90(%rbp,%rax)
movl -0x40(%rbp), %eax
addl $0x2, %eax
cltq
movb $0xa, -0x90(%rbp,%rax)
leaq -0x90(%rbp), %rdi
movl -0x40(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rsi
callq 0x4da10
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4dbb0
leaq -0x90(%rbp), %rdi
movslq -0x40(%rbp), %rax
addq %rax, %rdi
addq $0x1, %rdi
movl $0x2, %esi
callq 0x4da10
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4deb4
jmp 0x4df70
leaq 0x12a261(%rip), %rax    # 0x1781d8
movq 0x1e0(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x27320
leaq -0x38(%rbp), %rdi
callq 0x27380
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x4dfff
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x6, 0xa0(%rax)
jne 0x4dfbb
jmp 0x4df87
movq -0xa0(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x437f0
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4dffd
movq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x43630
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4dfd2
jmp 0x4df87
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)