// File: /workspace/github_c_makefile_star2_O3/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), %rsi
testq %rsi, %rsi
je 0x45370
movzbl -0x1(%rsi), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x452cb
leaq 0x7bebe(%rip), %rcx     # 0xc1164
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x452cd
movq -0x11(%rsi), %rdx
jmp 0x452cd
movzwl -0x5(%rsi), %edx
jmp 0x452cd
movl -0x9(%rsi), %edx
jmp 0x452cd
movzbl -0x3(%rsi), %edx
jmp 0x452cd
xorl %edx, %edx
movl %ebp, %edi
callq 0x26bb0
cmpq $-0x1, %rax
je 0x45325
leaq 0xbc5c7(%rip), %rcx     # 0x1018a8
addq %rax, 0x428(%rcx)
movq 0xc0(%rbx), %rdi
movl %eax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x377b2
movq 0xc0(%rbx), %rdi
movzbl -0x1(%rdi), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x45360
leaq 0x7be61(%rip), %rdx     # 0xc1178
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x45357
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x7c5ad(%rip), %rsi     # 0xc18e5
movl $0x1, %edi
jmp 0x45461
movq -0x11(%rdi), %rax
jmp 0x45357
movzwl -0x5(%rdi), %eax
jmp 0x45357
movl -0x9(%rdi), %eax
jmp 0x45357
movzbl -0x3(%rdi), %eax
testq %rax, %rax
jne 0x4542f
callq 0x36330
movq $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 0x45410
movq %rsp, %rsi
movl %ebp, %edi
movq %rax, %rdx
callq 0x26bb0
cmpq $-0x1, %rax
je 0x45423
movq 0xb0(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0xb0(%rbx)
leaq 0xbc4e1(%rip), %r14     # 0x1018a8
addq %rax, 0x428(%r14)
cmpq 0xb8(%rbx), %rcx
jne 0x4542f
movl 0xa8(%rbx), %edi
callq 0x26180
movl $0xffffffff, 0xa8(%rbx) # imm = 0xFFFFFFFF
movq 0x40(%r14), %rdi
movl 0x8(%rbx), %esi
movl $0x2, %edx
callq 0x2cf0e
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x4517c
je 0x4543b
callq 0x26880
movl (%rax), %edi
callq 0x26680
movq %rax, %rdx
jmp 0x45442
callq 0x26880
movl (%rax), %edi
cmpl $0xb, %edi
jne 0x45450
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x7c4f4(%rip), %rdx     # 0xc1936
leaq 0x7c4ca(%rip), %rsi     # 0xc1913
movl $0x3, %edi
jmp 0x45464
callq 0x26680
leaq 0x7c4e8(%rip), %rsi     # 0xc1944
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2fdad
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r14
popq %rbp
jmp 0x3d73b