// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: (anonymous namespace)::_select_cover(std::vector<(anonymous namespace)::TOldCover, std::allocator<(anonymous namespace)::TOldCover>>&, unsigned long, (anonymous namespace)::TDiffData const&, int, hdiff_private::TCompressDetect&, hdiff_private::TCompressDetect&, (anonymous namespace)::TDiffLimit*, bool)
static void _select_cover(std::vector<TOldCover>& covers,size_t cover_begin,const TDiffData& diff,int kMinSingleMatchScore,
                          TCompressDetect& nocover_detect,TCompressDetect& cover_detect,
                          TDiffLimit* diffLimit,bool isCanExtendCover){
    TOldCover lastCover(0,0,0);
    if (diffLimit)
        lastCover=diffLimit->lastCover_back;
    const size_t coverSize_old=covers.size();
    size_t insertIndex=cover_begin;
    for (size_t i=cover_begin;i<coverSize_old;++i){
        if (covers[i].length<=0) continue;//处理已经del的.
        bool isNeedSave=false;
        bool isCanLink=false;
        if (isCanExtendCover&&(!isNeedSave)){//向前合并可能.
            if ((insertIndex>cover_begin)&&(covers[insertIndex-1].isCanLink(covers[i]))){
                if (diffLimit){
                    const TOldCover& fc=covers[insertIndex-1];
                    hpatch_TCover cover={(size_t)(fc.oldPos+fc.length),(size_t)(fc.newPos+fc.length),
                                         (size_t)fc.linkSpaceLength(covers[i])};
                    if (diffLimit->listener->limitCover(diffLimit->listener,&cover,0)){
                        isCanLink=true;
                        isNeedSave=true;
                    }
                }else{
                    isCanLink=true;
                    isNeedSave=true;
                }
            }
        }
        if (isCanExtendCover&&(i+1<coverSize_old)){//查询向后合并可能link
            for (size_t j=i+1;j<coverSize_old; ++j) {
                if (!covers[i].isCanLink(covers[j])) break;
                if (diffLimit){
                    const TOldCover& fc=covers[i];
                    hpatch_TCover cover={(size_t)(fc.oldPos+fc.length),(size_t)(fc.newPos+fc.length),
                                         (size_t)fc.linkSpaceLength(covers[j])};
                    if (diffLimit->listener->limitCover(diffLimit->listener,&cover,0)){
                        covers[i].Link(covers[j]);
                        covers[j].length=0;//del
                    }else{
                        break;
                    }
                }else{
                    covers[i].Link(covers[j]);
                    covers[j].length=0;//del
                }

            }
        }
        if (!isNeedSave){//单覆盖是否保留.
            TInt noCoverCost=nocover_detect.cost(diff.newData+covers[i].newPos,covers[i].length);
            TInt coverCost=cover_detect.cost(diff.newData+covers[i].newPos,covers[i].length,
                                             diff.oldData+covers[i].oldPos);
            TInt coverSorce=noCoverCost-coverCost-getCoverCtrlCost(covers[i],lastCover);
            isNeedSave=(coverSorce>=kMinSingleMatchScore);
        }
        
        if (isNeedSave){
            if (isCanLink){//link合并.
                covers[insertIndex-1].Link(covers[i]);
                cover_detect.add_chars(diff.newData+lastCover.newPos+lastCover.length,
                                       covers[insertIndex-1].length-lastCover.length,
                                       diff.oldData+lastCover.oldPos+lastCover.length);
            }else{
                covers[insertIndex++]=covers[i];
                nocover_detect.add_chars(diff.newData+lastCover.newPos+lastCover.length,
                                         covers[i].newPos-(lastCover.newPos+lastCover.length));
                cover_detect.add_chars(diff.newData+covers[i].newPos,covers[i].length,
                                       diff.oldData+covers[i].oldPos);
            }
            lastCover=covers[insertIndex-1];
        }
    }
    covers.resize(insertIndex);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x28(%rsp)
movq %r8, 0x48(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
movq 0xb0(%rsp), %r10
testq %r10, %r10
je 0x13e79
movq 0x38(%r10), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%r10), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%r10), %rdi
jmp 0x13e8d
xorl %edi, %edi
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq 0x8(%rax), %rax
subq %rdx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbp
cmpq %rsi, %rbp
jbe 0x1437d
movq %rdi, 0x30(%rsp)
movslq %ecx, %rax
movq %rax, 0x70(%rsp)
movq %rsi, %r15
movq %rsi, %r12
movq %rsi, 0x50(%rsp)
leaq (%r12,%r12,2), %r13
cmpq $0x0, 0x10(%rdx,%r13,8)
jle 0x13f74
cmpq %rsi, %r15
seta %al
andb 0xb8(%rsp), %al
cmpb $0x1, %al
movq %r15, 0x38(%rsp)
jne 0x13f7f
leaq (%rdx,%r13,8), %rdi
leaq (%r15,%r15,2), %r8
movq (%rdi), %rax
movq -0x18(%rdx,%r8,8), %rsi
movq -0x10(%rdx,%r8,8), %rcx
movq 0x8(%rdi), %rdi
addq %rsi, %rdi
leaq (%rcx,%rax), %r9
cmpq %r9, %rdi
setne %r9b
movq -0x8(%rdx,%r8,8), %rdx
addq %rdx, %rsi
subq %rsi, %rax
cmpq $0x200, %rax            # imm = 0x200
setge %dil
orb %r9b, %dil
movl %edi, %r15d
xorb $0x1, %r15b
testq %r10, %r10
je 0x13f82
testb %dil, %dil
jne 0x13f82
movq %rsi, 0x58(%rsp)
addq %rdx, %rcx
movq %rcx, 0x60(%rsp)
movq %rax, 0x68(%rsp)
movq (%r10), %rdi
leaq 0x58(%rsp), %rsi
xorl %edx, %edx
callq *(%rdi)
movq 0xb0(%rsp), %r10
movl %eax, %r15d
jmp 0x13f82
incq %r12
movq %r12, %rax
jmp 0x1436f
xorl %r15d, %r15d
leaq 0x1(%r12), %rax
movq %rax, 0x40(%rsp)
cmpq %rbp, %rax
setae %al
movb 0xb8(%rsp), %cl
xorb $0x1, %cl
orb %al, %cl
jne 0x14088
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq 0x28(,%r13,8), %rbx
movq 0x40(%rsp), %r14
movq -0x10(%rax,%rbx), %rcx
movq (%rax,%r13,8), %rsi
movq 0x8(%rax,%r13,8), %rdx
movq -0x8(%rax,%rbx), %rdi
addq %rsi, %rdi
leaq (%rdx,%rcx), %r8
cmpq %r8, %rdi
jne 0x14088
movq 0x10(%rax,%r13,8), %rdi
leaq (%rsi,%rdi), %r9
movq %rcx, %r8
subq %r9, %r8
cmpq $0x1ff, %r8             # imm = 0x1FF
jg 0x14088
testq %r10, %r10
je 0x1405b
movq %r9, 0x58(%rsp)
addq %rdi, %rdx
movq %rdx, 0x60(%rsp)
movq %r8, 0x68(%rsp)
movq (%r10), %rdi
leaq 0x58(%rsp), %rsi
xorl %edx, %edx
callq *(%rdi)
testb %al, %al
je 0x14088
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rdx
movq -0x10(%rax,%rbx), %rcx
movq -0x8(%rax,%rbx), %rsi
addq %rdx, %rsi
movq 0x8(%rax,%r13,8), %rdi
addq %rcx, %rdi
cmpq %rdi, %rsi
jne 0x143bb
subq %rdx, %rcx
movq 0xb0(%rsp), %r10
jge 0x14064
jmp 0x1439c
subq %rsi, %rcx
jl 0x1439c
leaq (%rax,%r13,8), %rdx
addq (%rax,%rbx), %rcx
movq %rcx, 0x10(%rdx)
movq $0x0, (%rax,%rbx)
incq %r14
addq $0x18, %rbx
cmpq %rbp, %r14
jb 0x13fb9
testb %r15b, %r15b
je 0x14102
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %r15
leaq (%r15,%r15,2), %rcx
movq -0x18(%rax,%rcx,8), %rsi
movq (%rax,%r13,8), %rdx
movq 0x8(%rax,%r13,8), %rdi
addq %rsi, %rdi
movq -0x10(%rax,%rcx,8), %r8
addq %rdx, %r8
cmpq %r8, %rdi
jne 0x143bb
subq %rsi, %rdx
jl 0x1439c
leaq (%rax,%rcx,8), %rcx
leaq (%rax,%r13,8), %rax
addq 0x10(%rax), %rdx
movq %rdx, -0x8(%rcx)
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rsi
addq (%rax), %rsi
movq 0x30(%rsp), %rdi
addq %rdi, %rsi
subq %rdi, %rdx
movq 0x18(%rsp), %rcx
addq 0x10(%rax), %rcx
addq %rdi, %rcx
jmp 0x14329
movq 0x20(%rsp), %r14
movq (%r14), %rsi
movq 0x8(%rsp), %rbx
movq (%rbx), %rax
shlq $0x3, %r12
leaq (%r12,%r12,2), %r12
addq 0x8(%rax,%r12), %rsi
movq 0x10(%rax,%r12), %rdx
movq 0x48(%rsp), %rdi
xorl %ecx, %ecx
callq 0x1d436
movq %rax, %r15
movq (%rbx), %rax
movq (%r14), %rsi
addq 0x8(%rax,%r12), %rsi
movq 0x10(%r14), %rcx
movq 0x10(%rax,%r12), %rdx
addq (%rax,%r12), %rcx
movq 0x28(%rsp), %rdi
callq 0x1d436
movq (%rbx), %rdx
movq (%rdx,%r12), %rcx
subq 0x18(%rsp), %rcx
movq %rcx, %rsi
negq %rsi
cmovsq %rcx, %rsi
movq %rsi, %rcx
shrq $0x37, %rcx
movl $0x9, %ecx
movl $0x9, %edi
jne 0x141ce
leaq (%rsi,%rsi), %rdi
movq %rsi, %r8
shrq $0x1b, %r8
xorl %r9d, %r9d
cmpq $0x8000000, %rsi        # imm = 0x8000000
setae %r9b
cmovbq %rdi, %r8
leal 0x1(,%r9,4), %esi
movq %r8, %r10
shrq $0xe, %r10
cmpq $0x4000, %r8            # imm = 0x4000
cmovbq %r8, %r10
leal 0x3(,%r9,4), %r8d
cmovbl %esi, %r8d
xorl %edi, %edi
cmpq $0x7f, %r10
seta %dil
addl %r8d, %edi
leaq (%rdx,%r12), %rsi
movq 0x10(%rsi), %r8
movabsq $0x100000000000000, %r9 # imm = 0x100000000000000
cmpq %r9, %r8
jae 0x14230
movq %r8, %rcx
shrq $0x1c, %rcx
xorl %r9d, %r9d
cmpq $0x10000000, %r8        # imm = 0x10000000
setae %r9b
cmovbq %r8, %rcx
leal 0x1(,%r9,4), %r8d
movq %rcx, %r10
shrq $0xe, %r10
cmpq $0x4000, %rcx           # imm = 0x4000
cmovbq %rcx, %r10
leal 0x3(,%r9,4), %r9d
cmovbl %r8d, %r9d
xorl %ecx, %ecx
cmpq $0x7f, %r10
seta %cl
addl %r9d, %ecx
movq 0x8(%rsi), %r9
subq 0x10(%rsp), %r9
movl $0x9, %r8d
movabsq $0x100000000000000, %r10 # imm = 0x100000000000000
cmpq %r10, %r9
jae 0x1429b
movq %r9, %r8
shrq $0x1c, %r8
xorl %r10d, %r10d
cmpq $0x10000000, %r9        # imm = 0x10000000
setae %r10b
cmovbq %r9, %r8
leal 0x1(,%r10,4), %r9d
movq %r8, %r11
shrq $0xe, %r11
cmpq $0x4000, %r8            # imm = 0x4000
cmovbq %r8, %r11
leal 0x3(,%r10,4), %r10d
cmovbl %r9d, %r10d
xorl %r8d, %r8d
cmpq $0x7f, %r11
seta %r8b
addl %r10d, %r8d
addl %edi, %ecx
addl %r8d, %ecx
addq %rcx, %rax
subq %rax, %r15
cmpq 0x70(%rsp), %r15
jge 0x142c4
movq 0x50(%rsp), %rsi
movq 0xb0(%rsp), %r10
movq 0x38(%rsp), %r15
jmp 0x1436a
movq 0x38(%rsp), %r15
leaq (%r15,%r15,2), %rax
incq %r15
movq 0x10(%rsi), %rcx
movq %rcx, 0x10(%rdx,%rax,8)
movups (%rsi), %xmm0
movups %xmm0, (%rdx,%rax,8)
movq 0x10(%rsp), %rcx
addq 0x30(%rsp), %rcx
movq 0x20(%rsp), %r14
movq (%r14), %rsi
addq %rcx, %rsi
movq 0x8(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rax,%r12), %rdx
subq %rcx, %rdx
movq 0x48(%rsp), %rdi
xorl %ecx, %ecx
callq 0x1d360
movq (%rbx), %rax
movq (%r14), %rsi
addq 0x8(%rax,%r12), %rsi
movq 0x10(%r14), %rcx
movq 0x10(%rax,%r12), %rdx
addq (%rax,%r12), %rcx
movq 0x28(%rsp), %rdi
callq 0x1d360
movq 0x8(%rsp), %rax
movq (%rax), %rdx
leaq (%r15,%r15,2), %rax
movq -0x18(%rdx,%rax,8), %rcx
movq %rcx, 0x18(%rsp)
movq -0x10(%rdx,%rax,8), %rcx
movq %rcx, 0x10(%rsp)
movq -0x8(%rdx,%rax,8), %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rsi
movq 0xb0(%rsp), %r10
movq 0x40(%rsp), %rax
movq %rax, %r12
cmpq %rbp, %rax
jne 0x13ecf
jmp 0x14380
movq %rsi, %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x12098
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47ab7(%rip), %rdi     # 0x5be5a
leaq 0x4758d(%rip), %rsi     # 0x5b937
leaq 0x47a6a(%rip), %rcx     # 0x5be1b
movl $0x5e, %edx
callq 0x4200
leaq 0x47a47(%rip), %rdi     # 0x5be09
leaq 0x4756e(%rip), %rsi     # 0x5b937
leaq 0x47a4b(%rip), %rcx     # 0x5be1b
movl $0x5d, %edx
callq 0x4200