// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4060, %rsp           # imm = 0x4060
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
je 0x4f4d3
movl -0xc(%rbp), %eax
movl %eax, -0x404c(%rbp)
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x4048(%rbp)
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x4dc30
movl -0x404c(%rbp), %edi
movq -0x4048(%rbp), %rsi
movq %rax, %rdx
callq 0x26bc0
movq %rax, -0x4038(%rbp)
cmpq $-0x1, -0x4038(%rbp)
jne 0x4f454
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x1, %edi
leaq 0xecd72(%rip), %rsi     # 0x13c1b1
movb $0x0, %al
callq 0x2fc60
movq -0x28(%rbp), %rdi
callq 0x43ea0
jmp 0x4f663
movq -0x4038(%rbp), %rcx
leaq 0x128d76(%rip), %rax    # 0x1781d8
addq 0x428(%rax), %rcx
leaq 0x128d68(%rip), %rax    # 0x1781d8
movq %rcx, 0x428(%rax)
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rdi
movq -0x4038(%rbp), %rax
movl %eax, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x39db0
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x4dc30
cmpq $0x0, %rax
jne 0x4f4cc
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x38620
movq -0x28(%rbp), %rax
movq $0x0, 0xc0(%rax)
jmp 0x4f4d1
jmp 0x4f663
jmp 0x4f4d3
movq -0x28(%rbp), %rax
movl 0xa8(%rax), %edi
movq -0x28(%rbp), %rax
movq 0xb0(%rax), %rsi
xorl %edx, %edx
callq 0x26a60
movq -0x28(%rbp), %rax
movl 0xa8(%rax), %edi
leaq -0x4030(%rbp), %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x26340
movq %rax, -0x4040(%rbp)
cmpq $0x0, -0x4040(%rbp)
jg 0x4f570
cmpq $0x0, -0x4040(%rbp)
jne 0x4f535
leaq 0xeccd6(%rip), %rax     # 0x13c202
movq %rax, -0x4058(%rbp)
jmp 0x4f548
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, -0x4058(%rbp)
movq -0x4058(%rbp), %rdx
movl $0x3, %edi
leaq 0xecc84(%rip), %rsi     # 0x13c1df
movb $0x0, %al
callq 0x2fc60
movq -0x28(%rbp), %rdi
callq 0x43ea0
jmp 0x4f663
movl -0xc(%rbp), %edi
leaq -0x4030(%rbp), %rsi
movq -0x4040(%rbp), %rdx
callq 0x26bc0
movq %rax, -0x4038(%rbp)
cmpq $-0x1, %rax
jne 0x4f5cd
callq 0x26880
cmpl $0xb, (%rax)
je 0x4f5c8
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xecc58(%rip), %rsi     # 0x13c210
movb $0x0, %al
callq 0x2fc60
movq -0x28(%rbp), %rdi
callq 0x43ea0
jmp 0x4f663
movq -0x4038(%rbp), %rcx
movq -0x28(%rbp), %rax
addq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x4038(%rbp), %rcx
leaq 0x128be4(%rip), %rax    # 0x1781d8
addq 0x428(%rax), %rcx
leaq 0x128bd6(%rip), %rax    # 0x1781d8
movq %rcx, 0x428(%rax)
movq -0x28(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0xb8(%rcx), %rax
jne 0x4f663
movq -0x28(%rbp), %rax
movl 0xa8(%rax), %edi
callq 0x26180
movq -0x28(%rbp), %rax
movl $0xffffffff, 0xa8(%rax) # imm = 0xFFFFFFFF
leaq 0x128b93(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x2, %edx
callq 0x2aab0
movq -0x28(%rbp), %rdi
callq 0x4f230
addq $0x4060, %rsp           # imm = 0x4060
popq %rbp
retq
nopl (%rax)