// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp
// Function: hdiff_private::TStepStream::readTo(unsigned char*, unsigned char*)
hpatch_BOOL TStepStream::readTo(unsigned char* out_data,unsigned char* out_data_end){
    while (out_data!=out_data_end){
        hpatch_StreamPos_t stepDataLen=step_buf.size()+step_dataDiff.streamSize;
        if (readBufPos==stepDataLen){
            step_buf.clear();
            step_dataDiff.clear();
            readBufPos=0;
            while (doStep()) { 
                stepDataLen=step_buf.size()+step_dataDiff.streamSize;
                if (stepDataLen>0) 
                    break; 
            }
            check(stepDataLen>0);
        }
        size_t len=out_data_end-out_data;
        if (readBufPos+len>stepDataLen)
            len=(size_t)(stepDataLen-readBufPos);
        if (readBufPos<step_buf.size()){//copy data from step_buf
            size_t clen=len;
            if (readBufPos+clen>step_buf.size())
                clen=(size_t)(step_buf.size()-readBufPos);
            memcpy(out_data,step_buf.data()+(size_t)readBufPos,clen);
            readBufPos+=clen;
            out_data+=clen;
            len-=clen;
        }
        if (len>0){//copy data from step_dataDiff
            if (!step_dataDiff.read(&step_dataDiff,readBufPos-step_buf.size(),
                                    out_data,out_data+len)) return hpatch_FALSE;
            readBufPos+=len;
            out_data+=len;
        }
    }
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x4ed85
movq -0x50(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq %rax, %rcx
movq -0x50(%rbp), %rax
addq 0x268(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x2b8(%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0x4ebd4
movq -0x50(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xce90
movq -0x50(%rbp), %rdi
addq $0x260, %rdi            # imm = 0x260
callq 0x303b0
movq -0x50(%rbp), %rax
movq $0x0, 0x2b8(%rax)
movq -0x50(%rbp), %rdi
callq 0x4e320
testb $0x1, %al
jne 0x4eb4e
jmp 0x4eb78
movq -0x50(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq -0x50(%rbp), %rcx
addq 0x268(%rcx), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jbe 0x4eb76
jmp 0x4eb78
jmp 0x4eb3f
cmpq $0x0, -0x28(%rbp)
ja 0x4ebd2
movl $0x10, %edi
callq 0x41e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x58(%rbp)
leaq 0x62353(%rip), %rsi     # 0xb0eed
callq 0x4140
jmp 0x4eba1
movq -0x58(%rbp), %rdi
movq 0x97444(%rip), %rsi     # 0xe5ff0
movq 0x9740d(%rip), %rdx     # 0xe5fc0
callq 0x4630
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x42e0
jmp 0x4ed98
jmp 0x4ebd4
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
subq %rdx, %rcx
movq %rcx, -0x40(%rbp)
movq 0x2b8(%rax), %rax
addq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x4ec0b
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
subq 0x2b8(%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rdi
movq 0x2b8(%rdi), %rax
movq %rax, -0x60(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0x4ecec
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x2b8(%rdi), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jbe 0x4ec88
movq -0x50(%rbp), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq -0x50(%rbp), %rcx
subq 0x2b8(%rcx), %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0xbb60
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movq -0x50(%rbp), %rax
addq 0x2b8(%rax), %rsi
movq -0x48(%rbp), %rdx
callq 0x4320
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
addq 0x2b8(%rax), %rcx
movq %rcx, 0x2b8(%rax)
movq -0x48(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jbe 0x4ed80
movq -0x50(%rbp), %rdi
movq 0x270(%rdi), %rax
movq %rax, -0x78(%rbp)
movq %rdi, %rax
addq $0x260, %rax            # imm = 0x260
movq %rax, -0x80(%rbp)
movq 0x2b8(%rdi), %rax
movq %rax, -0x88(%rbp)
addq $0x248, %rdi            # imm = 0x248
callq 0xbe90
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movq -0x78(%rbp), %rax
subq %rcx, %rsi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq -0x40(%rbp), %rcx
callq *%rax
cmpl $0x0, %eax
jne 0x4ed5e
movl $0x0, -0x4(%rbp)
jmp 0x4ed8c
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
addq 0x2b8(%rax), %rcx
movq %rcx, 0x2b8(%rax)
movq -0x40(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x4eacf
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)