// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/src/patch/OldStream.cpp
// Function: OldStream_read(hpatch_TStreamInput const*, unsigned long long, unsigned char*, unsigned char*)
static hpatch_BOOL _OldStream_read(const hpatch_TStreamInput* stream,
                                   const hpatch_StreamPos_t _readFromPos,
                                   unsigned char* out_data,unsigned char* out_data_end){
    OldStream* self=(OldStream*)stream->streamImport;
    const uint32_t* ranges=self->_rangeEndList;
    int curRangeIndex=self->_curRangeIndex;
    hpatch_BOOL  result=hpatch_TRUE;
    size_t readFromPos=(size_t)_readFromPos;
    while (out_data<out_data_end) {
        size_t readLen=(size_t)(out_data_end-out_data);
        if (ranges[curRangeIndex-1]<=readFromPos){ //-1 safe
            if (readFromPos+readLen<=ranges[curRangeIndex]){//hit all
                check(_OldStream_read_do(self,readFromPos,out_data,out_data_end,curRangeIndex));
                break; //ok out while
            }else if (readFromPos<=ranges[curRangeIndex]){//hit left
                size_t leftLen=(size_t)(ranges[curRangeIndex]-readFromPos);
                if (leftLen>0)
                    check(_OldStream_read_do(self,readFromPos,out_data,out_data+leftLen,curRangeIndex));
                ++curRangeIndex;
                readFromPos+=leftLen;
                out_data+=leftLen;
                continue; //next
            }//else
        }//else
        
        curRangeIndex=findRangeIndex(ranges,self->_rangeCount,(uint32_t)readFromPos);
        check(curRangeIndex>=0);
    }
    self->_curRangeIndex=curRangeIndex;
clear:
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq (%rdi), %rdx
movl 0x58(%rdx), %r14d
cmpq %rcx, %r12
jae 0x3e07b
movq %rcx, %r15
movq 0x38(%rdx), %r13
movq %rdx, (%rsp)
movslq %r14d, %rax
movl -0x4(%r13,%rax,4), %ecx
cmpq %rcx, %rsi
jb 0x3e010
leaq (%rsi,%r15), %rcx
subq %r12, %rcx
movl (%r13,%rax,4), %ebp
cmpq %rbp, %rcx
jbe 0x3e061
movq %rbp, %rbx
subq %rsi, %rbx
jae 0x3e034
movq 0x50(%rdx), %rax
testq %rax, %rax
je 0x3e093
xorl %r14d, %r14d
cmpl %esi, (%r13,%r14,4)
ja 0x3e02d
incq %r14
cmpq %r14, %rax
jne 0x3e01c
jmp 0x3e093
testl %r14d, %r14d
jns 0x3e05a
jmp 0x3e093
je 0x3e051
leaq (%r12,%rbx), %rcx
movq (%rsp), %rdi
movq %r12, %rdx
movl %r14d, %r8d
callq 0x3e114
movq (%rsp), %rdx
testb %al, %al
je 0x3e0be
incl %r14d
addq %rbx, %r12
movq %rbp, %rsi
cmpq %r15, %r12
jb 0x3dfea
jmp 0x3e07b
movq (%rsp), %rdi
movq %r12, %rdx
movq %r15, %rcx
movl %r14d, %r8d
callq 0x3e114
movq (%rsp), %rdx
testb %al, %al
je 0x3e0e9
movl %r14d, 0x58(%rdx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21bbd(%rip), %rdi     # 0x5fc57
callq 0x44e0
leaq 0x1bfaa(%rip), %rdi     # 0x5a050
leaq 0x219b1(%rip), %rsi     # 0x5fa5e
leaq 0x21b02(%rip), %rcx     # 0x5fbb6
movl $0xc6, %edx
callq 0x4200
leaq 0x21baa(%rip), %rdi     # 0x5fc6f
callq 0x44e0
leaq 0x1bf7f(%rip), %rdi     # 0x5a050
leaq 0x21986(%rip), %rsi     # 0x5fa5e
leaq 0x21ad7(%rip), %rcx     # 0x5fbb6
movl $0xbd, %edx
callq 0x4200
leaq 0x21bd3(%rip), %rdi     # 0x5fcc3
callq 0x44e0
leaq 0x1bf54(%rip), %rdi     # 0x5a050
leaq 0x2195b(%rip), %rsi     # 0x5fa5e
leaq 0x21aac(%rip), %rcx     # 0x5fbb6
movl $0xb8, %edx
callq 0x4200