// File: /workspace/github_cpp_makefile_star2_O1/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 0xcab2
movq (%r15), %r12
movq 0x8(%r15), %r15
movq %r15, %rax
subq %r12, %rax
sarq $0x2, %rax
cmpq %r12, %r15
je 0xc887
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 0xc877
cmpq %r15, %r12
je 0xc8af
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0xc4c3
movq %r12, %rdi
movq %r15, %rsi
callq 0xc5a6
movq %r14, %rdi
callq 0x3f9dd
movl %eax, %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
testl %eax, %eax
jle 0xc9a5
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
subq %rcx, %rax
sarq $0x2, %rax
cmpq %rax, %r12
jae 0xc915
cmpl (%rcx,%r12,4), %r15d
sete %r13b
jne 0xc91d
leaq -0x1(%rax), %rdx
cmpq %r12, %rdx
je 0xc91a
leaq 0x1(%r12), %rsi
cmpl 0x4(%rcx,%r12,4), %r15d
movq %rsi, %r12
je 0xc8fc
movq %rsi, %r12
jmp 0xc91d
xorl %r13d, %r13d
jmp 0xc91d
movq %rax, %r12
movq %r14, %rdi
movl %r15d, %esi
callq 0x4092e
testl %eax, %eax
je 0xc999
movq %r14, %rdi
movl %r15d, %esi
callq 0x3fee7
testb %al, %al
je 0xc95f
testb %r13b, %r13b
jne 0xc999
movl %r15d, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xc98a
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xc999
movl %r15d, 0xc(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xc97b
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xc999
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
callq 0xab2c
jmp 0xc999
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xab2c
incl %r15d
cmpl %ebp, %r15d
jne 0xc8d8
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x2, %rax
cmpq %rax, %r12
jne 0xca4a
movq 0x8(%rbx), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
callq 0xc2d0
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %rbx, %r14
je 0xca0b
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 0xc4c3
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc5a6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xca22
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xca39
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 0x4ea0f(%rip), %rdi     # 0x5b460
leaq 0x4ea25(%rip), %rsi     # 0x5b47d
leaq 0x4ea32(%rip), %rcx     # 0x5b491
movl $0x39, %edx
callq 0x4200
jmp 0xca78
jmp 0xca71
jmp 0xca78
jmp 0xca78
movq %rax, %rbx
jmp 0xca92
jmp 0xca78
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xca92
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xcaa9
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45e0
nop