// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %r9, %r13
movq %r8, %r12
movq %rcx, 0x10(%rsp)
movq %rdx, %r14
movq %rsi, %rbp
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rax
movq %rdi, (%rsp)
subq (%rdi), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x40(%rsp)
movq %rdx, %rdi
callq *(%rdx)
cmpq $0xb, 0x80(%rsp)
jb 0x471eb
xorl %ebx, %ebx
testq %rax, %rax
je 0x470f5
leaq 0x18(%rsp), %rsi
movq %r14, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq %r14, %rdi
callq *0x8(%r14)
testl %eax, %eax
je 0x471d8
movq 0x20(%rsp), %r15
cmpq %rbx, %r15
jb 0x471d8
movq 0x28(%rsp), %r14
movq 0x8(%rsp), %rax
subq %r15, %rax
cmpq %rax, %r14
ja 0x471d8
movq 0x40(%rsp), %rax
subq 0x18(%rsp), %rax
jb 0x471d8
cmpq %rax, %r14
ja 0x471d8
subq %rbx, %r15
jbe 0x47065
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x443dc
testl %eax, %eax
je 0x471d8
testq %r15, %r15
je 0x47060
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x4720a
movl $0x0, %r15d
jmp 0x4703e
movq 0x28(%rsp), %r14
testq %r14, %r14
je 0x470d3
movq 0x18(%rsp), %r15
movq 0x80(%rsp), %rbx
cmpq %rbx, %r14
cmovbq %r14, %rbx
leaq (%r13,%rbx), %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *0x10(%rbp)
testl %eax, %eax
je 0x471d8
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4720a
testl %eax, %eax
je 0x471d8
movq (%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4423c
testl %eax, %eax
je 0x471d8
addq %rbx, %r15
subq %rbx, %r14
jne 0x4706f
movq 0x28(%rsp), %rbx
jmp 0x470d5
xorl %ebx, %ebx
movq 0x38(%rsp), %rax
decq %rax
addq 0x20(%rsp), %rbx
testq %rax, %rax
movq 0x30(%rsp), %r14
leaq 0x18(%rsp), %rsi
jne 0x46fd7
movq 0x8(%rsp), %r15
subq %rbx, %r15
jbe 0x47140
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x443dc
testl %eax, %eax
je 0x471d8
testq %r15, %r15
je 0x4713b
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x4720a
movl $0x0, %r15d
testl %eax, %eax
jne 0x47118
jmp 0x471da
movq 0x8(%rsp), %rbx
movq %rbx, %r15
movq (%rsp), %rdi
callq 0x441f9
xorl %ebx, %ebx
testl %eax, %eax
je 0x471da
cmpq $0x0, 0x8(%r12)
jne 0x471d8
cmpq $0x0, (%r12)
jne 0x471d8
movq 0x50(%r12), %rax
subq 0x48(%r12), %rax
movq 0x68(%r12), %rcx
subq 0x70(%r12), %rcx
cmpq %rcx, %rax
jne 0x471d8
movq 0x20(%r12), %rax
subq 0x18(%r12), %rax
movq 0x38(%r12), %rcx
subq 0x40(%r12), %rcx
cmpq %rcx, %rax
jne 0x471d8
movq %r14, %rdi
callq *0x10(%r14)
testl %eax, %eax
je 0x471d8
movq (%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x471d8
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq 0x20(%rdx), %rcx
subq 0x28(%rdx), %rcx
cmpq %rcx, %rax
jne 0x471d8
movl $0x1, %ebx
cmpq 0x8(%rsp), %r15
je 0x471da
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ae18(%rip), %rdi     # 0x6200a
leaq 0x1a195(%rip), %rsi     # 0x6138e
leaq 0x1ae31(%rip), %rcx     # 0x62031
movl $0x3de, %edx            # imm = 0x3DE
callq 0x4200