// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
callq 0x39530
movq -0x20(%rbp), %rax
testb $0x1, 0x40(%rax)
je 0x39b62
movq -0x20(%rbp), %rax
movq %rax, %rdi
addq $0x48, %rdi
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rcx
callq 0x39f40
movq -0x20(%rbp), %rdi
movq $0x200000, -0x18(%rbp)  # imm = 0x200000
callq 0x2ad80
cmpq $0x200000, %rax         # imm = 0x200000
jbe 0x39bb1
movq -0x20(%rbp), %rdi
callq 0x2ae80
movb %al, %dl
movl $0x4, %eax
movl $0x8, %ecx
testb $0x1, %dl
cmovneq %rcx, %rax
imulq $0x10001, %rax, %rdi    # imm = 0x10001
callq 0x4030
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x878(%rax)
movq -0x20(%rbp), %rdi
callq 0x2ae80
testb $0x1, %al
jne 0x39bc3
jmp 0x39c80
movq -0x20(%rbp), %rdi
leaq 0x632(%rip), %rax       # 0x3a200
movq %rax, 0x880(%rdi)
addq $0x28, %rdi
callq 0x3ac00
testb $0x1, %al
jne 0x39be4
jmp 0x39be9
jmp 0x39d3a
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ac40
movq -0x20(%rbp), %rdi
movq %rax, 0x60(%rdi)
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ac40
movq -0x20(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x28, %rdi
callq 0x3ac60
movq -0x20(%rbp), %r8
movq %rax, %rcx
movq -0x28(%rbp), %rax
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x68(%r8)
movq 0x60(%r8), %rdi
movq 0x68(%r8), %rsi
movq (%r8), %rdx
movq 0x8(%r8), %rcx
addq $0x70, %r8
callq 0x3a260
movq -0x20(%rbp), %rax
cmpq $0x0, 0x878(%rax)
je 0x39c7b
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq 0x68(%rax), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq 0x878(%rax), %r8
callq 0x3a300
jmp 0x39d3a
movq -0x20(%rbp), %rdi
leaq 0x255(%rip), %rax       # 0x39ee0
movq %rax, 0x880(%rdi)
addq $0x10, %rdi
callq 0x3ac80
testb $0x1, %al
jne 0x39ca1
jmp 0x39ca6
jmp 0x39d3a
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3acc0
movq -0x20(%rbp), %rdi
movq %rax, 0x60(%rdi)
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3acc0
movq -0x20(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x10, %rdi
callq 0x3ace0
movq -0x20(%rbp), %r8
movq %rax, %rcx
movq -0x30(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x68(%r8)
movq 0x60(%r8), %rdi
movq 0x68(%r8), %rsi
movq (%r8), %rdx
movq 0x8(%r8), %rcx
addq $0x70, %r8
callq 0x3a3d0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x878(%rax)
je 0x39d38
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq 0x68(%rax), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq 0x878(%rax), %r8
callq 0x3a470
jmp 0x39d3a
addq $0x30, %rsp
popq %rbp
retq