// File: sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: UnZipper_compressedData_decompressTo
bool UnZipper_compressedData_decompressTo(UnZipper* self,const hpatch_TStreamInput* codeStream,
                                          hpatch_StreamPos_t code_begin,hpatch_StreamPos_t code_end,
                                          hpatch_StreamPos_t uncompressedSize,
                                          const hpatch_TStreamOutput* outStream,hpatch_StreamPos_t writeToPos){
    bool result=true;
    _zlib_TDecompress* decHandle=_zlib_decompress_open_by(decompressPlugin,codeStream,code_begin,
                                                          code_end,0,self->_buf,(kBufSize>>1));
    TByte* dataBuf=self->_buf+(kBufSize>>1);
    hpatch_StreamPos_t  curWritePos=0;
    check_clear(decHandle!=0);
    while (curWritePos<uncompressedSize){
        hpatch_StreamPos_t readLen=(kBufSize>>1);
        if (readLen>(uncompressedSize-curWritePos)) readLen=uncompressedSize-curWritePos;
        check_clear(_zlib_decompress_part(decHandle,dataBuf,dataBuf+readLen));
        check_clear(outStream->write(outStream,writeToPos+curWritePos,dataBuf,dataBuf+readLen));
        curWritePos+=readLen;
    }
    if (!_zlib_is_decompress_finish(decompressPlugin,decHandle))
        printf("WARNING: zip format error, decompress not finish!\n");
clear:
    _zlib_decompress_close_by(decompressPlugin,decHandle);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movb $0x1, -0x31(%rbp)
movq 0x65cc1(%rip), %rdi     # 0xe65b0
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x90(%rax), %r9
xorl %r8d, %r8d
movq $0x2000, (%rsp)         # imm = 0x2000
callq 0x80a70
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
addq $0x2000, %rax           # imm = 0x2000
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x80961
movb $0x0, -0x31(%rbp)
leaq 0x2c927(%rip), %rdi     # 0xad270
leaq 0x3303a(%rip), %rsi     # 0xb398a
movl $0x28b, %edx            # imm = 0x28B
leaq 0x3323e(%rip), %rcx     # 0xb3b9a
callq 0x4270
jmp 0x80963
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x80a2e
movq $0x2000, -0x58(%rbp)    # imm = 0x2000
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
subq -0x50(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x80996
movq -0x28(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq -0x58(%rbp), %rdx
callq 0x80b10
cmpl $0x0, %eax
jne 0x809d3
movb $0x0, -0x31(%rbp)
leaq 0x2c8b5(%rip), %rdi     # 0xad270
leaq 0x32fc8(%rip), %rsi     # 0xb398a
movl $0x28f, %edx            # imm = 0x28F
leaq 0x331cc(%rip), %rcx     # 0xb3b9a
callq 0x4270
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movq 0x10(%rbp), %rsi
addq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x48(%rbp), %rcx
addq -0x58(%rbp), %rcx
callq *%rax
cmpl $0x0, %eax
jne 0x80a1d
movb $0x0, -0x31(%rbp)
leaq 0x2c86b(%rip), %rdi     # 0xad270
leaq 0x32f7e(%rip), %rsi     # 0xb398a
movl $0x290, %edx            # imm = 0x290
leaq 0x33182(%rip), %rcx     # 0xb3b9a
callq 0x4270
movq -0x58(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x80963
movq 0x65b7b(%rip), %rdi     # 0xe65b0
movq -0x40(%rbp), %rsi
callq 0x80bb0
cmpl $0x0, %eax
jne 0x80a51
leaq 0x33211(%rip), %rdi     # 0xb3c5b
movb $0x0, %al
callq 0x4060
jmp 0x80a53
movq 0x65b56(%rip), %rdi     # 0xe65b0
movq -0x40(%rbp), %rsi
callq 0x80c70
movb -0x31(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nop