// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r13d
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
leaq 0xbf4a4(%rip), %rbp     # 0x106858
movq 0x7c0(%rbp), %rax
testq %rax, %rax
jne 0x473cb
cmpq $0x0, 0x28(%r15)
je 0x475e4
testq %rax, %rax
jne 0x473db
cmpq $0x0, 0x28(%r15)
jne 0x475f3
cmpl %r14d, 0x7ac(%rbp)
je 0x474b1
cmpl $0x9, %r14d
movl %r13d, 0x8(%rsp)
ja 0x47407
movl %r14d, %eax
leaq 0xbfeb3(%rip), %rcx     # 0x1072b0
movq 0x160(%rcx,%rax,8), %r12
jmp 0x47448
movslq %r14d, %rdx
leaq 0x40(%rsp), %r12
movl $0x15, %esi
movq %r12, %rdi
callq 0x433e5
movl %eax, %r13d
callq 0x39222
leaq 0x78b77(%rip), %rsi     # 0xbffa2
movq %rax, %rdi
movl %r13d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x39eb7
xorl %edi, %edi
movq %rax, %rsi
callq 0x43ab4
movq %rax, %r12
cmpq $0x0, 0x7c0(%rbp)
je 0x4745a
movq %r12, %rdi
callq 0x4731c
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x2e582
movq %r13, %rdi
callq 0x2e59f
testq %rax, %rax
movl 0x8(%rsp), %r13d
je 0x474a3
leaq 0x10(%rsp), %r15
movq 0x10(%rax), %rdi
cmpl $0x6, 0xa0(%rdi)
je 0x47496
movq %r12, %rsi
callq 0x3fc19
movq %r15, %rdi
callq 0x2e59f
testq %rax, %rax
jne 0x47481
cmpl $0xa, %r14d
jb 0x474b1
movq %r12, %rdi
callq 0x440f3
movl %r14d, 0x7ac(%rbp)
cmpq $0x0, 0x7c0(%rbp)
movslq %r13d, %r14
movl %r14d, %ebp
je 0x47574
leaq 0x21(%rsp), %r13
movb $0x2a, -0x1(%r13)
movl $0x17, %esi
movq %r13, %rdi
movq %r14, %rdx
callq 0x433e5
cltq
leaq 0x20(%rsp), %r12
movw $0xa0d, 0x1(%rax,%r12)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rsi
movq %r12, %rdi
callq 0x4725b
movq %r14, 0x8(%rsp)
testl %r14d, %r14d
jle 0x4756f
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x446f9
movb $0x24, 0x20(%rsp)
movl $0x17, %esi
movq %r13, %rdi
movq %rax, %rdx
callq 0x433e5
movq %r13, %r14
movslq %eax, %r13
movw $0xa0d, 0x1(%r13,%r12)  # imm = 0xA0D
leal 0x3(%r13), %eax
movslq %eax, %rsi
movq %r12, %rdi
callq 0x4725b
movq (%rbx,%r15,8), %rdi
callq 0x4731c
addq %r14, %r13
movl $0x2, %esi
movq %r13, %rdi
movq %r14, %r13
callq 0x4725b
incq %r15
cmpq %r15, %rbp
jne 0x47510
movq 0x8(%rsp), %r14
leaq 0xbf2dd(%rip), %rax     # 0x106858
movq 0x1e0(%rax), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x2e582
movq %r15, %rdi
callq 0x2e59f
testq %rax, %rax
je 0x475e4
leaq 0x10(%rsp), %r15
movq 0x10(%rax), %r12
cmpl $0x6, 0xa0(%r12)
je 0x475d7
movq %r12, %rdi
movq %r14, %rsi
callq 0x4063b
testl %r14d, %r14d
jle 0x475d7
xorl %r13d, %r13d
movq (%rbx,%r13,8), %rsi
movq %r12, %rdi
callq 0x40537
incq %r13
cmpq %r13, %rbp
jne 0x475c3
movq %r15, %rdi
callq 0x2e59f
testq %rax, %rax
jne 0x475a1
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7cbdb(%rip), %rdi     # 0xc41d5
leaq 0x7cba7(%rip), %rsi     # 0xc41a8
movl $0xb8, %edx
callq 0x654e1
movl $0x1, %edi
callq 0x263d0