// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp
// Function: hdiff_private::TFastMatchForSString::buildMatchCache(unsigned char const*, unsigned char const*, unsigned long)
void TFastMatchForSString::buildMatchCache(const TChar* src_begin,const TChar* src_end,size_t threadNum){
        #define kFMZoom 4  //ctrl memory size & match speed
        size_t srcSize=src_end-src_begin;
        if (srcSize>=kFMMinStrSize){
            const size_t rollSize=srcSize-(kFMMinStrSize-1);
            bf.init(rollSize,kFMZoom); //alloc large memory
#if (_IS_USED_MULTITHREAD)
            const size_t kInsertMinParallelSize=4096;
            if ((threadNum>1)&&(rollSize>=kInsertMinParallelSize)) {
                const size_t maxThreanNum=rollSize/(kInsertMinParallelSize/2);
                threadNum=(threadNum<=maxThreanNum)?threadNum:maxThreanNum;

                const size_t step=rollSize/threadNum;
                const size_t threadCount=threadNum-1;
                std::vector<std::thread> threads(threadCount);
                for (size_t i=0;i<threadCount;i++,src_begin+=step)
                    threads[i]=std::thread(_filter_insert<true>,&bf,src_begin,src_begin+step+(kFMMinStrSize-1));
                _filter_insert<true>(&bf,src_begin,src_end);
                for (size_t i=0;i<threadCount;i++)
                    threads[i].join();
            }else
#endif
            {
                _filter_insert<false>(&bf,src_begin,src_end);
            }
        }else if ((srcSize>0)||(src_begin!=0))
            bf.init(0,kFMZoom);
        else{
            bf.clear();
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x5, -0x28(%rbp)
jb 0x3a1ba
movq -0xb0(%rbp), %rdi
movq -0x28(%rbp), %rax
subq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movl $0x4, %edx
callq 0x3ad00
movq $0x1000, -0x38(%rbp)    # imm = 0x1000
cmpq $0x1, -0x20(%rbp)
jbe 0x3a1a4
cmpq $0x1000, -0x30(%rbp)    # imm = 0x1000
jb 0x3a1a4
movq -0x30(%rbp), %rax
shrq $0xb, %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x40(%rbp), %rax
ja 0x39fe5
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x39ff0
movq -0x40(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
decq %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x29f40
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x29f60
jmp 0x3a04b
leaq -0x69(%rbp), %rdi
callq 0x29fd0
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x3a13b
movq -0xb0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq 0x4(%rax,%rcx), %rax
movq %rax, -0xa0(%rbp)
leaq 0x4a7(%rip), %rsi       # 0x3a540
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rdx
leaq -0x10(%rbp), %rcx
leaq -0xa0(%rbp), %r8
callq 0x3ad50
jmp 0x3a0b9
movq -0x88(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x2a090
movq %rax, %rdi
leaq -0x90(%rbp), %rsi
callq 0x2a0b0
leaq -0x90(%rbp), %rdi
callq 0x2a0f0
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x3a05f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x29fd0
jmp 0x3a1f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x2a120
jmp 0x3a1f6
movq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3a540
jmp 0x3a151
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x3a199
movq -0xa8(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x2a090
movq %rax, %rdi
callq 0x4620
jmp 0x3a183
jmp 0x3a185
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x3a15c
leaq -0x68(%rbp), %rdi
callq 0x2a120
jmp 0x3a1b8
movq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3a5c0
jmp 0x3a1ed
cmpq $0x0, -0x28(%rbp)
ja 0x3a1c8
cmpq $0x0, -0x10(%rbp)
je 0x3a1df
movq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x4, %edx
callq 0x3ad00
jmp 0x3a1eb
movq -0xb0(%rbp), %rdi
callq 0x3ae20
jmp 0x3a1ed
addq $0xd0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x4680
nop