// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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), %r14
testq %r14, %r14
je 0x3df73
movq %r14, %rdi
callq 0x3cf20
movl %ebp, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x26bb0
cmpq $-0x1, %rax
je 0x3e016
leaq 0xbb975(%rip), %rcx     # 0xf98a8
addq %rax, 0x428(%rcx)
movq 0xc0(%rbx), %rdi
pushq $-0x1
popq %rdx
movl %eax, %esi
callq 0x31e8e
movq 0xc0(%rbx), %r14
movq %r14, %rdi
callq 0x3cf20
testq %rax, %rax
jne 0x3e04c
movq %r14, %rdi
callq 0x311c8
andq $0x0, 0xc0(%rbx)
movl 0xa8(%rbx), %edi
movq 0xb0(%rbx), %rsi
xorl %edx, %edx
callq 0x26a60
movl 0xa8(%rbx), %edi
movq %rsp, %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x26340
testq %rax, %rax
jle 0x3e02d
movq %rsp, %rsi
movl %ebp, %edi
movq %rax, %rdx
callq 0x26bb0
cmpq $-0x1, %rax
je 0x3e040
movq 0xb0(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0xb0(%rbx)
leaq 0xbb8d6(%rip), %r14     # 0xf98a8
addq %rax, 0x428(%r14)
cmpq 0xb8(%rbx), %rcx
jne 0x3e04c
movl 0xa8(%rbx), %edi
callq 0x26180
orl $-0x1, 0xa8(%rbx)
movq 0x40(%r14), %rdi
movl 0x8(%rbx), %esi
pushq $0x2
popq %rdx
callq 0x28ba8
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x3de04
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x7500c(%rip), %rsi     # 0xb3035
pushq $0x1
jmp 0x3e079
je 0x3e058
callq 0x26880
movl (%rax), %edi
callq 0x26680
movq %rax, %rdx
jmp 0x3e05f
callq 0x26880
movl (%rax), %edi
cmpl $0xb, %edi
jne 0x3e06b
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x75027(%rip), %rdx     # 0xb3086
leaq 0x74ffd(%rip), %rsi     # 0xb3063
pushq $0x3
popq %rdi
jmp 0x3e07d
callq 0x26680
leaq 0x7501d(%rip), %rsi     # 0xb3094
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x37527