// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: (anonymous namespace)::getCanExtendLength(long, long, int, long, long, (anonymous namespace)::TDiffData const&, unsigned long)
static TInt getCanExtendLength(TInt oldPos,TInt newPos,int inc,TInt newPos_min,TInt lastNewEnd,
                                   const TDiffData& diff,const TFixedFloatSmooth kExtendMinSameRatio){
        static const unsigned int kSmoothLength=4;

        TFixedFloatSmooth curBestSameRatio=0;
        TInt curBestLength=0;
        TUInt curSameCount=0;
        const TFixedFloatSmooth kLimitSameCount=(~(TFixedFloatSmooth)0)/kFixedFloatSmooth_base;
        for (TUInt length=1; (oldPos>=0)&&(oldPos<(diff.oldData_end-diff.oldData))
             &&(newPos>=newPos_min)&&(newPos<lastNewEnd); ++length,oldPos+=inc,newPos+=inc) {
            if (diff.oldData[oldPos]==diff.newData[newPos]){
                ++curSameCount;
                
                if (curSameCount>= kLimitSameCount) break; //for curSameCount*kFixedFloatSmooth_base
                const TFixedFloatSmooth curSameRatio= (curSameCount*kFixedFloatSmooth_base)
                                                      /(length+kSmoothLength);
                if (curSameRatio>=curBestSameRatio){
                    curBestSameRatio=curSameRatio;
                    curBestLength=length;
                }
            }
        }
        if ((curBestSameRatio<kExtendMinSameRatio)||(curBestLength<=2)){
            curBestLength=0;
        }
        
        return curBestLength;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movabsq $0x3fffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFF
movq %rax, -0x50(%rbp)
movq $0x1, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x8(%rbp)
movb %al, -0x61(%rbp)
jl 0x24607
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
subq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x61(%rbp)
jge 0x24607
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x61(%rbp)
jl 0x24607
movq -0x10(%rbp), %rax
cmpq -0x28(%rbp), %rax
setl %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x24613
jmp 0x246b4
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq -0x10(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x24689
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movabsq $0x3fffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFF
cmpq %rax, -0x48(%rbp)
jb 0x24654
jmp 0x246b4
movq -0x48(%rbp), %rax
shlq $0xa, %rax
movq -0x58(%rbp), %rcx
addq $0x4, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x24687
movq -0x60(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x24689
jmp 0x2468b
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movslq -0x14(%rbp), %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movslq -0x14(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x245bd
movq -0x38(%rbp), %rax
cmpq 0x10(%rbp), %rax
jb 0x246c5
cmpq $0x2, -0x40(%rbp)
jg 0x246cd
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)