// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
movq %r9, %rbx
movq %rcx, %r15
movq %rdi, %r14
movq (%r9), %rcx
xorl %ebp, %ebp
testq %r15, %r15
je 0x44176
addq %rcx, %r15
jb 0x441d7
cmpq 0x8(%r8), %r15
ja 0x441d7
testq %r14, %r14
je 0x441cc
movq %rsi, %r12
movq 0x30(%rsp), %rdi
movq %rsi, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x9b(%rip), %rax        # 0x441e2
movq %rax, 0x10(%rsi)
movq %rdi, 0x20(%rsi)
movq 0x28(%rsi), %rax
testq %rax, %rax
je 0x4418b
movq 0x20(%rdi), %r9
testq %r9, %r9
je 0x441d7
movq %rax, %rdi
movq %rdx, %rsi
movq %r8, %rdx
movq %r15, %r8
callq *%r9
testl %eax, %eax
jne 0x441a1
jmp 0x441d7
addq %rcx, %rdx
jb 0x441d7
cmpq 0x8(%r8), %rdx
ja 0x441d7
movq %rdx, %r15
testq %r14, %r14
jne 0x441ab
jmp 0x441cf
movq %rdx, %rsi
movq %r8, %rdx
movq %r15, %r8
callq *0x8(%rdi)
movq %rax, 0x28(%r12)
testq %rax, %rax
je 0x441d7
movq 0x8(%r12), %rdx
xorl %ecx, %ecx
movq %r12, %r8
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rsi
movq %rcx, (%r14)
movq %rdx, 0x8(%r14)
movq %r8, 0x10(%r14)
movq %rsi, 0x18(%r14)
movq %rax, 0x20(%r14)
movq %rax, 0x28(%r14)
movq %r15, %rdx
movq %rdx, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq