// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x260(%rdi), %rax
movq %rax, (%rsp)
cmpq %rbx, %r12
je 0x2520b
movq 0x248(%r14), %rax
movq 0x250(%r14), %rcx
movq %rcx, %r13
subq %rax, %r13
addq 0x268(%r14), %r13
cmpq %r13, 0x2b8(%r14)
jne 0x2515c
cmpq %rax, %rcx
je 0x25108
movq %rax, 0x250(%r14)
movq (%rsp), %rdi
callq 0x25ff0
xorl %eax, %eax
movq %rax, 0x268(%r14)
movq %rax, 0x2b8(%r14)
movq %r14, %rdi
callq 0x24aa2
testb %al, %al
je 0x25153
movq 0x250(%r14), %r13
subq 0x248(%r14), %r13
addq 0x268(%r14), %r13
jne 0x25153
movq %r14, %rdi
callq 0x24aa2
testb %al, %al
jne 0x2512d
xorl %r13d, %r13d
testq %r13, %r13
je 0x2521f
movq %rbx, %rcx
subq %r12, %rcx
movq 0x2b8(%r14), %rax
leaq (%rax,%rcx), %rdx
movq %r13, %rbp
subq %rax, %rbp
cmpq %r13, %rdx
cmovbeq %rcx, %rbp
movq 0x248(%r14), %rsi
movq 0x250(%r14), %rcx
subq %rsi, %rcx
movq %rcx, %r13
subq %rax, %r13
jbe 0x251b9
leaq (%rax,%rbp), %rdx
cmpq %rcx, %rdx
cmovbeq %rbp, %r13
addq %rax, %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x4290
addq %r13, 0x2b8(%r14)
addq %r13, %r12
subq %r13, %rbp
movb $0x1, %r15b
testq %rbp, %rbp
je 0x251fe
movq 0x2b8(%r14), %rsi
subq 0x250(%r14), %rsi
addq 0x248(%r14), %rsi
leaq (%r12,%rbp), %r13
movq (%rsp), %rdi
movq %r12, %rdx
movq %r13, %rcx
callq *0x270(%r14)
testl %eax, %eax
je 0x251fb
addq %rbp, 0x2b8(%r14)
movq %r13, %r12
jmp 0x251fe
xorl %r15d, %r15d
testb %r15b, %r15b
jne 0x250cf
xorl %eax, %eax
jmp 0x25210
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x38600(%rip), %rsi     # 0x5d833
movq %rax, %rdi
callq 0x4110
movq 0x56da6(%rip), %rsi     # 0x7bfe8
movq 0x56d6f(%rip), %rdx     # 0x7bfb8
movq %rbx, %rdi
callq 0x4590
movq %rax, %r14
movq %rbx, %rdi
callq 0x4260
movq %r14, %rdi
callq 0x45e0