// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: getStreamClip
hpatch_BOOL getStreamClip(TStreamCacheClip* out_clip,_TDecompressInputStream* out_stream,
                          hpatch_StreamPos_t dataSize,hpatch_StreamPos_t compressedSize,
                          const hpatch_TStreamInput* stream,hpatch_StreamPos_t* pCurStreamPos,
                          hpatch_TDecompress* decompressPlugin,TByte* aCache,hpatch_size_t cacheSize){
    hpatch_StreamPos_t curStreamPos=*pCurStreamPos;
    if (compressedSize==0){
#ifdef __RUN_MEM_SAFE_CHECK
        if ((curStreamPos+dataSize)<curStreamPos) return _hpatch_FALSE;
        if ((curStreamPos+dataSize)>stream->streamSize) return _hpatch_FALSE;
#endif
        if (out_clip)
            _TStreamCacheClip_init(out_clip,stream,curStreamPos,curStreamPos+dataSize,aCache,cacheSize);
        curStreamPos+=dataSize;
    }else{
#ifdef __RUN_MEM_SAFE_CHECK
        if ((curStreamPos+compressedSize)<curStreamPos) return _hpatch_FALSE;
        if ((curStreamPos+compressedSize)>stream->streamSize) return _hpatch_FALSE;
#endif
        if (out_clip){
            out_stream->IInputStream.streamImport=out_stream;
            out_stream->IInputStream.streamSize=dataSize;
            out_stream->IInputStream.read=_decompress_read;
            out_stream->decompressPlugin=decompressPlugin;
            if (out_stream->decompressHandle==0){
                out_stream->decompressHandle=decompressPlugin->open(decompressPlugin,dataSize,stream,
                                                                    curStreamPos,curStreamPos+compressedSize);
                if (!out_stream->decompressHandle) return _hpatch_FALSE;
            }else{
                if (decompressPlugin->reset_code==0) return _hpatch_FALSE;
                if (!decompressPlugin->reset_code(out_stream->decompressHandle,dataSize,stream,curStreamPos,
                                                  curStreamPos+compressedSize)) return _hpatch_FALSE;
            }
            _TStreamCacheClip_init(out_clip,&out_stream->IInputStream,0,
                                   out_stream->IInputStream.streamSize,aCache,cacheSize);
        }
        curStreamPos+=compressedSize;
    }
    *pCurStreamPos=curStreamPos;
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x8707f
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x87028
movl $0x0, -0x4(%rbp)
jmp 0x871ce
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x87046
movl $0x0, -0x4(%rbp)
jmp 0x871ce
cmpq $0x0, -0x10(%rbp)
je 0x8706e
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x40(%rbp), %rcx
addq -0x20(%rbp), %rcx
movq 0x18(%rbp), %r8
movq 0x20(%rbp), %r9
callq 0x871e0
movq -0x20(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x871bc
movq -0x40(%rbp), %rax
addq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x87099
movl $0x0, -0x4(%rbp)
jmp 0x871ce
movq -0x40(%rbp), %rax
addq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x870b7
movl $0x0, -0x4(%rbp)
jmp 0x871ce
cmpq $0x0, -0x10(%rbp)
je 0x871b0
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq 0x1cc(%rip), %rcx       # 0x872b0
movq %rcx, 0x10(%rax)
movq 0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x87145
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x40(%rbp), %r8
addq -0x28(%rbp), %r8
callq *%rax
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x87143
movl $0x0, -0x4(%rbp)
jmp 0x871ce
jmp 0x8718f
movq 0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x87159
movl $0x0, -0x4(%rbp)
jmp 0x871ce
movq 0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x40(%rbp), %r8
addq -0x28(%rbp), %r8
callq *%rax
cmpl $0x0, %eax
jne 0x8718d
movl $0x0, -0x4(%rbp)
jmp 0x871ce
jmp 0x8718f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq 0x18(%rbp), %r8
movq 0x20(%rbp), %r9
xorl %eax, %eax
movl %eax, %edx
callq 0x871e0
movq -0x28(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)