// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/src/diff/DiffData.cpp
// Function: getSamePairList(UnZipper*, UnZipper*, bool, int, int, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&)
bool getSamePairList(UnZipper* newZip,UnZipper* oldZip,
                     bool newCompressedDataIsNormalized,
                     int zlibCompressLevel,int zlibCompressMemLevel,
                     std::vector<uint32_t>& out_samePairList,
                     std::vector<uint32_t>& out_newRefList,
                     std::vector<uint32_t>& out_newRefOtherCompressedList,
                     std::vector<uint32_t>& out_newRefCompressedSizeList){
    int oldFileCount=UnZipper_fileCount(oldZip);
    typedef std::multimap<uint32_t,int> TMap;
    TMap crcMap;
    for (int i=0; i<oldFileCount; ++i) {
        uint32_t crcOld=UnZipper_file_crc32(oldZip,i);
        crcMap.insert(TMap::value_type(crcOld,i));
    }
    
    int newFileCount=UnZipper_fileCount(newZip);
    for (int i=0; i<newFileCount; ++i) {
        ZipFilePos_t compressedSize=UnZipper_file_compressedSize(newZip,i);
        if (UnZipper_file_isReCompressedByApkV2Sign(newZip,i)){
            out_newRefOtherCompressedList.push_back(i);
            out_newRefCompressedSizeList.push_back(compressedSize);
        }else if ((0==UnZipper_file_uncompressedSize(newZip,i))
                  &&(!UnZipper_file_isCompressed(newZip,i))){ //empty entry
            check(0==compressedSize);
            //not need: out_newRefList.push_back(i);
        }else{
            bool findSame=false;
            int  oldSameIndex=-1;
            uint32_t crcNew=UnZipper_file_crc32(newZip,i);
            std::pair<TMap::const_iterator,TMap::const_iterator> range=crcMap.equal_range(crcNew);
            for (;range.first!=range.second;++range.first) {
                int oldIndex=range.first->second;
                if (zipFileData_isSame(newZip,i,oldZip,oldIndex)){
                    if (UnZipper_file_isReCompressedByApkV2Sign(oldZip,oldIndex))
                        continue;
                    if ((!UnZipper_file_isCompressed(oldZip,oldIndex))&&
                        UnZipper_file_isCompressed(newZip,i)) continue;
                    findSame=true;
                    oldSameIndex=oldIndex;
                    if (zipFile_name(newZip,i)==zipFile_name(oldZip,oldIndex)) break;
                }else{
                    printf("WARNING: crc32 equal but data not equal! file index: %d,%d\n",i,oldIndex);
                    hpatch_printPath_utf8(("   name: \""+zipFile_name(newZip,i)+"\"\n").c_str());
                    hpatch_printPath_utf8(("         \""+zipFile_name(oldZip,oldIndex)+"\"\n").c_str());
                }
            }
            if (findSame){
                out_samePairList.push_back(i);
                out_samePairList.push_back(oldSameIndex);
            }else{
                out_newRefList.push_back(i);
                if (UnZipper_file_isCompressed(newZip,i)){
                    if (newCompressedDataIsNormalized){
                        out_newRefCompressedSizeList.push_back(compressedSize);
                    }else{
                        std::vector<TByte> code;
                        check(getNormalizedCompressedCode(newZip,i,code,zlibCompressLevel,zlibCompressMemLevel));
                        out_newRefCompressedSizeList.push_back((uint32_t)code.size());
                    }
                }
            }
        }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r13
movl %r8d, 0x8c(%rsp)
movl %ecx, 0x88(%rsp)
movl %edx, 0x90(%rsp)
movq %rdi, (%rsp)
movq %rsi, 0x38(%rsp)
movq %rsi, %rdi
callq 0x3f9dd
movl %eax, %ebx
leaq 0xb0(%rsp), %rax
movl $0x0, (%rax)
xorl %r14d, %r14d
movq %r14, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %r14, 0x20(%rax)
testl %ebx, %ebx
jle 0x834e
leaq 0xa8(%rsp), %r15
leaq 0x10(%rsp), %rbp
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x4094c
movl %eax, 0x10(%rsp)
movl %r14d, 0x14(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xaa80
incl %r14d
cmpl %r14d, %ebx
jne 0x8325
movq (%rsp), %rdi
callq 0x3f9dd
movl %eax, %ebp
testl %eax, %eax
jle 0x8a0d
movq 0x120(%rsp), %r14
movq 0x118(%rsp), %r15
leaq 0x20(%rsp), %r12
xorl %ebx, %ebx
movq %r13, 0x98(%rsp)
movl %ebp, 0x34(%rsp)
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x40941
movl %eax, 0xc(%rsp)
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3febf
testb %al, %al
je 0x83c3
movl %ebx, 0x10(%rsp)
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x882f
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x883c
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x4092e
testl %eax, %eax
jne 0x83e5
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3fee7
testb %al, %al
je 0x88cf
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x4094c
movl %eax, 0x94(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x94(%rsp), %rsi
callq 0xac08
movq %rax, %r15
cmpq %rdx, %rax
je 0x886b
movq %rdx, 0xa0(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x0, 0x64(%rsp)
movl 0x24(%r15), %r14d
movq (%rsp), %rdi
movl %ebx, %esi
movq 0x38(%rsp), %rdx
movl %r14d, %ecx
callq 0x73f8
testb %al, %al
je 0x8522
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3febf
testb %al, %al
jne 0x87bf
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3fee7
testb %al, %al
jne 0x8486
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3fee7
testb %al, %al
jne 0x87bf
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3f9e6
movl %eax, %ebp
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3f9fa
movslq %ebp, %rdx
addq %rax, %rdx
movq %r12, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x7368
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3f9e6
movl %eax, %ebp
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3f9fa
movslq %ebp, %rdx
addq %rax, %rdx
leaq 0x50(%rsp), %rcx
movq %rcx, 0x40(%rsp)
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x7368
movq 0x18(%rsp), %rdx
cmpq 0x48(%rsp), %rdx
jne 0x87e7
testq %rdx, %rdx
je 0x87eb
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x4310
testl %eax, %eax
sete %bpl
jmp 0x87ee
leaq 0x51d9a(%rip), %rdi     # 0x5a2c3
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4060
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3f9e6
movl %eax, %ebp
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3f9fa
movslq %ebp, %rdx
addq %rax, %rdx
leaq 0x78(%rsp), %rcx
movq %rcx, 0x68(%rsp)
leaq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x7368
movl $0xa, %r8d
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x51d7f(%rip), %rcx     # 0x5a2ff
callq 0x4360
leaq 0x50(%rsp), %rsi
movq %rsi, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x85ad
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x85b3
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x50acc(%rip), %rsi     # 0x590a3
callq 0x4640
movq %r12, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x85ff
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x8607
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rdi
callq 0x48304
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x8640
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x865c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x8678
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3f9e6
movl %eax, %ebp
movq 0x38(%rsp), %rdi
movl %r14d, %esi
callq 0x3f9fa
movslq %ebp, %rdx
addq %rax, %rdx
leaq 0x78(%rsp), %rcx
movq %rcx, 0x68(%rsp)
leaq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x7368
movl $0xa, %r8d
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x51c43(%rip), %rcx     # 0x5a30a
callq 0x4360
leaq 0x50(%rsp), %rsi
movq %rsi, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x86f4
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x86fa
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x50985(%rip), %rsi     # 0x590a3
callq 0x4640
movq %r12, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8746
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x874e
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rdi
callq 0x48304
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x8787
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x87a3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x87bf
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4300
xorl %ebp, %ebp
movl %r13d, %r14d
testb %bpl, %bpl
jne 0x8829
movq %r15, %rdi
callq 0x4380
movq %rax, %r15
movl %r14d, %r13d
cmpq 0xa0(%rsp), %rax
jne 0x842e
jmp 0x8829
xorl %ebp, %ebp
jmp 0x87ee
movb $0x1, %bpl
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x880a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x8821
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
movb $0x1, %al
movl %eax, 0x64(%rsp)
jmp 0x87c4
movl 0x64(%rsp), %eax
jmp 0x8873
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0xab2c
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x8859
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x8a03
movq %r14, %rdi
leaq 0xc(%rsp), %rdx
callq 0xa944
jmp 0x8a03
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %eax, %eax
testb $0x1, %al
movq 0x98(%rsp), %r13
movq 0x118(%rsp), %r15
je 0x88a1
movl %ebx, 0x10(%rsp)
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0x88df
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r13)
jmp 0x88ec
movl %ebx, 0x10(%rsp)
movq 0x110(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x8917
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
movl 0x34(%rsp), %ebp
movq 0x120(%rsp), %r14
jmp 0x892d
cmpl $0x0, 0xc(%rsp)
je 0x8a03
jmp 0x8a2e
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
callq 0xab2c
movl %r14d, 0x10(%rsp)
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0x896a
movl %r14d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r13)
movl 0x34(%rsp), %ebp
movq 0x120(%rsp), %r14
jmp 0x8a03
leaq 0x10(%rsp), %rdx
callq 0xab2c
movl 0x34(%rsp), %ebp
movq 0x120(%rsp), %r14
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x3fee7
testb %al, %al
je 0x8a03
cmpb $0x0, 0x90(%rsp)
je 0x8985
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
jne 0x8846
movq %r14, %rdi
leaq 0xc(%rsp), %rdx
callq 0xa944
jmp 0x8a03
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
callq 0xab2c
movl 0x34(%rsp), %ebp
movq 0x120(%rsp), %r14
jmp 0x8a03
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rsp), %rdi
movl %ebx, %esi
leaq 0x10(%rsp), %rdx
movl 0x88(%rsp), %ecx
movl 0x8c(%rsp), %r8d
callq 0x7f6b
testb %al, %al
je 0x8a59
movl 0x18(%rsp), %eax
subl 0x10(%rsp), %eax
movl %eax, 0x40(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x89df
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x89ec
movq %r14, %rdi
leaq 0x40(%rsp), %rdx
callq 0xab2c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8a03
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
incl %ebx
cmpl %ebp, %ebx
jne 0x8384
leaq 0xa8(%rsp), %rdi
callq 0x9e34
movb $0x1, %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x51eca(%rip), %rdi     # 0x5a8ff
callq 0x44e0
leaq 0x5160f(%rip), %rdi     # 0x5a050
leaq 0x5160e(%rip), %rsi     # 0x5a056
leaq 0x517d3(%rip), %rcx     # 0x5a222
movl $0x129, %edx            # imm = 0x129
callq 0x4200
leaq 0x51eb8(%rip), %rdi     # 0x5a918
callq 0x44e0
leaq 0x515e4(%rip), %rdi     # 0x5a050
leaq 0x515e3(%rip), %rsi     # 0x5a056
leaq 0x517a8(%rip), %rcx     # 0x5a222
movl $0x14a, %edx            # imm = 0x14A
callq 0x4200
jmp 0x8a8b
jmp 0x8b56
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8b59
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
jmp 0x8b33
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
jmp 0x8adc
jmp 0x8ae6
jmp 0x8ae1
movq %rax, %rbx
jmp 0x8b00
movq %rax, %rbx
jmp 0x8b1c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b00
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x8b1c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x8b59
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x8b59
jmp 0x8b56
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b59
movq 0x20(%rsp), %rsi
jmp 0x8b30
jmp 0x8b56
jmp 0x8b56
jmp 0x8b56
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x9e34
movq %rbx, %rdi
callq 0x45e0