// File: sisong[P]ApkDiffPatch/src/diff/DiffData.cpp
// Function: getZipIsSameWithStream(hpatch_TStreamInput const*, hpatch_TStreamInput const*, int, bool*)
bool getZipIsSameWithStream(const hpatch_TStreamInput* oldZipStream,
                            const hpatch_TStreamInput* newZipStream,
                            int newApkFilesRemoved,bool* out_isOldHaveApkV2Sign){
    UnZipper            newZip;
    UnZipper            oldZip;
    std::map<std::string,int> oldMap;
    bool            result=true;
    bool            _isInClear=false;
    int             fileCount=0;
    
    UnZipper_init(&oldZip);
    UnZipper_init(&newZip);
    check_clear(UnZipper_openStream(&oldZip,oldZipStream));
    check_clear(UnZipper_openStream(&newZip,newZipStream));
    
    if (out_isOldHaveApkV2Sign){
        *out_isOldHaveApkV2Sign=UnZipper_isHaveApkV2Sign(&oldZip);
    }
    
    fileCount=UnZipper_fileCount(&oldZip);
    test_clear(fileCount==UnZipper_fileCount(&newZip)+newApkFilesRemoved);
    for (int i=0;i<fileCount; ++i)
        oldMap[zipFile_name(&oldZip,i)]=i;
    test_clear(oldMap.size()==(size_t)fileCount);
    
    for (int i=0;i<fileCount-newApkFilesRemoved; ++i) {
        std::map<std::string,int>::iterator it=oldMap.find(zipFile_name(&newZip,i));
        test_clear(it!=oldMap.end());
        int old_i=it->second;
        oldMap.erase(it);//del
        test_clear(UnZipper_file_crc32(&oldZip,old_i)==UnZipper_file_crc32(&newZip,i));
        test_clear(zipFileData_isSame(&oldZip,old_i,&newZip,i));
    }
    check_clear(oldMap.size()==newApkFilesRemoved);
    if (newApkFilesRemoved>0){
        for (std::map<std::string,int>::iterator it=oldMap.begin();it!=oldMap.end();++it){
            int old_i=it->second;
            check_clear(UnZipper_file_isApkV1Sign(&oldZip,old_i)
                        ||UnZipper_file_isStampCertFile(&oldZip,old_i)
                        ||(UnZipper_file_uncompressedSize(&oldZip,old_i)==0));
        }
    }

clear:
    _isInClear=true;
    check_clear(UnZipper_close(&newZip));
    check_clear(UnZipper_close(&oldZip));
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0xbbe0
movb $0x1, -0x1b1(%rbp)
movb $0x0, -0x1b2(%rbp)
movl $0x0, -0x1b8(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x7f360
jmp 0x8cbc
leaq -0xd0(%rbp), %rdi
callq 0x7f360
jmp 0x8cca
movq -0x8(%rbp), %rsi
leaq -0x180(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x7f480
movb %al, -0x24d(%rbp)
jmp 0x8ceb
movb -0x24d(%rbp), %al
testb $0x1, %al
jne 0x8d44
jmp 0x8cf7
leaq 0xa4608(%rip), %rdi     # 0xad306
xorl %eax, %eax
callq 0x4060
jmp 0x8d07
movb $0x0, -0x1b1(%rbp)
leaq 0xa455b(%rip), %rdi     # 0xad270
leaq 0xa455a(%rip), %rsi     # 0xad276
movl $0x4b, %edx
leaq 0xa4610(%rip), %rcx     # 0xad338
callq 0x4270
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x933e
movq -0x10(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x7f480
movb %al, -0x24e(%rbp)
jmp 0x8d65
movb -0x24e(%rbp), %al
testb $0x1, %al
jne 0x8da7
jmp 0x8d71
leaq 0xa4623(%rip), %rdi     # 0xad39b
xorl %eax, %eax
callq 0x4060
jmp 0x8d81
movb $0x0, -0x1b1(%rbp)
leaq 0xa44e1(%rip), %rdi     # 0xad270
leaq 0xa44e0(%rip), %rsi     # 0xad276
movl $0x4c, %edx
leaq 0xa4596(%rip), %rcx     # 0xad338
callq 0x4270
cmpq $0x0, -0x20(%rbp)
je 0x8dd1
leaq -0x180(%rbp), %rdi
callq 0x9360
movb %al, -0x24f(%rbp)
jmp 0x8dc2
movb -0x24f(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
leaq -0x180(%rbp), %rdi
callq 0x7ea90
movl %eax, -0x254(%rbp)
jmp 0x8de5
movl -0x254(%rbp), %eax
movl %eax, -0x1b8(%rbp)
movl -0x1b8(%rbp), %eax
movl %eax, -0x25c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x7ea90
movl %eax, -0x258(%rbp)
jmp 0x8e11
movl -0x25c(%rbp), %eax
movl -0x258(%rbp), %ecx
addl -0x14(%rbp), %ecx
cmpl %ecx, %eax
je 0x8e3b
movb $0x0, -0x1b1(%rbp)
testb $0x1, -0x1b2(%rbp)
jne 0x8e39
jmp 0x9262
jmp 0x8e3b
movl $0x0, -0x1c8(%rbp)
movl -0x1c8(%rbp), %eax
cmpl -0x1b8(%rbp), %eax
jge 0x8ee3
movl -0x1c8(%rbp), %edx
movl %edx, -0x260(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x9390
jmp 0x8e78
leaq -0x1b0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0xbc00
movq %rax, -0x268(%rbp)
jmp 0x8e94
movq -0x268(%rbp), %rax
movl -0x260(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x1e8(%rbp), %rdi
callq 0x4260
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0x8e45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x4260
jmp 0x933e
leaq -0x1b0(%rbp), %rdi
callq 0xbce0
movslq -0x1b8(%rbp), %rcx
cmpq %rcx, %rax
je 0x8f12
movb $0x0, -0x1b1(%rbp)
testb $0x1, -0x1b2(%rbp)
jne 0x8f10
jmp 0x9262
jmp 0x8f12
movl $0x0, -0x1ec(%rbp)
movl -0x1ec(%rbp), %eax
movl -0x1b8(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x90f4
movl -0x1ec(%rbp), %edx
leaq -0x218(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9390
jmp 0x8f4e
leaq -0x1b0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0xbd00
movq %rax, -0x270(%rbp)
jmp 0x8f6a
movq -0x270(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x4260
leaq -0x1b0(%rbp), %rdi
callq 0xbd60
movq %rax, -0x220(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0xbd30
xorb $-0x1, %al
testb $0x1, %al
jne 0x8fb2
jmp 0x8fec
movb $0x0, -0x1b1(%rbp)
testb $0x1, -0x1b2(%rbp)
jne 0x8fea
jmp 0x9262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x4260
jmp 0x933e
jmp 0x8fec
leaq -0x1f8(%rbp), %rdi
callq 0xbd90
movl 0x20(%rax), %eax
movl %eax, -0x224(%rbp)
movq -0x1f8(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0xbdb0
movq %rax, -0x278(%rbp)
jmp 0x902b
movq -0x278(%rbp), %rax
movq %rax, -0x238(%rbp)
movl -0x224(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x80540
movl %eax, -0x27c(%rbp)
jmp 0x9053
movl -0x1ec(%rbp), %esi
leaq -0xd0(%rbp), %rdi
callq 0x80540
movl %eax, -0x280(%rbp)
jmp 0x906d
movl -0x27c(%rbp), %eax
movl -0x280(%rbp), %ecx
cmpl %ecx, %eax
je 0x9094
movb $0x0, -0x1b1(%rbp)
testb $0x1, -0x1b2(%rbp)
jne 0x9092
jmp 0x9262
jmp 0x9094
movl -0x224(%rbp), %esi
movl -0x1ec(%rbp), %ecx
leaq -0x180(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x8a10
movb %al, -0x281(%rbp)
jmp 0x90bb
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x90de
jmp 0x90c7
movb $0x0, -0x1b1(%rbp)
testb $0x1, -0x1b2(%rbp)
jne 0x90dc
jmp 0x9262
jmp 0x90de
jmp 0x90e0
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
jmp 0x8f1c
leaq -0x1b0(%rbp), %rdi
callq 0xbce0
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0x913f
leaq 0xa42bd(%rip), %rdi     # 0xad3cd
xorl %eax, %eax
callq 0x4060
jmp 0x9119
movb $0x0, -0x1b1(%rbp)
leaq 0xa4149(%rip), %rdi     # 0xad270
leaq 0xa4148(%rip), %rsi     # 0xad276
movl $0x60, %edx
leaq 0xa41fe(%rip), %rcx     # 0xad338
callq 0x4270
cmpl $0x0, -0x14(%rbp)
jle 0x9260
leaq -0x1b0(%rbp), %rdi
callq 0xbdf0
movq %rax, -0x240(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0xbd60
movq %rax, -0x248(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0xbd30
testb $0x1, %al
jne 0x918b
jmp 0x925e
leaq -0x240(%rbp), %rdi
callq 0xbd90
movl 0x20(%rax), %eax
movl %eax, -0x24c(%rbp)
movl -0x24c(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x7ecf0
movb %al, -0x282(%rbp)
jmp 0x91ba
movb -0x282(%rbp), %al
testb $0x1, %al
jne 0x924b
jmp 0x91ca
movl -0x24c(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x9440
movb %al, -0x283(%rbp)
jmp 0x91e4
movb -0x283(%rbp), %al
testb $0x1, %al
jne 0x924b
jmp 0x91f0
movl -0x24c(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x80480
movl %eax, -0x288(%rbp)
jmp 0x920a
movl -0x288(%rbp), %eax
cmpl $0x0, %eax
je 0x924b
leaq 0xa41db(%rip), %rdi     # 0xad3f7
xorl %eax, %eax
callq 0x4060
jmp 0x9225
movb $0x0, -0x1b1(%rbp)
leaq 0xa403d(%rip), %rdi     # 0xad270
leaq 0xa403c(%rip), %rsi     # 0xad276
movl $0x66, %edx
leaq 0xa40f2(%rip), %rcx     # 0xad338
callq 0x4270
jmp 0x924d
leaq -0x240(%rbp), %rdi
callq 0xbe20
jmp 0x915c
jmp 0x9260
jmp 0x9262
movb $0x1, -0x1b2(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x7f390
movb %al, -0x289(%rbp)
jmp 0x927d
movb -0x289(%rbp), %al
testb $0x1, %al
jne 0x92bf
jmp 0x9289
leaq 0xa41fc(%rip), %rdi     # 0xad48c
xorl %eax, %eax
callq 0x4060
jmp 0x9299
movb $0x0, -0x1b1(%rbp)
leaq 0xa3fc9(%rip), %rdi     # 0xad270
leaq 0xa3fc8(%rip), %rsi     # 0xad276
movl $0x6c, %edx
leaq 0xa407e(%rip), %rcx     # 0xad338
callq 0x4270
leaq -0x180(%rbp), %rdi
callq 0x7f390
movb %al, -0x28a(%rbp)
jmp 0x92d3
movb -0x28a(%rbp), %al
testb $0x1, %al
jne 0x9315
jmp 0x92df
leaq 0xa41c6(%rip), %rdi     # 0xad4ac
xorl %eax, %eax
callq 0x4060
jmp 0x92ef
movb $0x0, -0x1b1(%rbp)
leaq 0xa3f73(%rip), %rdi     # 0xad270
leaq 0xa3f72(%rip), %rsi     # 0xad276
movl $0x6d, %edx
leaq 0xa4028(%rip), %rcx     # 0xad338
callq 0x4270
movb -0x1b1(%rbp), %al
movb %al, -0x28b(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0xbe50
movb -0x28b(%rbp), %al
andb $0x1, %al
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x1b0(%rbp), %rdi
callq 0xbe50
movq -0x1c0(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)