// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp
// Function: int const* hdiff_private::(anonymous namespace)::_lower_bound<int>(int const*, int const*, unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, unsigned long)
inline static const T* _lower_bound(const T* rbegin,const T* rend,
                                        const TChar* str,const TChar* str_end,
                                        const TChar* src_begin,const TChar* src_end,
                                        size_t min_eq=0){
#ifdef _SA_MATCHBY_STD_LOWER_BOUND
        return std::lower_bound<const T*,StringToken,const TSuffixString_compare&>
                    (rbegin,rend,StringToken(str,str_end),TSuffixString_compare(src_begin,src_end));
#else
        size_t left_eq=min_eq;
        size_t right_eq=min_eq;
        while (size_t len=(size_t)(rend-rbegin)) {
            const T* mid=__select_mid(rbegin,len);
            size_t eq_len=(left_eq<=right_eq)?left_eq:right_eq;
            const TChar* vs=str+eq_len;
            const TChar* ss=src_begin+(*mid)+eq_len;
            bool is_less;
            while (true) {
                if (vs==str_end) { is_less=false; break; };
                if (ss==src_end) { is_less=true;  break; };
                TInt sub=(*ss)-(*vs);
                if (!sub) {
                    ++vs;
                    ++ss;
                    ++eq_len;
                    const int kMaxCmpLength_forLimitRangeDiff=1024*8; 
                    if (eq_len<kMaxCmpLength_forLimitRangeDiff) //only for optimize limitRange match speed
                        continue;
                    else
                        return mid;
                }else{
                    is_less=(sub<0);
                    break;
                }
            }
            if (is_less){
                left_eq=eq_len;
                rbegin=mid+1;
            }else{
                right_eq=eq_len;
                rend=mid;
            }
        }
        return rbegin;
#endif
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x3a7b4
movq -0x50(%rbp), %rsi
leaq -0x10(%rbp), %rdi
callq 0x3a7d0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
ja 0x3a6bd
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x3a6c8
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x3a705
movb $0x0, -0x71(%rbp)
jmp 0x3a783
movq -0x70(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x3a715
movb $0x1, -0x71(%rbp)
jmp 0x3a783
movq -0x70(%rbp), %rax
movzbl (%rax), %eax
movq -0x68(%rbp), %rcx
movzbl (%rcx), %ecx
subl %ecx, %eax
cltq
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x3a776
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movl $0x2000, -0x84(%rbp)    # imm = 0x2000
cmpq $0x2000, -0x60(%rbp)    # imm = 0x2000
jae 0x3a76c
jmp 0x3a6f5
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3a7bc
cmpq $0x0, -0x80(%rbp)
setl %al
andb $0x1, %al
movb %al, -0x71(%rbp)
testb $0x1, -0x71(%rbp)
je 0x3a79f
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x10(%rbp)
jmp 0x3a7af
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x3a677
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)