// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rcx, %rbx
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0x10(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x58(%rsp), %rdi
callq 0x37105
leaq 0x108(%rsp), %rdi
callq 0x37105
leaq 0x58(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3719a
testb %al, %al
je 0x6c7e
leaq 0x108(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3719a
testb %al, %al
je 0x6ca6
testq %rbx, %rbx
je 0x6aa4
movq 0xf0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
setb (%rbx)
leaq 0x58(%rsp), %rdi
callq 0x36bfd
movl %eax, %r14d
leaq 0x108(%rsp), %rdi
callq 0x36bfd
addl 0x4(%rsp), %eax
xorl %ebx, %ebx
cmpl %eax, %r14d
jne 0x6bbb
testl %r14d, %r14d
movl $0x0, %ebp
cmovgl %r14d, %ebp
leaq 0x38(%rsp), %r15
leaq 0x58(%rsp), %r12
leaq 0x8(%rsp), %r13
cmpl %ebx, %ebp
je 0x6b12
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x6d91
movq %r13, %rdi
movq %r15, %rsi
callq 0x83d6
movl %ebx, (%rax)
movq %r15, %rdi
callq 0x4170
incl %ebx
jmp 0x6ae8
movslq %r14d, %rax
xorl %ebx, %ebx
cmpq %rax, 0x30(%rsp)
jne 0x6bbb
subl 0x4(%rsp), %r14d
testl %r14d, %r14d
cmovlel %ebx, %r14d
leaq 0x38(%rsp), %r15
leaq 0x108(%rsp), %r12
cmpl %ebx, %r14d
je 0x6c00
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x6d91
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8f8c
movq %rax, %r13
movq %r15, %rdi
callq 0x4170
leaq 0x10(%rsp), %rax
cmpq %rax, %r13
je 0x6bb9
movl 0x40(%r13), %ebp
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x8fca
leaq 0x58(%rsp), %rdi
movl %ebp, %esi
callq 0x37b21
movl %eax, %r13d
movq %r12, %rdi
movl %ebx, %esi
callq 0x37b21
cmpl %eax, %r13d
jne 0x6bb9
leaq 0x58(%rsp), %rdi
movl %ebp, %esi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x68c0
incl %ebx
testb %al, %al
jne 0x6b3b
xorl %ebx, %ebx
leaq 0x108(%rsp), %rdi
callq 0x37111
testb %al, %al
je 0x6ccb
leaq 0x58(%rsp), %rdi
callq 0x37111
testb %al, %al
je 0x6cf0
leaq 0x8(%rsp), %rdi
callq 0x84f2
movl %ebx, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rsp), %ecx
movslq %ecx, %rax
cmpq %rax, 0x30(%rsp)
jne 0x6d3e
movb $0x1, %bl
testl %ecx, %ecx
jle 0x6bbb
movq 0x20(%rsp), %r12
leaq 0x58(%rsp), %r14
leaq 0x4876b(%rip), %r15     # 0x4f394
pushq $0x11
popq %rbp
leaq 0x10(%rsp), %rax
cmpq %rax, %r12
je 0x6bbb
movl 0x40(%r12), %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x36ceb
testb %al, %al
jne 0x6c71
movq %r14, %rdi
movl %r13d, %esi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x36d99
testb %al, %al
jne 0x6c71
movq %r14, %rdi
movl %r13d, %esi
callq 0x37b03
testl %eax, %eax
jne 0x6d15
movq %r12, %rdi
callq 0x4260
movq %rax, %r12
jmp 0x6c2c
leaq 0x4887d(%rip), %rdi     # 0x4f502
callq 0x4510
leaq 0x483bf(%rip), %rdi     # 0x4f050
leaq 0x483be(%rip), %rsi     # 0x4f056
leaq 0x48407(%rip), %rcx     # 0x4f0a6
pushq $0x4b
jmp 0x6d38
leaq 0x48886(%rip), %rdi     # 0x4f533
callq 0x4510
leaq 0x48397(%rip), %rdi     # 0x4f050
leaq 0x48396(%rip), %rsi     # 0x4f056
leaq 0x483df(%rip), %rcx     # 0x4f0a6
pushq $0x4c
jmp 0x6d38
leaq 0x488bb(%rip), %rdi     # 0x4f58d
callq 0x4510
leaq 0x48372(%rip), %rdi     # 0x4f050
leaq 0x48371(%rip), %rsi     # 0x4f056
leaq 0x483ba(%rip), %rcx     # 0x4f0a6
pushq $0x6c
jmp 0x6d38
leaq 0x488b5(%rip), %rdi     # 0x4f5ac
callq 0x4510
leaq 0x4834d(%rip), %rdi     # 0x4f050
leaq 0x4834c(%rip), %rsi     # 0x4f056
leaq 0x48395(%rip), %rcx     # 0x4f0a6
pushq $0x6d
jmp 0x6d38
leaq 0x488af(%rip), %rdi     # 0x4f5cb
callq 0x4510
leaq 0x48328(%rip), %rdi     # 0x4f050
leaq 0x48327(%rip), %rsi     # 0x4f056
leaq 0x48370(%rip), %rcx     # 0x4f0a6
pushq $0x66
popq %rdx
callq 0x4230
leaq 0x4881f(%rip), %rdi     # 0x4f564
callq 0x4510
leaq 0x482ff(%rip), %rdi     # 0x4f050
leaq 0x482fe(%rip), %rsi     # 0x4f056
leaq 0x48347(%rip), %rcx     # 0x4f0a6
pushq $0x60
jmp 0x6d38
jmp 0x6d72
jmp 0x6d6d
jmp 0x6d6d
jmp 0x6d6d
jmp 0x6d6d
movq %rax, %rbx
jmp 0x6d7f
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
callq 0x84f2
movq %rbx, %rdi
callq 0x4600