// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
leaq 0x260(%rdi), %r12
cmpq %r14, %r13
je 0x200ed
movq 0x248(%r15), %rsi
movq 0x250(%r15), %rax
movq %rax, %rcx
subq %rsi, %rcx
movq 0x268(%r15), %rbx
addq %rcx, %rbx
cmpq %rbx, 0x2b8(%r15)
jne 0x20053
cmpq %rsi, %rax
je 0x1fff9
movq %rsi, 0x250(%r15)
movq %r12, %rdi
callq 0x13a7a
andq $0x0, 0x2b8(%r15)
movq %r15, %rdi
callq 0x1fb0c
testb %al, %al
je 0x20039
movq 0x248(%r15), %rsi
movq 0x250(%r15), %rcx
subq %rsi, %rcx
movq 0x268(%r15), %rdx
movl $0x0, %ebx
addq %rcx, %rdx
je 0x20009
jmp 0x20056
testq %rbx, %rbx
je 0x20103
movq 0x248(%r15), %rsi
movq 0x250(%r15), %rcx
subq %rsi, %rcx
movq %rbx, %rdx
movq %r14, %rdi
subq %r13, %rdi
movq 0x2b8(%r15), %rax
leaq (%rax,%rdi), %r8
movq %rdx, %rbx
subq %rax, %rbx
cmpq %rdx, %r8
cmovbeq %rdi, %rbx
movq %rcx, %rbp
subq %rax, %rbp
jbe 0x200ac
leaq (%rbx,%rax), %rdx
cmpq %rcx, %rdx
cmovbeq %rbx, %rbp
addq %rax, %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x42c0
movq 0x2b8(%r15), %rax
addq %rbp, %rax
movq %rax, 0x2b8(%r15)
addq %rbp, %r13
subq %rbp, %rbx
testq %rbx, %rbx
je 0x1ffbd
subq 0x250(%r15), %rax
addq 0x248(%r15), %rax
leaq (%rbx,%r13), %rbp
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq *0x270(%r15)
testl %eax, %eax
je 0x200f2
addq %rbx, 0x2b8(%r15)
movq %rbp, %r13
jmp 0x1ffbd
pushq $0x1
popq %rax
jmp 0x200f4
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %rbx
leaq 0x3282e(%rip), %rsi     # 0x52943
movq %rax, %rdi
callq 0x4120
movq 0x54ec4(%rip), %rsi     # 0x74fe8
movq 0x54e8d(%rip), %rdx     # 0x74fb8
movq %rbx, %rdi
callq 0x45b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x4290
movq %r14, %rdi
callq 0x4600