// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/replication.c
// Function: sendBulkToSlave
void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
    client *slave = privdata;
    UNUSED(el);
    UNUSED(mask);
    char buf[PROTO_IOBUF_LEN];
    ssize_t nwritten, buflen;

    /* Before sending the RDB file, we send the preamble as configured by the
     * replication process. Currently the preamble is just the bulk count of
     * the file in the form "$<length>\r\n". */
    if (slave->replpreamble) {
        nwritten = write(fd,slave->replpreamble,sdslen(slave->replpreamble));
        if (nwritten == -1) {
            serverLog(LL_VERBOSE,"Write error sending RDB preamble to slave: %s",
                strerror(errno));
            freeClient(slave);
            return;
        }
        server.stat_net_output_bytes += nwritten;
        sdsrange(slave->replpreamble,nwritten,-1);
        if (sdslen(slave->replpreamble) == 0) {
            sdsfree(slave->replpreamble);
            slave->replpreamble = NULL;
            /* fall through sending data. */
        } else {
            return;
        }
    }

    /* If the preamble was already transfered, send the RDB bulk data. */
    lseek(slave->repldbfd,slave->repldboff,SEEK_SET);
    buflen = read(slave->repldbfd,buf,PROTO_IOBUF_LEN);
    if (buflen <= 0) {
        serverLog(LL_WARNING,"Read error sending DB to slave: %s",
            (buflen == 0) ? "premature EOF" : strerror(errno));
        freeClient(slave);
        return;
    }
    if ((nwritten = write(fd,buf,buflen)) == -1) {
        if (errno != EAGAIN) {
            serverLog(LL_WARNING,"Write error sending DB to slave: %s",
                strerror(errno));
            freeClient(slave);
        }
        return;
    }
    slave->repldboff += nwritten;
    server.stat_net_output_bytes += nwritten;
    if (slave->repldboff == slave->repldbsize) {
        close(slave->repldbfd);
        slave->repldbfd = -1;
        aeDeleteFileEvent(server.el,slave->fd,AE_WRITABLE);
        putSlaveOnline(slave);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x4000, %rsp           # imm = 0x4000
movq %rdx, %rbx
movl %esi, %ebp
movq 0xc0(%rdx), %rsi
testq %rsi, %rsi
je 0x485ed
movzbl -0x1(%rsi), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x48544
leaq 0x7bbe1(%rip), %rcx     # 0xc4100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x48546
movq -0x11(%rsi), %rdx
jmp 0x48546
movzwl -0x5(%rsi), %edx
jmp 0x48546
movl -0x9(%rsi), %edx
jmp 0x48546
movzbl -0x3(%rsi), %edx
jmp 0x48546
xorl %edx, %edx
movl %ebp, %edi
callq 0x26bc0
cmpq $-0x1, %rax
je 0x4859e
leaq 0xbe2fe(%rip), %rcx     # 0x106858
addq %rax, 0x418(%rcx)
movq 0xc0(%rbx), %rdi
movl %eax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3a73b
movq 0xc0(%rbx), %rdi
movzbl -0x1(%rdi), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x485d2
leaq 0x7bb84(%rip), %rdx     # 0xc4114
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x485d4
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x7c2a0(%rip), %rsi     # 0xc4851
movl $0x1, %edi
jmp 0x486de
movq -0x11(%rdi), %rax
jmp 0x485d4
movzwl -0x5(%rdi), %eax
jmp 0x485d4
movl -0x9(%rdi), %eax
jmp 0x485d4
movzbl -0x3(%rdi), %eax
jmp 0x485d4
xorl %eax, %eax
testq %rax, %rax
jne 0x486ac
callq 0x392b6
movq $0x0, 0xc0(%rbx)
movl 0xa8(%rbx), %edi
movq 0xb0(%rbx), %rsi
xorl %edx, %edx
callq 0x26a70
movl 0xa8(%rbx), %edi
movq %rsp, %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x26350
testq %rax, %rax
jle 0x4868d
movq %rsp, %rsi
movl %ebp, %edi
movq %rax, %rdx
callq 0x26bc0
cmpq $-0x1, %rax
je 0x486a0
movq 0xb0(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0xb0(%rbx)
leaq 0xbe214(%rip), %r14     # 0x106858
addq %rax, 0x418(%r14)
cmpq 0xb8(%rbx), %rcx
jne 0x486ac
movl 0xa8(%rbx), %edi
callq 0x26180
movl $0xffffffff, 0xa8(%rbx) # imm = 0xFFFFFFFF
movq 0x40(%r14), %rdi
movl 0x8(%rbx), %esi
movl $0x2, %edx
callq 0x2ffb6
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x483f5
je 0x486b8
callq 0x26890
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
jmp 0x486bf
callq 0x26890
movl (%rax), %edi
cmpl $0xb, %edi
jne 0x486cd
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x7c1e3(%rip), %rdx     # 0xc48a2
leaq 0x7c1b9(%rip), %rsi     # 0xc487f
movl $0x3, %edi
jmp 0x486e1
callq 0x26690
leaq 0x7c1d7(%rip), %rsi     # 0xc48b0
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x32ea6
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x40b04