// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rcx, 0x20(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
testq %r8, %r8
je 0x13ab3
movq 0x8(%r12), %r13
jmp 0x13ab6
xorl %r13d, %r13d
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rsi, %rax
jbe 0x13cbe
leaq (,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %rbx
movq %r12, 0x40(%rsp)
leaq 0x1(%rsi), %rcx
movq %rcx, 0x50(%rsp)
cmpq %rax, %rcx
jae 0x13b12
leaq (%r14,%rbx), %r15
movq 0x20(%r14,%rbx), %rbp
testq %r12, %r12
jne 0x13b28
jmp 0x13bee
leaq (%rsi,%rsi,2), %rax
testq %r12, %r12
je 0x13bde
movq 0x10(%r12), %rbp
leaq (%r14,%rax,8), %r15
movq 0x8(%r14,%rbx), %rax
movq %rax, %rdx
subq %r13, %rdx
movq (%r15), %rcx
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
testq %rdx, %rdx
jle 0x13b7a
subq %rdx, %rcx
movq %rcx, 0x28(%rsp)
subq %rdx, %rax
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq (%r12), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *0x8(%rdi)
movq 0x8(%r14,%rbx), %r13
subq 0x10(%rsp), %r13
movq 0x8(%r14,%rbx), %rax
movq (%r15), %rcx
movq 0x10(%r14,%rbx), %rdx
addq %rdx, %rax
movq %rbp, %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 0x13bee
movq %rcx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq (%r12), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *(%rdi)
movq 0x10(%r14,%rbx), %rbp
addq 0x8(%r14,%rbx), %rbp
addq 0x10(%rsp), %rbp
jmp 0x13bee
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rbp
subq (%rcx), %rbp
leaq (%r14,%rax,8), %r15
movq (%r15), %r14
movq 0x8(%r15), %r12
leaq -0x1(%r14), %rdi
leaq -0x1(%r12), %rsi
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r13, %rcx
movq %rbp, 0x48(%rsp)
movq %rbp, %r8
movq 0x8(%rsp), %r9
callq 0x13d8a
movq %r13, %rcx
testq %rax, %rax
jle 0x13c43
subq %rax, %r14
movq %r14, (%r15)
subq %rax, %r12
movq %r12, 0x8(%r15)
movq 0x10(%r15), %rbp
addq %rax, %rbp
movq %rbp, 0x10(%r15)
jmp 0x13c47
movq 0x10(%r15), %rbp
addq %rbp, %r14
leaq (%r12,%rbp), %r13
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %edx
movq 0x48(%rsp), %r8
movq 0x8(%rsp), %r9
callq 0x13d8a
testq %rax, %rax
jle 0x13c83
addq %rbp, %rax
movq %rax, 0x10(%r15)
addq %r12, %rax
movq %rax, %r13
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %rbx
movq 0x50(%rsp), %rcx
movq %rcx, %rsi
cmpq %rax, %rcx
movq 0x40(%rsp), %r12
jb 0x13af1
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq