// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp
// Function: hdiff_private::TSuffixString::build_cache(unsigned long)
void TSuffixString::build_cache(size_t threadNum){
    clear_cache();
#if (_SSTRING_FAST_MATCH>0)
    if (m_isUsedFastMatch) m_fastMatch.buildMatchCache(m_src_begin,m_src_end,threadNum);
#endif
    const size_t kUsedCacheMinSASize =2*(1<<20); //当字符串较大时再启用大缓存表.
    if (SASize()>kUsedCacheMinSASize){
        m_cached2char_range=new TChar[(256*256+1)*(isUseLargeSA()?sizeof(size_t):sizeof(TInt32))];
    }
    
    if (isUseLargeSA()){
        m_lower_bound=(t_lower_bound_func)_lower_bound_TInt;
        if (m_SA_large.empty()) return;
        m_cached_SA_begin=&m_SA_large[0];
        m_cached_SA_end=&m_SA_large[0]+m_SA_large.size();
        _build_range256((TInt*)m_cached_SA_begin,(TInt*)m_cached_SA_end,
                        m_src_begin,m_src_end,(const TInt**)&m_cached1char_range[0]);
        if (m_cached2char_range){
            _build_range((TInt*)m_cached_SA_begin,(TInt*)m_cached_SA_end,
                         m_src_begin,m_src_end,(TInt*)m_cached2char_range);
        }
    }else{
        m_lower_bound=(t_lower_bound_func)_lower_bound_TInt32;
        if (m_SA_limit.empty()) return;
        m_cached_SA_begin=&m_SA_limit[0];
        m_cached_SA_end=&m_SA_limit[0]+m_SA_limit.size();
        _build_range256((TInt32*)m_cached_SA_begin,(TInt32*)m_cached_SA_end,
                        m_src_begin,m_src_end,(const TInt32**)&m_cached1char_range[0]);
        if (m_cached2char_range){
            _build_range((TInt32*)m_cached_SA_begin,(TInt32*)m_cached_SA_end,
                         m_src_begin,m_src_end,(TInt32*)m_cached2char_range);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r15
callq 0x1811e
cmpb $0x1, 0x40(%r15)
jne 0x18405
leaq 0x48(%r15), %rdi
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rcx
callq 0x18728
movq (%r15), %rbx
movq 0x8(%r15), %r14
movq %r14, %r12
subq %rbx, %r12
cmpq $0x200001, %r12         # imm = 0x200001
jb 0x184c2
cmpq $0x7fffffff, %r12       # imm = 0x7FFFFFFF
movl $0x80008, %eax          # imm = 0x80008
movl $0x40004, %edi          # imm = 0x40004
cmovaq %rax, %rdi
callq 0x4030
movq %rax, 0x878(%r15)
testq $-0x80000000, %r12      # imm = 0x80000000
je 0x184c2
leaq 0x4a0(%rip), %rax       # 0x188f0
movq %rax, 0x880(%r15)
movq 0x28(%r15), %rax
movq 0x30(%r15), %r12
cmpq %r12, %rax
je 0x1862e
movq %rax, 0x60(%r15)
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq %r12, 0x68(%r15)
xorl %r13d, %r13d
leaq 0x12(%rsp), %rbp
movq %rax, 0x18(%rsp)
cmpq $0x100, %r13            # imm = 0x100
je 0x185b5
movb %r13b, 0x12(%rsp)
andq $0x0, (%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x13(%rsp), %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x189f1
movq %rax, 0x70(%r15,%r13,8)
incq %r13
jmp 0x18488
leaq 0x244(%rip), %rax       # 0x1870d
movq %rax, 0x880(%r15)
movq 0x10(%r15), %rax
movq 0x18(%r15), %r12
cmpq %r12, %rax
je 0x1862e
movq %rax, 0x60(%r15)
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq %r12, 0x68(%r15)
xorl %r13d, %r13d
leaq 0x13(%rsp), %rbp
movq %rax, 0x18(%rsp)
cmpq $0x100, %r13            # imm = 0x100
je 0x18537
movb %r13b, 0x13(%rsp)
andq $0x0, (%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x14(%rsp), %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x18956
movq %rax, 0x70(%r15,%r13,8)
incq %r13
jmp 0x18501
movq %r12, 0x870(%r15)
movq 0x878(%r15), %rbp
testq %rbp, %rbp
movq 0x18(%rsp), %rax
je 0x1862e
xorl %r15d, %r15d
leaq 0x16(%rsp), %r13
cmpq $0x10000, %r15          # imm = 0x10000
je 0x185a4
movl %r15d, %ecx
rolw $0x8, %cx
movw %cx, 0x16(%rsp)
andq $0x0, (%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x18(%rsp), %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x18956
movq %rax, %rcx
subq 0x18(%rsp), %rcx
shrq $0x2, %rcx
movl %ecx, (%rbp,%r15,4)
incq %r15
jmp 0x1855b
movq 0x20(%rsp), %rax
shrq $0x2, %rax
movl %eax, 0x40000(%rbp)
jmp 0x1862e
movq %r12, 0x870(%r15)
movq 0x878(%r15), %rbp
testq %rbp, %rbp
movq 0x18(%rsp), %rax
je 0x1862e
xorl %r15d, %r15d
leaq 0x14(%rsp), %r13
cmpq $0x10000, %r15          # imm = 0x10000
je 0x1861e
movl %r15d, %ecx
rolw $0x8, %cx
movw %cx, 0x14(%rsp)
andq $0x0, (%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x16(%rsp), %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x189f1
movq %rax, %rcx
subq 0x18(%rsp), %rcx
sarq $0x3, %rcx
movq %rcx, (%rbp,%r15,8)
incq %r15
jmp 0x185d5
movq 0x20(%rsp), %rax
sarq $0x3, %rax
movq %rax, 0x80000(%rbp)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop