// File: sisong[P]ApkDiffPatch/src/diff/Differ.cpp
// Function: checkZipDiffWithStream(hpatch_TStreamInput const*, hpatch_TStreamInput const*, hpatch_TStreamInput const*, int)
TCheckZipDiffResult checkZipDiffWithStream(const hpatch_TStreamInput* oldZipStream,
                                           const hpatch_TStreamInput* newZipStream,
                                           const hpatch_TStreamInput* diffStream,int threadNum){
    assert((size_t)newZipStream->streamSize==newZipStream->streamSize);
    std::vector<TByte>      temp_newZip;
    TVectorStreamOutput     temp_outNewZipStream(temp_newZip);
    if (PATCH_SUCCESS!=ZipPatchWithStream(oldZipStream,diffStream,&temp_outNewZipStream,0,0,threadNum))
        return CHECK_ZIPPATCH_ERROR;
    //else
        
    
    hpatch_TStreamInput     temp_inNewZipStream;
    mem_as_hStreamInput(&temp_inNewZipStream,temp_newZip.data(),temp_newZip.data()+temp_newZip.size());
    bool isByteByByteEqual=getIsEqual(newZipStream,&temp_inNewZipStream);
    if (isByteByByteEqual)
        return CHECK_BYTE_BY_BYTE_EQUAL_TRUE;
    
    bool isOldHaveApkV2Sign=false;
    bool isSame=getZipIsSameWithStream(newZipStream,&temp_inNewZipStream,0,&isOldHaveApkV2Sign);
    if (!isSame)
        return CHECK_SAME_LIKE_ERROR;
    if (isOldHaveApkV2Sign)
        return CHECK_SAME_LIKE_TRUE__BYTE_BY_BYTE_EQUAL_ERROR;
    else
        return CHECK_SAME_LIKE_TRUE__BYTE_BY_BYTE_EQUAL_FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x13dae
jmp 0x13dcd
leaq 0x9a595(%rip), %rdi     # 0xae34a
leaq 0x9a5c9(%rip), %rsi     # 0xae385
movl $0x16e, %edx            # imm = 0x16E
leaq 0x9a5d1(%rip), %rcx     # 0xae399
callq 0x4270
leaq -0x40(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0xbe70
movq -0xa8(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x14bb0
jmp 0x13def
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %r9d
xorl %eax, %eax
movl %eax, %r8d
leaq -0x68(%rbp), %rdx
movq %r8, %rcx
callq 0xa37a0
movl %eax, -0xac(%rbp)
jmp 0x13e14
movl -0xac(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x13e4d
movl $0x4, -0x4(%rbp)
movl $0x1, -0x78(%rbp)
jmp 0x13f57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xbb80
jmp 0x13f6c
leaq -0x40(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0xbb60
movq -0xc8(%rbp), %rdi
movq %rax, -0xb8(%rbp)
callq 0xbb60
movq -0xc8(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0xbe90
movq -0xc0(%rbp), %rdx
movq -0xb8(%rbp), %rsi
addq %rax, %rdx
leaq -0x98(%rbp), %rdi
callq 0x85b30
jmp 0x13ea2
movq -0x18(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x14560
movb %al, -0xc9(%rbp)
jmp 0x13eba
movb -0xc9(%rbp), %al
andb $0x1, %al
movb %al, -0x99(%rbp)
testb $0x1, -0x99(%rbp)
je 0x13ee1
movl $0x0, -0x4(%rbp)
movl $0x1, -0x78(%rbp)
jmp 0x13f57
movb $0x0, -0x9a(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x98(%rbp), %rsi
xorl %edx, %edx
leaq -0x9a(%rbp), %rcx
callq 0x8c70
movb %al, -0xca(%rbp)
jmp 0x13f09
movb -0xca(%rbp), %al
andb $0x1, %al
movb %al, -0x9b(%rbp)
testb $0x1, -0x9b(%rbp)
jne 0x13f30
movl $0x3, -0x4(%rbp)
movl $0x1, -0x78(%rbp)
jmp 0x13f57
testb $0x1, -0x9a(%rbp)
je 0x13f49
movl $0x2, -0x4(%rbp)
movl $0x1, -0x78(%rbp)
jmp 0x13f57
movl $0x1, -0x4(%rbp)
movl $0x1, -0x78(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xbb80
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)