// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp
// Function: hdiff_private::TNewDataSubDiffCoverStream::readTo(unsigned long long, unsigned char*, unsigned char*)
hpatch_BOOL TNewDataSubDiffCoverStream::readTo(hpatch_StreamPos_t readFromPos,
                                               unsigned char* out_data,unsigned char* out_data_end){
    // newStream:[       |                                          |              ]
    //              cover.newPos                        cover.newPos+cover.length
    // _cache:           |  skipLen  [  curDataLen  ]  inStreamLen  |
    //                                          |
    //                                     readFromPos   
    while (out_data!=out_data_end){
        hpatch_StreamPos_t skipLen=cover.length-(curDataLen+inStreamLen);
        if ((readFromPos<skipLen)||(readFromPos>=(skipLen+curDataLen))){
            if (!_updateCache(readFromPos)) return hpatch_FALSE;
            skipLen=cover.length-(curDataLen+inStreamLen);
        }
        size_t srcPos=(size_t)(readFromPos-skipLen);
        size_t len=std::min((size_t)(curDataLen-srcPos),(size_t)(out_data_end-out_data));
        for (size_t i=0;i<len;i++)
            out_data[i]=newData[srcPos+i]-oldData[srcPos+i];
        readFromPos+=len;
        out_data+=len;
    }
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x4dd78
movq -0x60(%rbp), %rdx
movq 0x58(%rdx), %rax
movq 0x30(%rdx), %rcx
addq 0x28(%rdx), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x4dc94
movq -0x60(%rbp), %rdx
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
addq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jb 0x4dcc9
movq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4dd90
cmpl $0x0, %eax
jne 0x4dcb2
movl $0x0, -0x4(%rbp)
jmp 0x4dd7f
movq -0x60(%rbp), %rdx
movq 0x58(%rdx), %rax
movq 0x30(%rdx), %rcx
addq 0x28(%rdx), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rax
movq -0x18(%rbp), %rcx
subq -0x30(%rbp), %rcx
movq %rcx, -0x38(%rbp)
movq 0x30(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xe220
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x4dd5b
movq -0x60(%rbp), %rcx
movq 0x60(%rcx), %rax
movq -0x38(%rbp), %rdx
addq -0x58(%rbp), %rdx
movzbl (%rax,%rdx), %eax
movq 0x68(%rcx), %rcx
movq -0x38(%rbp), %rdx
addq -0x58(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x4dd10
movq -0x40(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x4dc50
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)