// File: /workspace/github_cpp_makefile_star2_O1/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, 0x28(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
testq %r8, %r8
je 0x13dbf
movq 0x8(%r12), %r15
jmp 0x13dc2
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rsi, %rax
jbe 0x13fcb
leaq (,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %rbx
movq %r12, 0x48(%rsp)
incq %rsi
cmpq %rax, %rsi
jae 0x13e0c
movq 0x20(%r13,%rbx), %r14
jmp 0x13e24
testq %r12, %r12
je 0x13e18
movq 0x10(%r12), %r14
jmp 0x13e24
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
movq %rsi, 0x50(%rsp)
testq %r12, %r12
je 0x13eff
movq (%r13,%rbx), %rcx
movq 0x8(%r13,%rbx), %rax
subq %r15, %rax
cmpq %rax, %rcx
cmovlq %rcx, %rax
testq %rax, %rax
jle 0x13e85
movq (%r13,%rbx), %rcx
subq %rax, %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%r13,%rbx), %rcx
subq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq (%r12), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq *0x8(%rdi)
movq 0x8(%r13,%rbx), %r15
subq 0x18(%rsp), %r15
movq 0x10(%r13,%rbx), %rcx
movq 0x8(%r13,%rbx), %rax
addq %rcx, %rax
addq (%r13,%rbx), %rcx
movq %r14, %rdx
movq 0x10(%rsp), %rdi
movq 0x18(%rdi), %rsi
subq 0x10(%rdi), %rsi
subq %rax, %rdx
movq %rsi, %rax
subq %rcx, %rax
addq %rdx, %rcx
cmpq %rsi, %rcx
cmovleq %rdx, %rax
testq %rax, %rax
jle 0x13eff
movq 0x10(%r13,%rbx), %rcx
movq (%r13,%rbx), %rdx
addq %rcx, %rdx
movq %rdx, 0x30(%rsp)
addq 0x8(%r13,%rbx), %rcx
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq (%r12), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq *(%rdi)
movq 0x10(%r13,%rbx), %r14
addq 0x8(%r13,%rbx), %r14
addq 0x18(%rsp), %r14
movq (%r13,%rbx), %r12
movq 0x8(%r13,%rbx), %rbp
leaq -0x1(%r12), %rdi
leaq -0x1(%rbp), %rsi
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r15, %rcx
movq %r14, %r8
movq 0x10(%rsp), %r9
callq 0x14097
testq %rax, %rax
jle 0x13f4a
subq %rax, %r12
movq %r12, (%r13,%rbx)
subq %rax, %rbp
movq %rbp, 0x8(%r13,%rbx)
addq %rax, 0x10(%r13,%rbx)
movq 0x8(%r13,%rbx), %rbp
movq 0x10(%r13,%rbx), %r12
movq (%r13,%rbx), %rdi
addq %r12, %rdi
leaq (%r12,%rbp), %rsi
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, %edx
movq %r15, %rcx
movq %r14, %r8
movq 0x10(%rsp), %r9
callq 0x14097
testq %rax, %rax
jle 0x13f8b
addq %r12, %rax
movq %rax, 0x10(%r13,%rbx)
addq 0x10(%r13,%rbx), %rbp
movq 0x20(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %rbx
movq %rbp, %r15
movq 0x50(%rsp), %rsi
cmpq %rax, %rsi
movq 0x48(%rsp), %r12
jb 0x13dfd
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq