// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %rcx, 0x20(%rsp)
movq %rsi, %rbx
movq 0x8(%rdi), %rax
movq 0x8(%rax), %r15
movq %rdi, 0x18(%rsp)
subq (%rdi), %r15
movq 0x8(%rsi), %rax
movq %rax, 0x50(%rsp)
movq %rdx, %rdi
movq %rdx, 0x30(%rsp)
callq *(%rdx)
cmpq $0xb, 0x90(%rsp)
jb 0x47e59
movq %rax, %r14
movq $0x0, 0x10(%rsp)
subq $0x1, %r14
jb 0x47d43
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq *0x8(%rdi)
movl $0x0, 0x4(%rsp)
testl %eax, %eax
je 0x47c6c
movq 0x40(%rsp), %r12
cmpq 0x10(%rsp), %r12
jb 0x47c6c
movq 0x48(%rsp), %rax
movq %r15, %rcx
subq %r12, %rcx
cmpq %rcx, %rax
ja 0x47c6c
movq 0x50(%rsp), %rcx
subq 0x38(%rsp), %rcx
setb %dl
cmpq %rcx, %rax
seta %al
orb %dl, %al
je 0x47c77
xorl %eax, %eax
testb %al, %al
jne 0x47c16
jmp 0x47e46
subq 0x10(%rsp), %r12
jbe 0x47ca5
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r12, %rdx
callq 0x44b94
testl %eax, %eax
je 0x47c6c
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x47e78
testl %eax, %eax
je 0x47c6c
movq %r15, 0x28(%rsp)
movq 0x38(%rsp), %r12
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x47d28
movq %rax, %r15
movq 0x90(%rsp), %rbp
cmpq %rbp, %rax
cmovbq %rax, %rbp
movq %r13, %rcx
addq %rbp, %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *0x10(%rbx)
testl %eax, %eax
je 0x47d16
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x47eb5
testl %eax, %eax
je 0x47d16
movq 0x18(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x449d4
testl %eax, %eax
je 0x47d16
addq %rbp, %r12
movq %r15, %rax
subq %rbp, %rax
movb $0x1, %cl
jmp 0x47d1b
xorl %ecx, %ecx
movq %r15, %rax
testb %cl, %cl
jne 0x47cb4
testq %r15, %r15
je 0x47d28
xorl %eax, %eax
jmp 0x47d39
movq 0x48(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movb $0x1, %al
movq 0x28(%rsp), %r15
jmp 0x47c6e
movq %r15, %rbx
subq 0x10(%rsp), %rbx
jbe 0x47d97
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x44b94
movl $0x0, 0x4(%rsp)
testl %eax, %eax
je 0x47d8d
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x47e78
testl %eax, %eax
setne %al
movq 0x10(%rsp), %rcx
cmovneq %r15, %rcx
movq %rcx, 0x10(%rsp)
jmp 0x47d8f
xorl %eax, %eax
testb %al, %al
je 0x47e46
movq 0x18(%rsp), %rdi
callq 0x44991
testl %eax, %eax
je 0x47e3e
movq 0x8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x47e3e
movq 0x8(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x47e3e
movq 0x8(%rsp), %rdx
movq 0x50(%rdx), %rax
subq 0x48(%rdx), %rax
movq 0x68(%rdx), %rcx
subq 0x70(%rdx), %rcx
cmpq %rcx, %rax
jne 0x47e3e
movq 0x8(%rsp), %rdx
movq 0x20(%rdx), %rax
subq 0x18(%rdx), %rax
movq 0x38(%rdx), %rcx
subq 0x40(%rdx), %rcx
cmpq %rcx, %rax
jne 0x47e3e
movq 0x30(%rsp), %rdi
callq *0x10(%rdi)
testl %eax, %eax
je 0x47e3e
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x47e3e
movq 0x20(%rsp), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq 0x20(%rdx), %rcx
subq 0x28(%rdx), %rcx
cmpq %rcx, %rax
jne 0x47e3e
movl $0x1, 0x4(%rsp)
cmpq %r15, 0x10(%rsp)
je 0x47e46
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a13c(%rip), %rdi     # 0x61f9c
leaq 0x194a7(%rip), %rsi     # 0x6130e
leaq 0x1a155(%rip), %rcx     # 0x61fc3
movl $0x3de, %edx            # imm = 0x3DE
callq 0x4200