// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %rcx, %r12
movq %rdx, %r15
movq %rdi, %r13
movq 0x50(%rsp), %r9
movq 0x48(%rsp), %r11
movq (%rbx), %rcx
xorl %ebp, %ebp
testq %r12, %r12
je 0x3b18a
addq %rcx, %r12
jb 0x3b1ea
cmpq 0x8(%r8), %r12
ja 0x3b1ea
testq %r13, %r13
je 0x3b1e4
movq %rsi, %r14
movq 0x40(%rsp), %rdi
movq %rsi, (%rsi)
movq %r15, 0x8(%rsi)
leaq 0xf5(%rip), %rax        # 0x3b248
movq %rax, 0x10(%rsi)
movq %rdi, 0x20(%rsi)
movq 0x28(%rsi), %rax
testq %rax, %rax
je 0x3b1b3
movq 0x20(%rdi), %r10
testq %r10, %r10
je 0x3b1ea
movq %rax, %rdi
movq %r15, %rsi
movq %r8, %rdx
movq %r12, %r8
movq %r11, %r15
callq *%r10
movq 0x50(%rsp), %r9
testl %eax, %eax
jne 0x3b1d0
jmp 0x3b1ea
addq %rcx, %r15
jb 0x3b1ea
cmpq 0x8(%r8), %r15
ja 0x3b1ea
testq %r13, %r13
je 0x3b1ae
movq %r13, %rdi
movq %r8, %rsi
movq %rcx, %rdx
movq %r15, %rcx
movq %r11, %r8
callq 0x3b1fb
movq %r15, %r12
jmp 0x3b1e4
movq %r15, %rsi
movq %r8, %rdx
movq %r12, %r8
movq %r11, %r15
callq *0x8(%rdi)
movq 0x50(%rsp), %r9
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x3b1ea
movq 0x8(%r14), %rcx
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %r8
callq 0x3b1fb
movq %r12, (%rbx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq