// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: (anonymous namespace)::extend_cover(std::vector<(anonymous namespace)::TOldCover, std::allocator<(anonymous namespace)::TOldCover>>&, unsigned long, (anonymous namespace)::TDiffData const&, unsigned long, (anonymous namespace)::TDiffLimit*)
static void extend_cover(std::vector<TOldCover>& covers,size_t cover_begin,const TDiffData& diff,
                         const TFixedFloatSmooth kExtendMinSameRatio,TDiffLimit* diffLimit=0){
    TInt lastNewEnd=diffLimit?diffLimit->newPos:0;
    for (size_t i=cover_begin; i<covers.size(); ++i) {
        TInt newPos_next;
        if (i+1<covers.size())
            newPos_next=covers[i+1].newPos;
        else
            newPos_next=diffLimit?diffLimit->newEnd:(TInt)(diff.newData_end-diff.newData);
        TOldCover& curCover=covers[i];
        if (diffLimit){
            TInt limit_front=std::min(curCover.newPos-lastNewEnd,curCover.oldPos);
            if (limit_front>0){
                hpatch_TCover cover={(size_t)(curCover.oldPos-limit_front),
                                     (size_t)(curCover.newPos-limit_front),(size_t)limit_front};
                hpatch_StreamPos_t lenLimit;
                diffLimit->listener->limitCover_front(diffLimit->listener,&cover,&lenLimit);
                lastNewEnd=curCover.newPos-(TInt)lenLimit;
            }

            TInt limit_back=newPos_next-(curCover.newPos+curCover.length);
            if ((curCover.oldPos+curCover.length)+limit_back>(diff.oldData_end-diff.oldData))
                limit_back=(diff.oldData_end-diff.oldData)-(curCover.oldPos+curCover.length);
            if (limit_back>0){
                hpatch_TCover cover={(size_t)(curCover.oldPos+curCover.length),
                                     (size_t)(curCover.newPos+curCover.length),(size_t)limit_back};
                hpatch_StreamPos_t lenLimit;
                diffLimit->listener->limitCover(diffLimit->listener,&cover,&lenLimit);
                newPos_next=(curCover.newPos+curCover.length)+ (TInt)lenLimit;
            }
        }
        //向前延伸.
        TInt extendLength_front=getCanExtendLength(curCover.oldPos-1,curCover.newPos-1,
                                                   -1,lastNewEnd,newPos_next,diff,kExtendMinSameRatio);
        if (extendLength_front>0){
            curCover.oldPos-=extendLength_front;
            curCover.newPos-=extendLength_front;
            curCover.length+=extendLength_front;
        }
        //向后延伸.
        TInt extendLength_back=getCanExtendLength(curCover.oldPos+curCover.length,
                                                  curCover.newPos+curCover.length,
                                                  1,lastNewEnd,newPos_next,diff,kExtendMinSameRatio);
        if (extendLength_back>0){
            curCover.length+=extendLength_back;
        }

        lastNewEnd=curCover.newPos+curCover.length;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movq %rcx, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, 0x40(%rsp)
testq %r8, %r8
je 0x108f4
movq 0x8(%rbx), %rbp
jmp 0x108f6
xorl %ebp, %ebp
imulq $0x18, %rsi, %r12
movq %rbx, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %rax
subq %r14, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rax, %rsi
jae 0x10ac1
leaq 0x1(%rsi), %rcx
movq %rcx, 0x48(%rsp)
cmpq %rax, %rcx
movq %r12, 0x50(%rsp)
jae 0x10948
imulq $0x18, %rsi, %r15
addq %r14, %r15
movq 0x20(%r14,%r12), %r13
testq %rbx, %rbx
jne 0x10959
jmp 0x10a1f
testq %rbx, %rbx
je 0x10a0d
movq 0x10(%rbx), %r13
leaq (%r14,%r12), %r15
movq 0x8(%r14,%r12), %rax
movq %rax, %rdx
subq %rbp, %rdx
movq (%r15), %rcx
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
testq %rdx, %rdx
jle 0x109aa
subq %rdx, %rcx
movq %rcx, 0x20(%rsp)
subq %rdx, %rax
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *0x8(%rdi)
movq 0x8(%r14,%r12), %rbp
subq 0x10(%rsp), %rbp
movq 0x8(%r14,%r12), %rax
movq (%r15), %rcx
movq 0x10(%r14,%r12), %rdx
addq %rdx, %rax
movq %r13, %rsi
subq %rax, %rsi
addq %rdx, %rcx
leaq (%rcx,%rsi), %rdi
movq 0x8(%rsp), %rdx
movq 0x18(%rdx), %r8
subq 0x10(%rdx), %r8
movq %r8, %rdx
subq %rcx, %rdx
cmpq %r8, %rdi
cmovleq %rsi, %rdx
testq %rdx, %rdx
jle 0x10a1f
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *(%rdi)
movq 0x10(%r14,%r12), %r13
addq 0x8(%r14,%r12), %r13
addq 0x10(%rsp), %r13
jmp 0x10a1f
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
subq (%rax), %r13
addq %r12, %r14
movq %r14, %r15
movq (%r15), %r14
movq 0x8(%r15), %r12
leaq -0x1(%r14), %rdi
leaq -0x1(%r12), %rsi
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
pushq $-0x1
popq %rdx
movq %rbp, %rcx
movq %r13, %r8
movq 0x8(%rsp), %r9
callq 0x10b8b
movq %rbp, %rcx
testq %rax, %rax
jle 0x10a6d
subq %rax, %r14
movq %r14, (%r15)
subq %rax, %r12
movq %r12, 0x8(%r15)
movq 0x10(%r15), %rbx
addq %rax, %rbx
movq %rbx, 0x10(%r15)
jmp 0x10a71
movq 0x10(%r15), %rbx
addq %rbx, %r14
leaq (%r12,%rbx), %rbp
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rdx
movq %r13, %r8
movq 0x8(%rsp), %r9
callq 0x10b8b
testq %rax, %rax
jle 0x10aa9
addq %rbx, %rax
movq %rax, 0x10(%r15)
addq %r12, %rax
movq %rax, %rbp
movq 0x50(%rsp), %r12
addq $0x18, %r12
movq 0x48(%rsp), %rsi
movq 0x38(%rsp), %rbx
jmp 0x108ff
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq