// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/match_block.cpp
// Function: void hdiff_private::_clipCover<hpatch_TCover32, unsigned int, true>(hpatch_TCover32*, unsigned long, std::vector<hpatch_TCover, std::allocator<hpatch_TCover>> const&, std::vector<hpatch_TCover, std::allocator<hpatch_TCover>>&)
static 
    void _clipCover(TCover* pcovers,size_t coverCount,
                    const std::vector<TPackedCover>& packedCovers,
                    std::vector<hpatch_TCover>& out_clipCovers){
        if (packedCovers.empty()) return;
        const TPackedCover* clipCur=packedCovers.data();
        hpatch_StreamPos_t  clipPos=clipCur->newPos;
        hpatch_StreamPos_t  unpackLen=0;
        const TPackedCover* clipEnd=clipCur+packedCovers.size();
        for (size_t i=0;i<coverCount;++i){
            TCover& s=pcovers[i];
            hpatch_StreamPos_t sbegin=_cover_pos(isNew,&s);
            while (sbegin>=clipPos){
                _check(clipCur!=clipEnd,"error clip cover");
                unpackLen=clipCur->oldPos-clipCur->newPos;
                ++clipCur;
                if (clipCur!=clipEnd)
                    clipPos=clipCur->newPos;
                else
                    clipPos=hpatch_kNullStreamPos;
            }
            const TPackedCover* clipCuri=clipCur;
            hpatch_StreamPos_t  clipPosi=clipPos;
            hpatch_StreamPos_t  unpackLeni=unpackLen;
            do{
                if (sbegin+s.length<=clipPosi){
                    _cover_pos(isNew,&s)+=(TPos)unpackLeni;
                    break; //ok next cover
                }
                hpatch_TCover _c={s.oldPos,s.newPos,clipPosi-sbegin};
                _cover_pos(isNew,&_c)+=(TPos)unpackLeni;
                out_clipCovers.push_back(_c);
                s.oldPos+=(TPos)_c.length;
                s.newPos+=(TPos)_c.length;
                s.length-=(TPos)_c.length;
                sbegin=_cover_pos(isNew,&s);
                while (sbegin>=clipPosi){
                    _check(clipCuri!=clipEnd,"error clip cover");
                    unpackLeni=clipCuri->oldPos-clipCuri->newPos;
                    ++clipCuri;
                    if (clipCuri!=clipEnd)
                        clipPosi=clipCuri->newPos;
                    else
                        clipPosi=hpatch_kNullStreamPos;
                }
            } while (true);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x33350
testb $0x1, %al
jne 0x325aa
jmp 0x325af
jmp 0x3288b
movq -0x18(%rbp), %rdi
callq 0x34630
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2c560
movq %rax, %rcx
movq -0xa0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x3288b
movq -0x8(%rbp), %rax
imulq $0xc, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x326e2
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x3269e
movl $0x10, %edi
callq 0x41e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
leaq 0x7d776(%rip), %rsi     # 0xafdd6
callq 0x4140
jmp 0x32667
movq -0xa8(%rbp), %rdi
movq 0xb397b(%rip), %rsi     # 0xe5ff0
movq 0xb3944(%rip), %rdx     # 0xe5fc0
callq 0x4630
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x42e0
jmp 0x32894
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
subq 0x8(%rcx), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x326d5
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x326dd
movq $-0x1, -0x30(%rbp)
jmp 0x3262a
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
cmpq -0x78(%rbp), %rax
ja 0x32723
movq -0x80(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
jmp 0x32878
movq -0x50(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movl %eax, %eax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2b840
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x88(%rbp), %rax
movl %eax, %edx
movq -0x50(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x78(%rbp), %rax
jb 0x3286a
movq -0x70(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x32826
movl $0x10, %edi
callq 0x41e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
leaq 0x7d5eb(%rip), %rsi     # 0xafdd6
callq 0x4140
jmp 0x327f2
movq -0xb0(%rbp), %rdi
movq 0xb37f0(%rip), %rsi     # 0xe5ff0
movq 0xb37b9(%rip), %rdx     # 0xe5fc0
callq 0x4630
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x42e0
jmp 0x32894
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq -0x70(%rbp), %rcx
subq 0x8(%rcx), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x3285d
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x32865
movq $-0x1, -0x78(%rbp)
jmp 0x327b5
jmp 0x3286c
movb $0x1, %al
testb $0x1, %al
jne 0x326fa
jmp 0x32878
jmp 0x3287a
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x32601
addq $0xb0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4680
nopl (%rax)