// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: (anonymous namespace)::get_diff(unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, (anonymous namespace)::TDiffData&, std::vector<(anonymous namespace)::TOldCover, std::allocator<(anonymous namespace)::TOldCover>>&, int, bool, ICoverLinesListener*, hdiff_private::TSuffixString const*, unsigned long, bool)
static void get_diff(const TByte* newData,const TByte* newData_end,
                     const TByte* oldData,const TByte* oldData_end,
                     TDiffData&   out_diff,std::vector<TOldCover>& covers,
                     int kMinSingleMatchScore,
                     bool isUseBigCacheMatch,ICoverLinesListener* listener,
                     const TSuffixString* sstring,size_t threadNum,
                     bool isCanExtendCover=true){
    assert(newData<=newData_end);
    assert(oldData<=oldData_end);
    TDiffData& diff=out_diff;
    diff.newData=newData;
    diff.newData_end=newData_end;
    diff.oldData=oldData;
    diff.oldData_end=oldData_end;
    
    const bool isCover32=sizeof(*covers.data())==sizeof(hpatch_TCover32);
    if (!isCover32)
        assert(sizeof(*covers.data())==sizeof(hpatch_TCover));
    const hpatch_StreamPos_t maxCoverLen=(listener&&listener->get_limit_cover_length)?
                                            listener->get_limit_cover_length(listener):kDefaultLimitCoverLen;
    {
        TSuffixString _sstring_default(isUseBigCacheMatch);
        if (sstring==0){
            _sstring_default.resetSuffixString(oldData,oldData_end,threadNum);
            sstring=&_sstring_default;
        }
        first_search_and_dispose_cover_MT(covers,diff,*sstring,kMinSingleMatchScore,listener,threadNum,isCanExtendCover);
        _limitCoverLenth(covers,maxCoverLen);
        assert_covers_safe(covers,diff.newData_end-diff.newData,diff.oldData_end-diff.oldData);
        if (listener&&listener->search_cover_limit&&
            listener->search_cover_limit(listener,covers.data(),covers.size(),isCover32)){
            TDiffResearchCover diffResearchCover(diff,covers,*sstring,kMinSingleMatchScore,
                                    listener->get_max_match_deep?listener->get_max_match_deep(listener):kDefaultMaxMatchDeepForLimit,
                                    isCanExtendCover);
            listener->research_cover(listener,&diffResearchCover,covers.data(),covers.size(),isCover32);
            diffResearchCover.researchFinish();
            _limitCoverLenth(covers,maxCoverLen);
            assert_covers_safe(covers,diff.newData_end-diff.newData,diff.oldData_end-diff.oldData);
        }
        sstring=0;
        _sstring_default.clear();
    }
    if (listener&&listener->insert_cover){
        TDiffInsertCover diffInsertCover(covers);
        hpatch_StreamPos_t newDataSize=(size_t)(diff.newData_end-diff.newData);
        hpatch_StreamPos_t oldDataSize=(size_t)(diff.oldData_end-diff.oldData);
        listener->insert_cover(listener,&diffInsertCover,covers.data(),covers.size(),isCover32,
                               &newDataSize,&oldDataSize);
        diff.newData_end=diff.newData+(size_t)newDataSize;
        diff.oldData_end=diff.oldData+(size_t)oldDataSize;
        _limitCoverLenth(covers,maxCoverLen);
        assert_covers_safe(covers,diff.newData_end-diff.newData,diff.oldData_end-diff.oldData);
    }
    if (listener&&listener->search_cover_finish){
        hpatch_StreamPos_t newDataSize=(size_t)(diff.newData_end-diff.newData);
        hpatch_StreamPos_t oldDataSize=(size_t)(diff.oldData_end-diff.oldData);
        size_t newCoverCount=covers.size();
        listener->search_cover_finish(listener,covers.data(),&newCoverCount,isCover32,
                                      &newDataSize,&oldDataSize);
        check(newCoverCount<=covers.size());
        covers.resize(newCoverCount);
        diff.newData_end=diff.newData+(size_t)newDataSize;
        diff.oldData_end=diff.oldData+(size_t)oldDataSize;
        _limitCoverLenth(covers,maxCoverLen);
        assert_covers_safe(covers,diff.newData_end-diff.newData,diff.oldData_end-diff.oldData);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xab0, %rsp            # imm = 0xAB0
movq %rcx, -0xa08(%rbp)
movq %rdx, %rax
movq -0xa08(%rbp), %rdx
movq %rax, -0xa00(%rbp)
movq %rsi, %rax
movq -0xa00(%rbp), %rsi
movq %rax, -0x9f8(%rbp)
movq %rdi, %r10
movq -0x9f8(%rbp), %rdi
movb 0x38(%rbp), %al
movq 0x30(%rbp), %rcx
movq 0x28(%rbp), %rcx
movq 0x20(%rbp), %rcx
movb 0x18(%rbp), %cl
movl 0x10(%rbp), %r11d
movq %r10, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
andb $0x1, %cl
movb %cl, -0x31(%rbp)
andb $0x1, %al
movb %al, -0x32(%rbp)
movq -0x8(%rbp), %rax
cmpq -0x10(%rbp), %rax
ja 0x18d03
jmp 0x18d22
leaq 0x963a9(%rip), %rdi     # 0xaf0b3
leaq 0x96071(%rip), %rsi     # 0xaed82
movl $0x3c3, %edx            # imm = 0x3C3
leaq 0x963ab(%rip), %rcx     # 0xaf0c8
callq 0x4270
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x18d2e
jmp 0x18d4d
leaq 0x96462(%rip), %rdi     # 0xaf197
leaq 0x96046(%rip), %rsi     # 0xaed82
movl $0x3c4, %edx            # imm = 0x3C4
leaq 0x96380(%rip), %rcx     # 0xaf0c8
callq 0x4270
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movb $0x0, -0x41(%rbp)
cmpq $0x0, 0x20(%rbp)
je 0x18db1
movq 0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x18db1
movq 0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rbp), %rdi
callq *%rax
movq %rax, -0xa10(%rbp)
jmp 0x18dbf
movl $0xffff, %eax           # imm = 0xFFFF
movq %rax, -0xa10(%rbp)
jmp 0x18dbf
movq -0xa10(%rbp), %rax
movq %rax, -0x50(%rbp)
movb -0x31(%rbp), %al
leaq -0x8d8(%rbp), %rdi
andb $0x1, %al
movzbl %al, %esi
callq 0x39470
cmpq $0x0, 0x28(%rbp)
jne 0x18e23
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x30(%rbp), %rcx
leaq -0x8d8(%rbp), %rdi
callq 0x396b0
jmp 0x18dff
leaq -0x8d8(%rbp), %rax
movq %rax, 0x28(%rbp)
jmp 0x18e23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8e0(%rbp)
movl %eax, -0x8e4(%rbp)
jmp 0x191b5
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq 0x28(%rbp), %rdx
movl 0x10(%rbp), %ecx
movq 0x20(%rbp), %r8
movq 0x30(%rbp), %r9
movzbl -0x32(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x1de20
jmp 0x18e50
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1e340
jmp 0x18e5f
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rsi
subq %rcx, %rsi
movq 0x18(%rax), %rdx
movq 0x10(%rax), %rax
subq %rax, %rdx
callq 0x1e650
jmp 0x18e83
cmpq $0x0, 0x20(%rbp)
je 0x19063
movq 0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19063
movq 0x20(%rbp), %rax
movq %rax, -0xa30(%rbp)
movq (%rax), %rax
movq %rax, -0xa20(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a2e0
movq %rax, -0xa28(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a300
movq -0xa30(%rbp), %rdi
movq -0xa28(%rbp), %rsi
movq %rax, %rdx
movq -0xa20(%rbp), %rax
xorl %ecx, %ecx
callq *%rax
movb %al, -0xa11(%rbp)
jmp 0x18eee
movb -0xa11(%rbp), %al
testb $0x1, %al
jne 0x18efd
jmp 0x19063
movq -0x40(%rbp), %rax
movq %rax, -0xa50(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xa48(%rbp)
movq 0x28(%rbp), %rax
movq %rax, -0xa40(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0xa34(%rbp)
movq 0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x18f52
movq 0x20(%rbp), %rdi
movq 0x20(%rdi), %rax
callq *%rax
movl %eax, -0xa54(%rbp)
jmp 0x18f44
movl -0xa54(%rbp), %eax
movl %eax, -0xa58(%rbp)
jmp 0x18f5f
movl $0x6, %eax
movl %eax, -0xa58(%rbp)
jmp 0x18f5f
movl -0xa34(%rbp), %r8d
movq -0xa40(%rbp), %rcx
movq -0xa48(%rbp), %rdx
movq -0xa50(%rbp), %rsi
movl -0xa58(%rbp), %r9d
movzbl -0x32(%rbp), %edi
andl $0x1, %edi
movq %rsp, %rax
movl %edi, (%rax)
leaq -0x9b8(%rbp), %rdi
callq 0x1e6b0
jmp 0x18f9c
movq 0x20(%rbp), %rax
movq %rax, -0xa70(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xa60(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a2e0
movq %rax, -0xa68(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a300
movq -0xa70(%rbp), %rdi
movq -0xa68(%rbp), %rdx
movq %rax, %rcx
movq -0xa60(%rbp), %rax
leaq -0x9b8(%rbp), %rsi
xorl %r8d, %r8d
callq *%rax
jmp 0x18ff1
leaq -0x9b8(%rbp), %rdi
callq 0x1e7c0
jmp 0x18fff
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1e340
jmp 0x1900e
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rsi
subq %rcx, %rsi
movq 0x18(%rax), %rdx
movq 0x10(%rax), %rax
subq %rax, %rdx
callq 0x1e650
jmp 0x19032
leaq -0x9b8(%rbp), %rdi
callq 0x1e970
jmp 0x19063
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8e0(%rbp)
movl %eax, -0x8e4(%rbp)
leaq -0x9b8(%rbp), %rdi
callq 0x1e970
jmp 0x191b5
movq $0x0, 0x28(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x397d0
jmp 0x19079
leaq -0x8d8(%rbp), %rdi
callq 0x39780
cmpq $0x0, 0x20(%rbp)
je 0x191c6
movq 0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x191c6
movq -0x30(%rbp), %rsi
leaq -0x9c8(%rbp), %rdi
callq 0x1e9c0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x9d0(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x9d8(%rbp)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa78(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xa88(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a2e0
movq %rax, -0xa80(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a300
movq -0xa88(%rbp), %rdi
movq -0xa80(%rbp), %rdx
movq %rax, %rcx
movq -0xa78(%rbp), %rax
leaq -0x9c8(%rbp), %rsi
xorl %r8d, %r8d
leaq -0x9d0(%rbp), %r9
leaq -0x9d8(%rbp), %r10
movq %r10, (%rsp)
callq *%rax
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq -0x9d0(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
addq -0x9d8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1e340
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rax
subq %rax, %rsi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
subq %rax, %rdx
callq 0x1e650
jmp 0x191c6
leaq -0x8d8(%rbp), %rdi
callq 0x39780
jmp 0x19379
cmpq $0x0, 0x20(%rbp)
je 0x19370
movq 0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x19370
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x9e0(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x9e8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a300
movq %rax, -0x9f0(%rbp)
movq 0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa98(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xaa0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a2e0
movq -0xaa0(%rbp), %rdi
movq %rax, %rsi
movq -0xa98(%rbp), %rax
leaq -0x9f0(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x9e0(%rbp), %r8
leaq -0x9e8(%rbp), %r9
callq *%rax
movq -0x9f0(%rbp), %rax
movq %rax, -0xa90(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a300
movq %rax, %rcx
movq -0xa90(%rbp), %rax
cmpq %rcx, %rax
jbe 0x192f8
movl $0x10, %edi
callq 0x41e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xaa8(%rbp)
leaq 0x95ef8(%rip), %rsi     # 0xaf1ac
callq 0x4140
jmp 0x192bb
movq -0xaa8(%rbp), %rdi
movq 0xccd27(%rip), %rsi     # 0xe5ff0
movq 0xcccf0(%rip), %rdx     # 0xe5fc0
callq 0x4630
movq -0xaa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8e0(%rbp)
movl %eax, -0x8e4(%rbp)
callq 0x42e0
jmp 0x19379
movq -0x30(%rbp), %rdi
movq -0x9f0(%rbp), %rsi
callq 0x1e9f0
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq -0x9e0(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
addq -0x9e8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1e340
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rax
subq %rax, %rsi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
subq %rax, %rdx
callq 0x1e650
addq $0xab0, %rsp            # imm = 0xAB0
popq %rbp
retq
movq -0x8e0(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)