// File: sisong[P]ApkDiffPatch/src/patch/ZipDiffData.cpp
// Function: openZipDiffData(hpatch_TStreamInput const*, hpatch_TDecompress*, unsigned long*)
static bool _openZipDiffData(const hpatch_TStreamInput* diffData,hpatch_TDecompress* decompressPlugin,
                  size_t* out_headInfoPos=0){
    const char* kVersionType="ZiPat1&";
    const size_t kVersionTypeLen=7;
    assert(kVersionTypeLen==strlen(kVersionType));
    
    TByte buf[kVersionTypeLen + hpatch_kMaxPluginTypeLength+1+1];
    int readLen=sizeof(buf)-1;
    buf[readLen]='\0';
    if ((size_t)readLen>diffData->streamSize)
        readLen=(int)diffData->streamSize;
    check(diffData->read(diffData,0,buf,buf+readLen));
    //check type+version
    check(0==strncmp((const char*)buf,kVersionType,kVersionTypeLen));
    {//read compressType
        check(decompressPlugin!=0);
        const char* compressType=(const char*)buf+kVersionTypeLen;
        size_t compressTypeLen=strlen(compressType);//safe
        check(compressTypeLen<=hpatch_kMaxPluginTypeLength);
        if (out_headInfoPos)
            *out_headInfoPos=kVersionTypeLen+compressTypeLen+1;
        hpatch_compressedDiffInfo compressedInfo={0,0,1};
        memcpy(compressedInfo.compressType,compressType,compressTypeLen+1); //'\0'
        return 0!=decompressPlugin->is_can_open(compressedInfo.compressType);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x3137f(%rip), %rax     # 0xadbfd
movq %rax, -0x20(%rbp)
movq $0x7, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x4180
movq %rax, %rcx
movl $0x7, %eax
cmpq %rcx, %rax
jne 0x7c8a2
jmp 0x7c8c1
leaq 0x36fad(%rip), %rdi     # 0xb3856
leaq 0x36b0f(%rip), %rsi     # 0xb33bf
movl $0x39, %edx
leaq 0x36fc0(%rip), %rcx     # 0xb387c
callq 0x4270
movl $0x10b, -0x144(%rbp)    # imm = 0x10B
movslq -0x144(%rbp), %rax
movb $0x0, -0x140(%rbp,%rax)
movslq -0x144(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x7c8f9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x144(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdi
leaq -0x140(%rbp), %rdx
leaq -0x140(%rbp), %rcx
movslq -0x144(%rbp), %rsi
addq %rsi, %rcx
xorl %esi, %esi
callq *%rax
cmpl $0x0, %eax
jne 0x7c953
leaq 0x36fa2(%rip), %rdi     # 0xb38cf
movb $0x0, %al
callq 0x4060
leaq 0x30935(%rip), %rdi     # 0xad270
leaq 0x36a7d(%rip), %rsi     # 0xb33bf
movl $0x40, %edx
leaq 0x36f2e(%rip), %rcx     # 0xb387c
callq 0x4270
leaq -0x140(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x7, %edx
callq 0x41d0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x7c99d
leaq 0x36f8b(%rip), %rdi     # 0xb3902
movb $0x0, %al
callq 0x4060
leaq 0x308eb(%rip), %rdi     # 0xad270
leaq 0x36a33(%rip), %rsi     # 0xb33bf
movl $0x42, %edx
leaq 0x36ee4(%rip), %rcx     # 0xb387c
callq 0x4270
cmpq $0x0, -0x10(%rbp)
jne 0x7c9d1
leaq 0x31427(%rip), %rdi     # 0xaddd2
movb $0x0, %al
callq 0x4060
leaq 0x308b7(%rip), %rdi     # 0xad270
leaq 0x369ff(%rip), %rsi     # 0xb33bf
movl $0x44, %edx
leaq 0x36eb0(%rip), %rcx     # 0xb387c
callq 0x4270
leaq -0x140(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdi
callq 0x4180
movq %rax, -0x158(%rbp)
cmpq $0x103, -0x158(%rbp) # imm = 0x103
jbe 0x7ca30
leaq 0x36f3a(%rip), %rdi     # 0xb3944
movb $0x0, %al
callq 0x4060
leaq 0x30858(%rip), %rdi     # 0xad270
leaq 0x369a0(%rip), %rsi     # 0xb33bf
movl $0x47, %edx
leaq 0x36e51(%rip), %rcx     # 0xb387c
callq 0x4270
cmpq $0x0, -0x18(%rbp)
je 0x7ca4d
movq -0x158(%rbp), %rcx
addq $0x7, %rcx
addq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x270(%rbp), %rdi
xorl %esi, %esi
movl $0x118, %edx            # imm = 0x118
callq 0x4210
movl $0x1, -0x260(%rbp)
leaq -0x270(%rbp), %rdi
addq $0x14, %rdi
movq -0x150(%rbp), %rsi
movq -0x158(%rbp), %rdx
addq $0x1, %rdx
callq 0x4320
movq -0x10(%rbp), %rax
movq (%rax), %rax
leaq -0x270(%rbp), %rdi
addq $0x14, %rdi
callq *%rax
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
setne %al
andb $0x1, %al
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
nopw %cs:(%rax,%rax)