// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: patchByClip
static hpatch_BOOL patchByClip(_TOutStreamCache* outCache,
                               const hpatch_TStreamInput*  oldData,
                               hpatch_TCovers* covers,
                               TStreamCacheClip* code_newDataDiffClip,
                               struct _TBytesRle_load_stream* rle_loader,
                               TByte* temp_cache,hpatch_size_t cache_size){
    const hpatch_StreamPos_t newDataSize=_TOutStreamCache_leaveSize(outCache);
    const hpatch_StreamPos_t oldDataSize=oldData->streamSize;
    hpatch_StreamPos_t coverCount=covers->leave_cover_count(covers);
    hpatch_StreamPos_t newPosBack=0;
    assert(cache_size>=hpatch_kMaxPackedUIntBytes);
    
    while (coverCount--){
        hpatch_TCover cover;
        if(!covers->read_cover(covers,&cover)) return _hpatch_FALSE;
#ifdef __RUN_MEM_SAFE_CHECK
        if (cover.newPos<newPosBack) return _hpatch_FALSE;
        if (cover.length>(hpatch_StreamPos_t)(newDataSize-cover.newPos)) return _hpatch_FALSE;
        if (cover.oldPos>oldDataSize) return _hpatch_FALSE;
        if (cover.length>(hpatch_StreamPos_t)(oldDataSize-cover.oldPos)) return _hpatch_FALSE;
#endif
        if (newPosBack<cover.newPos){
            hpatch_StreamPos_t copyLength=cover.newPos-newPosBack;
            if (!_TOutStreamCache_copyFromClip(outCache,code_newDataDiffClip,copyLength)) return _hpatch_FALSE;
            if (!_rle_decode_skip(rle_loader,copyLength)) return _hpatch_FALSE;
        }
        if (!_patch_add_old_with_rle(outCache,rle_loader,oldData,cover.oldPos,cover.length,
                                     temp_cache,cache_size)) return _hpatch_FALSE;
        newPosBack=cover.newPos+cover.length;
    }
    
    if (newPosBack<newDataSize){
        hpatch_StreamPos_t copyLength=newDataSize-newPosBack;
        if (!_TOutStreamCache_copyFromClip(outCache,code_newDataDiffClip,copyLength)) return _hpatch_FALSE;
        if (!_rle_decode_skip(rle_loader,copyLength)) return _hpatch_FALSE;
        newPosBack=newDataSize;
    }
    if (!_TOutStreamCache_flush(outCache))
        return _hpatch_FALSE;
    if (   _TBytesRle_load_stream_isFinish(rle_loader)
        && covers->is_finish(covers)
        && _TOutStreamCache_isFinish(outCache)
        && _TStreamCacheClip_isFinish(code_newDataDiffClip)
        && (newPosBack==newDataSize) )
        return hpatch_TRUE;
    else
        return _hpatch_FALSE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r13
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %r12
movq %rsi, %rbp
movq 0x90(%rsp), %r14
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rax
movq %rdi, 0x8(%rsp)
subq (%rdi), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x50(%rsp)
movq %rdx, %rdi
callq *(%rdx)
cmpq $0xb, %r14
jb 0x3df41
xorl %ecx, %ecx
leaq 0x28(%rsp), %rsi
movq %r12, 0x40(%rsp)
subq $0x1, %rax
jb 0x3de5e
movq %rax, 0x48(%rsp)
movq %r12, %rdi
movq %rcx, %rbx
callq *0x8(%r12)
testl %eax, %eax
je 0x3de4b
movq %rbx, %rcx
movq 0x30(%rsp), %r12
cmpq %rbx, %r12
jb 0x3de4b
movq 0x38(%rsp), %rbx
movq 0x10(%rsp), %rax
subq %r12, %rax
cmpq %rax, %rbx
ja 0x3de4b
movq 0x28(%rsp), %r15
movq 0x50(%rsp), %rax
subq %r15, %rax
jb 0x3de4b
cmpq %rax, %rbx
ja 0x3de4b
subq %rcx, %r12
jbe 0x3ddd9
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rdx
callq 0x3b45c
testl %eax, %eax
je 0x3de4b
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x3df60
testl %eax, %eax
je 0x3de4b
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %rbx
testq %rbx, %rbx
je 0x3de2d
cmpq %r14, %rbx
movq %r14, %r12
cmovbq %rbx, %r12
leaq (%r13,%r12), %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *0x10(%rbp)
testl %eax, %eax
je 0x3de4b
movq 0x20(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3df95
testl %eax, %eax
je 0x3de4b
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3b2c3
testl %eax, %eax
je 0x3de4b
addq %r12, %r15
subq %r12, %rbx
jmp 0x3ddd9
movq 0x38(%rsp), %rcx
addq 0x30(%rsp), %rcx
movq 0x40(%rsp), %r12
movq 0x48(%rsp), %rax
leaq 0x28(%rsp), %rsi
jmp 0x3dd3a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %r15
subq %rcx, %r15
movq 0x20(%rsp), %r14
jbe 0x3de99
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x3b45c
xorl %ebx, %ebx
testl %eax, %eax
je 0x3de4d
movq %r14, %rdi
movq %r15, %rsi
callq 0x3df60
movq 0x10(%rsp), %rcx
testl %eax, %eax
je 0x3de4d
movq %rcx, %r15
movq 0x8(%rsp), %rdi
callq 0x3b25f
xorl %ebx, %ebx
testl %eax, %eax
je 0x3de4d
cmpq $0x0, 0x8(%r14)
jne 0x3de4d
cmpq $0x0, (%r14)
jne 0x3de4d
movq 0x50(%r14), %rax
subq 0x48(%r14), %rax
movq 0x68(%r14), %rcx
subq 0x70(%r14), %rcx
cmpq %rcx, %rax
jne 0x3de4d
movq 0x20(%r14), %rax
subq 0x18(%r14), %rax
movq 0x38(%r14), %rcx
subq 0x40(%r14), %rcx
cmpq %rcx, %rax
jne 0x3de4d
movq %r12, %rdi
callq *0x10(%r12)
testl %eax, %eax
je 0x3de4d
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x3de4d
movq 0x18(%rsp), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq 0x20(%rdx), %rcx
subq 0x28(%rdx), %rcx
cmpq %rcx, %rax
jne 0x3de4d
cmpq 0x10(%rsp), %r15
jne 0x3de4d
pushq $0x1
popq %rbx
jmp 0x3de4d
leaq 0x19162(%rip), %rdi     # 0x570aa
leaq 0x184df(%rip), %rsi     # 0x5642e
leaq 0x1917b(%rip), %rcx     # 0x570d1
movl $0x3de, %edx            # imm = 0x3DE
callq 0x4230