// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp
// Function: hdiff_private::TNewDataDiffStream::_read(hpatch_TStreamInput const*, unsigned long long, unsigned char*, unsigned char*)
hpatch_BOOL TNewDataDiffStream::_read(const hpatch_TStreamInput* stream,hpatch_StreamPos_t readFromPos,
                                      unsigned char* out_data,unsigned char* out_data_end){
    TNewDataDiffStream* self=(TNewDataDiffStream*)stream->streamImport;
    if (readFromPos==0){
        self->curNewPos=0;
        self->curNewPos_end=0;
        self->readedCoverCount=self->_coveri;
        self->lastNewEnd=self->_newDataPos;
    }else{
        checki(self->_readFromPos_back==readFromPos,"TNewDataDiffStream::read() readFromPos error!");
    }
    self->_readFromPos_back=readFromPos+(size_t)(out_data_end-out_data);
    
    size_t n=self->covers.coverCount();
    while (out_data<out_data_end) {
        hpatch_StreamPos_t curLen=self->curNewPos_end-self->curNewPos;
        if (curLen>0){
            size_t readLen=(out_data_end-out_data);
            if (readLen>curLen) readLen=(size_t)curLen;
            if (!self->newData->read(self->newData,self->curNewPos,
                                     out_data,out_data+readLen)) return hpatch_FALSE;
            out_data+=readLen;
            self->curNewPos+=readLen;
        }else{
            TCover curCover;
            if (self->readedCoverCount==n){
                if (self->lastNewEnd>=self->newData->streamSize) return hpatch_FALSE; //error;
                curCover.newPos=self->newData->streamSize;
                curCover.length=0;
                curCover.oldPos=0;
            }else{
                self->covers.covers(self->readedCoverCount,&curCover);
                ++self->readedCoverCount;
            }
            assert(self->lastNewEnd<=curCover.newPos);
            self->curNewPos=self->lastNewEnd;
            self->curNewPos_end=curCover.newPos;
            self->lastNewEnd=curCover.newPos+curCover.length;
        }
    }
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq (%rdi), %r15
testq %rsi, %rsi
je 0x1eeb0
cmpq %rsi, 0x50(%r15)
je 0x1eec9
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %rbx
leaq 0x336b4(%rip), %rsi     # 0x52546
movq %rax, %rdi
callq 0x4120
movq 0x56147(%rip), %rsi     # 0x74fe8
movq 0x56110(%rip), %rdx     # 0x74fb8
movq %rbx, %rdi
callq 0x45b0
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movdqu 0x58(%r15), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, 0x40(%r15)
subq %rdx, %rsi
addq %rbx, %rsi
movq %rsi, 0x50(%r15)
movq 0x20(%r15), %rax
movq 0x18(%rax), %r12
pushq $0x1
popq %rbp
cmpq %rbx, %rdx
jae 0x1ef8a
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rax
subq %rsi, %rax
jne 0x1ef5d
movq 0x48(%r15), %rsi
cmpq %r12, %rsi
jne 0x1ef12
movq 0x28(%r15), %rax
movq 0x40(%r15), %rsi
movq 0x8(%rax), %rax
xorl %ecx, %ecx
cmpq %rax, %rsi
jb 0x1ef47
jmp 0x1ef88
movq 0x20(%r15), %rax
movq 0x10(%rax), %rcx
cmpb $0x1, 0x20(%rax)
jne 0x1ef2e
imulq $0xc, %rsi, %rdi
movl 0x4(%rcx,%rdi), %eax
movl 0x8(%rcx,%rdi), %ecx
jmp 0x1ef3c
imulq $0x18, %rsi, %rdi
movq 0x8(%rcx,%rdi), %rax
movq 0x10(%rcx,%rdi), %rcx
incq %rsi
movq %rsi, 0x48(%r15)
movq 0x40(%r15), %rsi
cmpq %rax, %rsi
ja 0x1ef9b
movq %rsi, 0x30(%r15)
movq %rax, 0x38(%r15)
addq %rax, %rcx
movq %rcx, 0x40(%r15)
jmp 0x1eeef
movq %rbx, %r13
subq %rdx, %r13
cmpq %rax, %r13
cmovaeq %rax, %r13
movq 0x28(%r15), %rdi
leaq (%rdx,%r13), %r14
movq %r14, %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x1ef88
addq %r13, 0x30(%r15)
movq %r14, %rdx
jmp 0x1eede
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x335d2(%rip), %rdi     # 0x52574
leaq 0x333e8(%rip), %rsi     # 0x52391
leaq 0x335e6(%rip), %rcx     # 0x52596
movl $0xe8, %edx
callq 0x4230
movq %rax, %r14
movq %rbx, %rdi
callq 0x4290
movq %r14, %rdi
callq 0x4600
nop