// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp
// Function: hdiff_private::TDigestMatcher::TDigestMatcher(hpatch_TStreamInput const*, hpatch_TStreamInput const*, unsigned long, hdiff_TMTSets_s const&)
TDigestMatcher::TDigestMatcher(const hpatch_TStreamInput* oldData,const hpatch_TStreamInput* newData,
                               size_t kMatchBlockSize,const hdiff_TMTSets_s& mtsets)
:m_oldData(oldData),m_newData(newData),m_isUseLargeSorted(true),m_mtsets(mtsets),
m_newCacheSize(0),m_oldCacheSize(0),m_oldMinCacheSize(0),m_backupCacheSize(0),m_kMatchBlockSize(0){
    if (kMatchBlockSize>(oldData->streamSize+1)/2)
        kMatchBlockSize=(size_t)((oldData->streamSize+1)/2);
    if (kMatchBlockSize<kMatchBlockSize_min)
        kMatchBlockSize=kMatchBlockSize_min;
    if (oldData->streamSize<kMatchBlockSize) return;
    m_kMatchBlockSize=kMatchBlockSize;
    
    hpatch_StreamPos_t _blockCount=getBlockCount(m_kMatchBlockSize,m_oldData->streamSize);
    m_isUseLargeSorted=(_blockCount>=((hpatch_StreamPos_t)1<<32));
    const size_t blockCount=(size_t)_blockCount;
    if (blockCount!=_blockCount)
        throw std::runtime_error("TDataDigest() oldData->streamSize/MatchBlockSize too big error!");
    m_blocks.resize(blockCount);
    if (m_isUseLargeSorted)
        m_sorted_larger.resize(blockCount);
    else
        m_sorted_limit.resize(blockCount);
    
    m_backupCacheSize=getBackupSize(m_kMatchBlockSize);
    m_newCacheSize=upperCount(m_kMatchBlockSize*2+m_backupCacheSize,kBestReadSize)*kBestReadSize;
    m_oldCacheSize=upperCount(m_kMatchBlockSize+m_backupCacheSize,kBestReadSize)*kBestReadSize;
    m_oldMinCacheSize=upperCount(m_kMatchBlockSize+m_backupCacheSize,kMinReadSize)*kMinReadSize;
    assert(m_oldMinCacheSize<=m_oldCacheSize);
    m_mem.realloc((m_newCacheSize+m_oldCacheSize)*getSearchThreadNum());
    getDigests();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, (%rdi)
movq %rdx, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movb $0x1, 0x70(%rdi)
movups (%r8), %xmm1
movups %xmm1, 0x78(%rdi)
movq 0x10(%r8), %rax
movq %rax, 0x88(%rdi)
movups %xmm0, 0x90(%rdi)
movups %xmm0, 0xa0(%rdi)
movups %xmm0, 0xb0(%rdi)
movups %xmm0, 0xc0(%rdi)
movq 0x8(%rsi), %rax
leaq 0x1(%rax), %rdx
shrq %rdx
cmpq %rcx, %rdx
cmovaeq %rcx, %rdx
cmpq $0x5, %rdx
movl $0x4, %ecx
cmovaeq %rdx, %rcx
cmpq %rcx, %rax
jb 0x1da12
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
leaq 0x40(%rdi), %r15
leaq 0x58(%rdi), %r12
movq %rcx, 0xc8(%rdi)
addq %rcx, %rax
decq %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r13
shrq $0x20, %rax
setne 0x70(%rdi)
movq %r14, %rdi
movq %r13, %rsi
callq 0x20520
cmpb $0x1, 0x70(%rbx)
jne 0x1d93e
movq %r12, %rdi
movq %r13, %rsi
callq 0x20520
jmp 0x1d949
movq %r15, %rdi
movq %r13, %rsi
callq 0x20552
movq 0xc8(%rbx), %rcx
cmpq $0x101, %rcx            # imm = 0x101
movl $0x100, %edx            # imm = 0x100
cmovaeq %rcx, %rdx
movq %rdx, 0xc0(%rbx)
leaq (%rdx,%rcx,2), %rbp
movl $0x3ffff, %eax          # imm = 0x3FFFF
addq %rax, %rbp
movq $-0x40000, %rsi         # imm = 0xFFFC0000
andq %rsi, %rbp
movq %rbp, 0xa8(%rbx)
addq %rcx, %rax
addq %rdx, %rax
andq %rsi, %rax
movq %rax, 0xb0(%rbx)
addq %rdx, %rcx
addq $0xfff, %rcx            # imm = 0xFFF
andq $-0x1000, %rcx          # imm = 0xF000
movq %rcx, 0xb8(%rbx)
cmpq %rax, %rcx
ja 0x1da21
addq %rax, %rbp
movq %rbx, %rdi
callq 0x1d822
movq %rax, %r13
imulq %rbp, %r13
movq 0x90(%rbx), %rdi
movq 0xa0(%rbx), %rax
subq %rdi, %rax
cmpq %r13, %rax
jae 0x1da00
movq %r13, %rsi
callq 0x4530
testq %rax, %rax
je 0x1da40
movq %rax, 0x90(%rbx)
addq %rax, %r13
movq %r13, 0x98(%rbx)
movq %r13, 0xa0(%rbx)
jmp 0x1da0a
addq %r13, %rdi
movq %rdi, 0x98(%rbx)
movq %rbx, %rdi
callq 0x1db10
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3f21a(%rip), %rdi     # 0x5cc42
leaq 0x3f235(%rip), %rsi     # 0x5cc64
leaq 0x3f27c(%rip), %rcx     # 0x5ccb2
movl $0xc0, %edx
callq 0x4200
movl $0x10, %edi
callq 0x4190
movq %rax, %rbp
leaq 0x3e8bb(%rip), %rsi     # 0x5c30f
movq %rax, %rdi
callq 0x4110
movq 0x5e585(%rip), %rsi     # 0x7bfe8
movq 0x5e54e(%rip), %rdx     # 0x7bfb8
movq %rbp, %rdi
callq 0x4590
movq %rax, %r13
movq %rbp, %rdi
callq 0x4260
jmp 0x1da82
movq %rax, %r13
leaq 0x90(%rbx), %rbp
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x1daa6
callq 0x43b0
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movq $0x0, 0x10(%rbp)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1dabb
movq 0x68(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1dacf
movq 0x50(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
cmpq $0x0, 0x30(%rbx)
je 0x1daf4
movq $0x0, 0x30(%rbx)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x1daf4
callq 0x43e0
movq $0x0, 0x28(%rbx)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1db08
movq 0x20(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %r13, %rdi
callq 0x45e0