// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %esi, 0x50(%rsp)
movq %rdi, 0x28(%rsp)
testq %rdx, %rdx
je 0xcfc5
movl $0x0, 0xc(%rsp)
cmpl $0x2, %ecx
jb 0xcfb2
movq %rdx, %r14
shrl %ecx
leaq 0x30(%rsp), %rbx
movl %ecx, (%rbx)
movl %ecx, 0x4(%rbx)
addq %rdx, %rcx
movq %rcx, 0x8(%rbx)
movq 0x28(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rbx)
movq 0x8(%rcx), %rax
movq %rax, 0x18(%rbx)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0xcba4
movl %ebp, %ecx
shll $0x7, %ecx
movl %eax, %ebp
andl $0x7f, %ebp
orl %ecx, %ebp
cmpl $0x7f, %eax
ja 0xcd4a
movq $0x0, 0x20(%rsp)
leaq 0x30(%rsp), %r12
movl $0x0, 0x18(%rsp)
subl $0x1, %ebp
jb 0xcf95
movl %ebp, 0x8(%rsp)
xorl %r15d, %r15d
movq %r12, %rdi
callq 0xcba4
movl %r15d, %ecx
shll $0x7, %ecx
movl %eax, %r15d
andl $0x7f, %r15d
orl %ecx, %r15d
cmpl $0x7f, %eax
ja 0xcd89
movq %r12, %rdi
callq 0xcba4
movl %eax, %ebx
andl $0x1f, %ebx
movl %eax, 0x14(%rsp)
testb $0x20, %al
jne 0xcdc2
movq 0x20(%rsp), %rbp
jmp 0xcdde
movq 0x20(%rsp), %rbp
movq %r12, %rdi
callq 0xcba4
shll $0x7, %ebx
movl %eax, %ecx
andl $0x7f, %ecx
orl %ecx, %ebx
cmpl $0x7f, %eax
ja 0xcdc7
movl %ebx, %eax
negl %eax
testb $0x40, 0x14(%rsp)
cmovel %ebx, %eax
movl %eax, 0x10(%rsp)
xorl %r13d, %r13d
movq %r12, %rdi
callq 0xcba4
movl %r13d, %ecx
shll $0x7, %ecx
movl %eax, %r13d
andl $0x7f, %r13d
orl %ecx, %r13d
cmpl $0x7f, %eax
ja 0xcdf1
movl $0x0, 0xc(%rsp)
movl %r13d, %eax
addl %ebp, %eax
jb 0xcf59
cmpl %eax, %ebp
movl %eax, 0x54(%rsp)
jae 0xce92
testl %r13d, %r13d
je 0xce92
movl %r13d, %ebp
movl 0x34(%rsp), %ebx
subl 0x30(%rsp), %ebx
jne 0xce4f
movq %r12, %rdi
callq 0xcb3c
testl %eax, %eax
je 0xce81
movl 0x34(%rsp), %ebx
subl 0x30(%rsp), %ebx
cmpl %ebp, %ebx
cmovael %ebp, %ebx
movl 0x30(%rsp), %r13d
movq 0x38(%rsp), %rsi
addq %r13, %rsi
movq 0x28(%rsp), %rdi
movl %ebx, %edx
callq *0x18(%rdi)
testl %eax, %eax
je 0xce81
addl %ebx, %r13d
movl %r13d, 0x30(%rsp)
movl %ebp, %r13d
subl %ebx, %r13d
movb $0x1, %al
jmp 0xce86
xorl %eax, %eax
movl %ebp, %r13d
testb %al, %al
jne 0xce29
testl %ebp, %ebp
jne 0xcf59
movl 0x10(%rsp), %eax
addl 0x18(%rsp), %eax
movl %eax, 0x10(%rsp)
movl %eax, 0x1c(%rsp)
movl %r15d, %ecx
testl %ecx, %ecx
je 0xcf61
movl %ecx, %ebx
movl 0x34(%rsp), %ebp
cmpl $0x7f, 0x14(%rsp)
ja 0xced0
subl 0x30(%rsp), %ebp
jne 0xced0
movq %r12, %rdi
callq 0xcb3c
movl 0x34(%rsp), %ebp
subl 0x30(%rsp), %ebp
testl %ebp, %ebp
je 0xcf49
cmpl %ebx, %ebp
movl %ebx, %r13d
cmovbl %ebp, %r13d
movq 0x28(%rsp), %rdi
movl 0x1c(%rsp), %esi
movq %r14, %rdx
movl %r13d, %ecx
callq *0x10(%rdi)
testl %eax, %eax
je 0xcf49
cmpl $0x7f, 0x14(%rsp)
ja 0xcf29
movl 0x30(%rsp), %eax
movq %rax, %rcx
addq 0x38(%rsp), %rcx
movl %ebp, %esi
movl %ebx, %edx
cmpq %rdx, %rsi
cmovbq %rsi, %rdx
xorl %esi, %esi
movb (%rcx,%rsi), %dil
addb %dil, (%r14,%rsi)
incq %rsi
cmpl %esi, %edx
jne 0xcf13
addl %r13d, %eax
movl %eax, 0x30(%rsp)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movl %r13d, %edx
callq *0x18(%rdi)
testl %eax, %eax
je 0xcf49
addl %r13d, 0x1c(%rsp)
movl %ebx, %ecx
subl %r13d, %ecx
movb $0x1, %al
jmp 0xcf4d
xorl %eax, %eax
movl %ebx, %ecx
testb %al, %al
jne 0xcea5
testl %ebx, %ebx
je 0xcf61
xorl %eax, %eax
movl 0x8(%rsp), %ebp
jmp 0xcf8b
movl 0x54(%rsp), %esi
addl %r15d, %esi
movl 0x10(%rsp), %edx
addl %r15d, %edx
testl %r15d, %r15d
setne %cl
movl 0x8(%rsp), %ebp
testl %ebp, %ebp
sete %al
orb %cl, %al
movl %esi, %ecx
movq %rcx, 0x20(%rsp)
movl %edx, 0x18(%rsp)
testb %al, %al
jne 0xcd79
jmp 0xcfb2
movq 0x20(%rsp), %rax
cmpl 0x50(%rsp), %eax
sete %al
cmpl $0x0, 0x34(%rsp)
setne %cl
andb %al, %cl
movzbl %cl, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e64e(%rip), %rdi     # 0x5b61a
leaq 0x4e557(%rip), %rsi     # 0x5b52a
leaq 0x4e5b8(%rip), %rcx     # 0x5b592
movl $0x92, %edx
callq 0x4200