// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatchLite/hpatch_lite.c
// Function: hpatch_lite_patch
hpi_BOOL hpatch_lite_patch(hpatchi_listener_t* listener,hpi_pos_t newSize,
                           hpi_byte* temp_cache,hpi_size_t temp_cache_size){
    _TInputCache  diff;
    hpi_pos_t  coverCount;
    hpi_pos_t  newPosBack=0;
    hpi_pos_t  oldPosBack=0;
    {
        assert(temp_cache);
        _SAFE_CHECK(temp_cache_size>=hpi_kMinCacheSize);
        temp_cache_size>>=1;
        diff.cache_begin=temp_cache_size;
        diff.cache_end=temp_cache_size;
        diff.cache_buf=temp_cache+temp_cache_size;
        diff.inputStream=listener->diff_data;
        diff.read_code=listener->read_diff;
    }
    coverCount=_cache_unpackUInt(&diff,0,hpi_TRUE);

    while (coverCount--){
        hpi_pos_t cover_oldPos;
        hpi_pos_t cover_newPos;
        hpi_pos_t cover_length;
        hpi_BOOL  isNotNeedSubDiff;
        {//read cover
            cover_length=_cache_unpackUInt(&diff,0,hpi_TRUE);
            {
                hpi_fast_uint8 tag=_cache_read_1byte(&diff);
                cover_oldPos=_cache_unpackUInt(&diff,tag&31,tag&(1<<5));
                isNotNeedSubDiff=(tag>>7);
                if (tag&(1<<6))
                    cover_oldPos=oldPosBack-cover_oldPos;
                else
                    cover_oldPos+=oldPosBack;
            }
            cover_newPos=_cache_unpackUInt(&diff,0,hpi_TRUE);
            cover_newPos+=newPosBack;
        }

        _SAFE_CHECK(cover_newPos>=newPosBack);
        if (newPosBack<cover_newPos)
            _CHECK(_patch_copy_diff(listener,&diff,cover_newPos-newPosBack));
        _CHECK(_patch_add_old_withClip(listener,&diff,isNotNeedSubDiff,cover_oldPos,cover_length,temp_cache));
        newPosBack=cover_newPos+cover_length;
        oldPosBack=cover_oldPos+cover_length;
        _SAFE_CHECK((cover_length>0)|(coverCount==0));
    }
    return (newSize==newPosBack)&_cache_success_finish(&diff);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdx, %rdx
je 0xb4f5
xorl %eax, %eax
cmpl $0x2, %ecx
jb 0xb4d2
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
shrl %ecx
leaq 0x18(%rsp), %rdi
movl %ecx, (%rdi)
movl %ecx, 0x4(%rdi)
addq %rdx, %rcx
movq %rcx, 0x8(%rdi)
movups (%r15), %xmm0
movups %xmm0, 0x10(%rdi)
xorl %ebx, %ebx
pushq $0x1
popq %rdx
xorl %esi, %esi
callq 0xb514
movl %eax, %edx
xorl %esi, %esi
movl %ebp, 0x3c(%rsp)
subl $0x1, %edx
jb 0xb4e1
movl %esi, 0x44(%rsp)
movl %edx, 0x40(%rsp)
leaq 0x18(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
pushq $0x1
popq %rbp
movl %ebp, %edx
callq 0xb514
movl %eax, 0x10(%rsp)
movq %r12, %rdi
callq 0xb171
movl %eax, %r13d
movl %eax, %esi
andl $0x1f, %esi
movl %eax, %edx
andl $0x20, %edx
movq %r12, %rdi
callq 0xb514
movl %eax, %ecx
negl %ecx
movl %r13d, 0x14(%rsp)
testb $0x40, %r13b
cmovel %eax, %ecx
movl %ecx, 0xc(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0xb514
movl %eax, %r13d
addl %ebx, %r13d
jb 0xb4d0
cmpl %r13d, %ebx
jae 0xb3db
movl %eax, %r12d
testl %r12d, %r12d
je 0xb3db
movl 0x18(%rsp), %ebx
movl 0x1c(%rsp), %ebp
subl %ebx, %ebp
jne 0xb3b1
leaq 0x18(%rsp), %rdi
callq 0xb114
testl %eax, %eax
je 0xb4d0
movl 0x18(%rsp), %ebx
movl 0x1c(%rsp), %ebp
subl %ebx, %ebp
cmpl %r12d, %ebp
cmovael %r12d, %ebp
movl %ebx, %esi
addq 0x20(%rsp), %rsi
movq %r15, %rdi
movl %ebp, %edx
callq *0x18(%r15)
testl %eax, %eax
je 0xb4d0
addl %ebp, %ebx
movl %ebx, 0x18(%rsp)
subl %ebp, %r12d
jmp 0xb384
movl %r13d, 0x38(%rsp)
movl 0xc(%rsp), %r12d
addl 0x44(%rsp), %r12d
movl %r12d, 0xc(%rsp)
movl 0x10(%rsp), %ebx
testl %ebx, %ebx
je 0xb49d
movl 0x1c(%rsp), %r13d
cmpl $0x7f, 0x14(%rsp)
ja 0xb422
subl 0x18(%rsp), %r13d
jne 0xb42b
leaq 0x18(%rsp), %rdi
callq 0xb114
movl 0x1c(%rsp), %r13d
subl 0x18(%rsp), %r13d
testl %r13d, %r13d
je 0xb4d0
cmpl %ebx, %r13d
movl %ebx, %ebp
cmovbl %r13d, %ebp
movq %r15, %rdi
movl %r12d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq *0x10(%r15)
testl %eax, %eax
je 0xb4d0
cmpl $0x7f, 0x14(%rsp)
ja 0xb483
movl 0x18(%rsp), %eax
movq %rax, %rcx
addq 0x20(%rsp), %rcx
movl %ebx, %esi
movl %r13d, %edx
cmpq %rdx, %rsi
cmovbq %rsi, %rdx
xorl %esi, %esi
cmpl %esi, %edx
je 0xb47d
movb (%rcx,%rsi), %dil
addb %dil, (%r14,%rsi)
incq %rsi
jmp 0xb46c
addl %ebp, %eax
movl %eax, 0x18(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq *0x18(%r15)
testl %eax, %eax
je 0xb4d0
addl %ebp, %r12d
subl %ebp, %ebx
jmp 0xb3f3
movl 0x10(%rsp), %eax
movl 0x38(%rsp), %edi
addl %eax, %edi
movl 0xc(%rsp), %esi
addl %eax, %esi
testl %eax, %eax
setne %al
movl 0x40(%rsp), %edx
testl %edx, %edx
sete %cl
orb %al, %cl
movl %edi, %ebx
movl 0x3c(%rsp), %ebp
movl $0x0, %eax
jne 0xb30a
jmp 0xb4d2
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %ebp, %ebx
sete %al
cmpl $0x0, 0x1c(%rsp)
setne %cl
andb %al, %cl
movzbl %cl, %eax
jmp 0xb4d2
leaq 0x4511e(%rip), %rdi     # 0x5061a
leaq 0x45027(%rip), %rsi     # 0x5052a
leaq 0x45088(%rip), %rcx     # 0x50592
movl $0x92, %edx
callq 0x4230