// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, 0x10(%rsp)
testq %rdx, %rdx
je 0xcd3a
xorl %eax, %eax
cmpl $0x2, %ecx
jb 0xcd16
movl %esi, %r12d
shrl %ecx
leaq 0x18(%rsp), %rbx
movl %ecx, (%rbx)
movl %ecx, 0x4(%rbx)
movq %rdx, 0x38(%rsp)
addq %rdx, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x10(%rbx)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0xc936
movl %ebp, %ecx
shll $0x7, %ecx
movl %eax, %ebp
andl $0x7f, %ebp
orl %ecx, %ebp
cmpl $0x7f, %eax
ja 0xcacd
xorl %ebx, %ebx
leaq 0x18(%rsp), %r13
xorl %edx, %edx
movl %r12d, 0x40(%rsp)
subl $0x1, %ebp
jb 0xcd25
movl %edx, 0x4(%rsp)
xorl %r15d, %r15d
movq %r13, %rdi
callq 0xc936
movl %r15d, %ecx
shll $0x7, %ecx
movl %eax, %r15d
andl $0x7f, %r15d
orl %ecx, %r15d
cmpl $0x7f, %eax
ja 0xcb04
movq %r13, %rdi
callq 0xc936
movl %eax, %r14d
andl $0x1f, %r14d
movl %eax, 0xc(%rsp)
testb $0x20, %al
je 0xcb51
movq %r13, %rdi
callq 0xc936
shll $0x7, %r14d
movl %eax, %ecx
andl $0x7f, %ecx
orl %ecx, %r14d
cmpl $0x7f, %eax
ja 0xcb38
movl %r14d, %eax
negl %eax
testb $0x40, 0xc(%rsp)
cmovel %r14d, %eax
movl %eax, %r14d
xorl %r12d, %r12d
movq %r13, %rdi
callq 0xc936
movl %r12d, %ecx
shll $0x7, %ecx
movl %eax, %r12d
andl $0x7f, %r12d
orl %ecx, %r12d
cmpl $0x7f, %eax
ja 0xcb65
xorl %eax, %eax
movl %r12d, %ecx
addl %ebx, %ecx
jb 0xcd16
movl %r14d, 0x8(%rsp)
movl %ecx, 0x44(%rsp)
cmpl %ecx, %ebx
jae 0xcbfd
movl 0x18(%rsp), %r13d
movl 0x1c(%rsp), %r14d
movl %r14d, %ebx
subl %r13d, %ebx
jne 0xcbcf
leaq 0x18(%rsp), %rdi
callq 0xc8d4
testl %eax, %eax
je 0xcd14
movl 0x18(%rsp), %r13d
movl 0x1c(%rsp), %ebx
movl %ebx, %r14d
subl %r13d, %ebx
cmpl %r12d, %ebx
cmovael %r12d, %ebx
movl %r13d, %esi
addq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdi
movl %ebx, %edx
callq *0x18(%rdi)
testl %eax, %eax
je 0xcd14
addl %ebx, %r13d
movl %r13d, 0x18(%rsp)
subl %ebx, %r12d
jne 0xcba6
movl 0x8(%rsp), %eax
addl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
testl %r15d, %r15d
je 0xcce0
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rsp)
movl %r15d, %r12d
movl 0x8(%rsp), %ebx
cmpl $0x7f, 0xc(%rsp)
movq 0x38(%rsp), %rdx
leaq 0x18(%rsp), %rdi
ja 0xcc59
movl 0x4(%rsp), %r14d
subl 0x18(%rsp), %r14d
jne 0xcc67
callq 0xc8d4
movq 0x38(%rsp), %rdx
movl 0x1c(%rsp), %r14d
movl %r14d, 0x4(%rsp)
subl 0x18(%rsp), %r14d
jmp 0xcc5e
movl 0x4(%rsp), %r14d
testl %r14d, %r14d
je 0xcd14
cmpl %r12d, %r14d
movl %r12d, %r13d
cmovbl %r14d, %r13d
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movl %r13d, %ecx
callq *0x10(%rdi)
testl %eax, %eax
je 0xcd14
cmpl $0x7f, 0xc(%rsp)
movq 0x38(%rsp), %rsi
ja 0xccc5
movl 0x18(%rsp), %eax
movq %rax, %rcx
addq 0x20(%rsp), %rcx
movl %r14d, %edi
movl %r12d, %edx
cmpq %rdx, %rdi
cmovbq %rdi, %rdx
xorl %r8d, %r8d
movb (%rcx,%r8), %dil
addb %dil, (%rsi,%r8)
incq %r8
cmpl %r8d, %edx
jne 0xccae
addl %r13d, %eax
movl %eax, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movl %r13d, %edx
callq *0x18(%rdi)
testl %eax, %eax
je 0xcd14
addl %r13d, %ebx
subl %r13d, %r12d
jne 0xcc21
movl 0x44(%rsp), %esi
addl %r15d, %esi
movl 0x8(%rsp), %edx
addl %r15d, %edx
testl %r15d, %r15d
setne %al
testl %ebp, %ebp
sete %cl
orb %al, %cl
movl %esi, %ebx
movl 0x40(%rsp), %r12d
leaq 0x18(%rsp), %r13
movl $0x0, %eax
jne 0xcaf4
jmp 0xcd16
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %r12d, %ebx
sete %al
cmpl $0x0, 0x1c(%rsp)
setne %cl
andb %al, %cl
movzbl %cl, %eax
jmp 0xcd16
leaq 0x4e8d9(%rip), %rdi     # 0x5b61a
leaq 0x4e7e2(%rip), %rsi     # 0x5b52a
leaq 0x4e843(%rip), %rcx     # 0x5b592
movl $0x92, %edx
callq 0x4200