// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movq %r9, 0x70(%rsp)
movl %r8d, 0x60(%rsp)
movl %ecx, 0x5c(%rsp)
movl %edx, 0x64(%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, 0x48(%rsp)
movq %rsi, %rdi
callq 0x36bfd
leaq 0xc0(%rsp), %rcx
andl $0x0, (%rcx)
andq $0x0, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
andq $0x0, 0x20(%rcx)
movl %eax, %ebx
xorl %ebp, %ebp
testl %eax, %eax
cmovlel %ebp, %ebx
leaq 0xb8(%rsp), %r14
leaq 0x20(%rsp), %r15
cmpl %ebp, %ebx
je 0x761f
movq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x37b21
movl %eax, 0x20(%rsp)
movl %ebp, 0x24(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x9266
incl %ebp
jmp 0x75f8
movq 0x10(%rsp), %rdi
callq 0x36bfd
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x68(%rsp)
leaq 0x98(%rsp), %rbx
xorl %r15d, %r15d
cmpl 0x68(%rsp), %r15d
je 0x7996
movq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x37b16
movl %eax, 0x1c(%rsp)
movq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x370b0
testb %al, %al
je 0x769a
movl %r15d, 0x20(%rsp)
movq 0x128(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x937e
movq 0x130(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x8468
jmp 0x798e
movq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x37b03
testl %eax, %eax
jne 0x76c0
movq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x370d6
testb %al, %al
je 0x792f
movq 0x10(%rsp), %rdi
movl %r15d, 0xc(%rsp)
movl %r15d, %esi
callq 0x37b21
movl %eax, 0x6c(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
callq 0x9474
movq %rax, %r15
movq %rdx, %r12
movl $0x0, 0x58(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0x54(%rsp)
cmpq %r12, %r15
je 0x78ab
movl 0x24(%r15), %ebp
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
movl %ebp, %ecx
callq 0x68c0
testb %al, %al
je 0x77be
movq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x370b0
testb %al, %al
jne 0x789b
movq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x370d6
testb %al, %al
jne 0x7761
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x370d6
testb %al, %al
jne 0x789b
leaq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x6d91
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
movl %ebp, %edx
callq 0x6d91
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8486
movl %eax, %r13d
movq %rbx, %rdi
callq 0x4170
movq %r14, %rdi
callq 0x4170
movb $0x1, %al
movl %eax, 0x58(%rsp)
movl %ebp, 0x54(%rsp)
testb %r13b, %r13b
je 0x789b
jmp 0x78b6
movq %r12, %r14
leaq 0x47afb(%rip), %rdi     # 0x4f2c3
movl 0xc(%rsp), %r12d
movl %r12d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x4060
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r12d, %edx
callq 0x6d91
movq %rbx, %rdi
leaq 0x47b07(%rip), %rsi     # 0x4f2ff
movq %r13, %rdx
callq 0x84af
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
leaq 0x46894(%rip), %rdx     # 0x4e0a3
callq 0x67cf
movq 0x20(%rsp), %rdi
callq 0x3e2f4
leaq 0x20(%rsp), %rdi
callq 0x4170
movq %rbx, %rdi
callq 0x4170
leaq 0x78(%rsp), %r13
movq %r13, %rdi
callq 0x4170
movq %r13, %rdi
movq 0x48(%rsp), %rsi
movl %ebp, %edx
callq 0x6d91
movq %rbx, %rdi
leaq 0x47ab4(%rip), %rsi     # 0x4f30a
movq %r13, %rdx
callq 0x84af
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
leaq 0x46836(%rip), %rdx     # 0x4e0a3
callq 0x67cf
movq 0x20(%rsp), %rdi
callq 0x3e2f4
leaq 0x20(%rsp), %rdi
callq 0x4170
movq %rbx, %rdi
callq 0x4170
leaq 0x78(%rsp), %rdi
callq 0x4170
movq %r14, %r12
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
jmp 0x76fd
movl 0x54(%rsp), %ebp
testb $0x1, 0x58(%rsp)
je 0x78e7
movl 0xc(%rsp), %r15d
movl %r15d, 0x20(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x937e
movl %ebp, 0x20(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x937e
jmp 0x798e
movl 0xc(%rsp), %r15d
movl %r15d, 0x20(%rsp)
movq 0x120(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x937e
movq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x370d6
testb %al, %al
je 0x798e
cmpb $0x0, 0x64(%rsp)
je 0x7938
movq 0x130(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x8468
jmp 0x798e
cmpl $0x0, 0x1c(%rsp)
je 0x798e
jmp 0x79b7
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %rdi
movl %r15d, %esi
leaq 0x20(%rsp), %rdx
movl 0x5c(%rsp), %ecx
movl 0x60(%rsp), %r8d
callq 0x72ec
testb %al, %al
je 0x79e2
movl 0x28(%rsp), %eax
subl 0x20(%rsp), %eax
movl %eax, 0x98(%rsp)
movq 0x130(%rsp), %rdi
movq %rbx, %rsi
callq 0x937e
leaq 0x20(%rsp), %rdi
callq 0x8b88
incl %r15d
jmp 0x763f
leaq 0xb8(%rsp), %rdi
callq 0x8556
movb $0x1, %al
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47f41(%rip), %rdi     # 0x4f8ff
callq 0x4510
leaq 0x47686(%rip), %rdi     # 0x4f050
leaq 0x47685(%rip), %rsi     # 0x4f056
leaq 0x4784a(%rip), %rcx     # 0x4f222
movl $0x129, %edx            # imm = 0x129
callq 0x4230
leaq 0x47f2f(%rip), %rdi     # 0x4f918
callq 0x4510
leaq 0x4765b(%rip), %rdi     # 0x4f050
leaq 0x4765a(%rip), %rsi     # 0x4f056
leaq 0x4781f(%rip), %rcx     # 0x4f222
movl $0x14a, %edx            # imm = 0x14A
callq 0x4230
jmp 0x7a7a
jmp 0x7a11
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x8b88
jmp 0x7a7d
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a7a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x7a73
jmp 0x7a7a
jmp 0x7a7a
jmp 0x7a48
jmp 0x7a54
jmp 0x7a7a
jmp 0x7a4f
movq %rax, %rbx
jmp 0x7a61
jmp 0x7a7a
movq %rax, %rbx
jmp 0x7a6e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x98(%rsp), %rdi
callq 0x4170
leaq 0x78(%rsp), %rdi
callq 0x4170
jmp 0x7a7d
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x8556
movq %rbx, %rdi
callq 0x4600