// File: /workspace/github_cpp_makefile_star2_O3/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 0x23908
cmpq %rsi, 0x50(%r15)
je 0x23921
movl $0x10, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x39b3c(%rip), %rsi     # 0x5d426
movq %rax, %rdi
callq 0x4110
movq 0x586ef(%rip), %rsi     # 0x7bfe8
movq 0x586b8(%rip), %rdx     # 0x7bfb8
movq %rbx, %rdi
callq 0x4590
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)
movl $0x1, %ebp
cmpq %rbx, %rdx
jae 0x239f6
movq 0x20(%r15), %rax
movq 0x18(%rax), %r12
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rcx
cmpq %rsi, %rcx
jne 0x239b9
movq 0x48(%r15), %rax
cmpq %r12, %rax
jne 0x2396f
movq 0x28(%r15), %rcx
movq 0x40(%r15), %rsi
movq 0x8(%rcx), %rcx
xorl %edi, %edi
cmpq %rcx, %rsi
jb 0x239a0
jmp 0x239f4
movq 0x20(%r15), %rcx
movq 0x10(%rcx), %rsi
cmpb $0x1, 0x20(%rcx)
leaq (%rax,%rax,2), %rdi
jne 0x2398b
movl 0x4(%rsi,%rdi,4), %ecx
movl 0x8(%rsi,%rdi,4), %edi
jmp 0x23995
movq 0x8(%rsi,%rdi,8), %rcx
movq 0x10(%rsi,%rdi,8), %rdi
incq %rax
movq %rax, 0x48(%r15)
movq 0x40(%r15), %rsi
cmpq %rcx, %rsi
ja 0x23a07
movq %rsi, 0x30(%r15)
movq %rcx, 0x38(%r15)
addq %rcx, %rdi
movq %rdi, 0x40(%r15)
cmpq %rsi, %rcx
je 0x23952
subq %rsi, %rcx
movq %rbx, %r13
subq %rdx, %r13
cmpq %rcx, %r13
cmovaeq %rcx, %r13
movq 0x28(%r15), %rdi
leaq (%rdx,%r13), %r14
movq %r14, %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x239f4
addq 0x30(%r15), %r13
movq %r13, 0x30(%r15)
movq %r13, %rsi
movq %r14, %rdx
cmpq %rbx, %r14
jb 0x23945
jmp 0x239f6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x39a46(%rip), %rdi     # 0x5d454
leaq 0x3985c(%rip), %rsi     # 0x5d271
leaq 0x39a5a(%rip), %rcx     # 0x5d476
movl $0xe8, %edx
callq 0x4200
movq %rax, %r14
movq %rbx, %rdi
callq 0x4260
movq %r14, %rdi
callq 0x45e0
nop