// File: /workspace/github_cpp_makefile_star2_O1/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 %rdx, %r14
movq (%rdi), %r12
testq %rsi, %rsi
je 0x23bb2
cmpq %rsi, 0x50(%r12)
je 0x23bcf
movl $0x10, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x398a2(%rip), %rsi     # 0x5d436
movq %rax, %rdi
callq 0x4110
movq 0x58445(%rip), %rsi     # 0x7bfe8
movq 0x5840e(%rip), %rdx     # 0x7bfb8
movq %rbx, %rdi
callq 0x4590
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r12)
movq 0x58(%r12), %rax
movq 0x60(%r12), %rcx
movq %rax, 0x48(%r12)
movq %rcx, 0x40(%r12)
subq %r14, %rsi
addq %rbx, %rsi
movq %rsi, 0x50(%r12)
movq 0x20(%r12), %rax
movq 0x18(%rax), %r13
cmpq %rbx, %r14
jae 0x23ca5
movq 0x30(%r12), %rsi
movq 0x38(%r12), %rax
subq %rsi, %rax
jne 0x23c19
movq 0x48(%r12), %rdx
cmpq %r13, %rdx
jne 0x23c46
movq 0x28(%r12), %rax
movq 0x8(%rax), %rcx
xorl %eax, %eax
cmpq %rcx, 0x40(%r12)
jb 0x23c75
jmp 0x23c93
movq %rbx, %rbp
subq %r14, %rbp
cmpq %rax, %rbp
cmovaeq %rax, %rbp
movq 0x28(%r12), %rdi
leaq (%r14,%rbp), %r15
movq %r14, %rdx
movq %r15, %rcx
callq *0x10(%rdi)
testl %eax, %eax
setne %al
je 0x23c93
addq %rbp, 0x30(%r12)
jmp 0x23c96
movq 0x20(%r12), %rcx
movq 0x10(%rcx), %rax
cmpb $0x1, 0x20(%rcx)
leaq (%rdx,%rdx,2), %rsi
jne 0x23c63
movl 0x4(%rax,%rsi,4), %ecx
movl 0x8(%rax,%rsi,4), %eax
jmp 0x23c6d
movq 0x8(%rax,%rsi,8), %rcx
movq 0x10(%rax,%rsi,8), %rax
incq %rdx
movq %rdx, 0x48(%r12)
movq 0x40(%r12), %rdx
cmpq %rcx, %rdx
ja 0x23cb9
movq %rdx, 0x30(%r12)
movq %rcx, 0x38(%r12)
addq %rcx, %rax
movq %rax, 0x40(%r12)
movb $0x1, %al
movq %r14, %r15
movq %r15, %r14
testb %al, %al
jne 0x23be3
xorl %eax, %eax
jmp 0x23caa
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x397a4(%rip), %rdi     # 0x5d464
leaq 0x395ba(%rip), %rsi     # 0x5d281
leaq 0x397b8(%rip), %rcx     # 0x5d486
movl $0xe8, %edx
callq 0x4200
movq %rax, %r14
movq %rbx, %rdi
callq 0x4260
movq %r14, %rdi
callq 0x45e0
nop