// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/src/diff/OldRef.cpp
// Function: getOldRefList(UnZipper*, std::vector<unsigned int, std::allocator<unsigned int>> const&, std::vector<unsigned int, std::allocator<unsigned int>> const&, UnZipper*, std::vector<unsigned int, std::allocator<unsigned int>>&)
bool getOldRefList(UnZipper* newZip,const std::vector<uint32_t>& samePairList,
                   const std::vector<uint32_t>& newRefList,
                   UnZipper* oldZip,std::vector<uint32_t>& out_oldRefList){
    std::vector<uint32_t> oldSameList(samePairList.size()/2);
    for (size_t i=0; i<oldSameList.size(); ++i)
        oldSameList[i]=samePairList[i*2+1];
    std::sort(oldSameList.begin(),oldSameList.end());
    
    int oldZipFileCount=UnZipper_fileCount(oldZip);
    std::vector<uint32_t> decompressList;
    size_t iOldSame=0;
    for (int i=0; i<oldZipFileCount; ++i) {
        bool isInSame=false;
        while ((iOldSame<oldSameList.size())&&(i==(int)oldSameList[iOldSame])){
            isInSame=true;
            ++iOldSame;
        }
        if (UnZipper_file_uncompressedSize(oldZip,i)<=0)
            continue;
        if(!UnZipper_file_isCompressed(oldZip,i))
            out_oldRefList.push_back(i);//反正不用解压,不用判断其是否有参考意义了;
        else if (!isInSame) //跳过和newZip中相同的文件,但某些情况可能会使得结果变大;
            decompressList.push_back(i);
    }
    assert(iOldSame==oldSameList.size());
    //optimize: continue to reduce the decompressList?
    out_oldRefList.insert(out_oldRefList.end(),decompressList.begin(),decompressList.end());
    std::sort(out_oldRefList.begin(),out_oldRefList.end());
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rsi, %r13
movq 0x8(%rsi), %rsi
subq (%r13), %rsi
sarq $0x2, %rsi
shrq %rsi
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0xc846
movq (%r15), %r12
movq 0x8(%r15), %r15
movq %r15, %rax
subq %r12, %rax
je 0xc644
sarq $0x2, %rax
movq (%r13), %rcx
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
xorl %esi, %esi
movl 0x4(%rcx,%rsi,8), %edi
movl %edi, (%r12,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0xc60c
cmpq %r12, %r15
je 0xc644
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0xc27f
movq %r12, %rdi
movq %r15, %rsi
callq 0xc362
movq %r14, %rdi
callq 0x3f577
movl %eax, %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
testl %eax, %eax
jle 0xc73a
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
subq %rcx, %rax
sarq $0x2, %rax
cmpq %rax, %r12
jae 0xc6aa
cmpl (%rcx,%r12,4), %r15d
sete %r13b
jne 0xc6b2
leaq -0x1(%rax), %rdx
cmpq %r12, %rdx
je 0xc6af
leaq 0x1(%r12), %rsi
cmpl 0x4(%rcx,%r12,4), %r15d
movq %rsi, %r12
je 0xc691
movq %rsi, %r12
jmp 0xc6b2
xorl %r13d, %r13d
jmp 0xc6b2
movq %rax, %r12
movq %r14, %rdi
movl %r15d, %esi
callq 0x40520
testl %eax, %eax
je 0xc72e
movq %r14, %rdi
movl %r15d, %esi
callq 0x3fadd
testb %al, %al
je 0xc6f4
testb %r13b, %r13b
jne 0xc72e
movl %r15d, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xc71f
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xc72e
movl %r15d, 0xc(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xc710
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xc72e
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
callq 0xa8d2
jmp 0xc72e
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xa8d2
incl %r15d
cmpl %ebp, %r15d
jne 0xc66d
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x2, %rax
cmpq %rax, %r12
jne 0xc7df
movq 0x8(%rbx), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
callq 0xc0c4
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %rbx, %r14
je 0xc7a0
movq %rbx, %rax
subq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc27f
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc362
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc7b7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc7ce
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4ec7a(%rip), %rdi     # 0x5b460
leaq 0x4ec90(%rip), %rsi     # 0x5b47d
leaq 0x4ec9d(%rip), %rcx     # 0x5b491
movl $0x39, %edx
callq 0x4200
jmp 0xc802
jmp 0xc80d
movq %rax, %rbx
jmp 0xc827
jmp 0xc80d
jmp 0xc80d
jmp 0xc80d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc827
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc83e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45e0