// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: check_lite_diff(unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, hpatch_TDecompress*)
bool check_lite_diff(const hpi_byte* newData,const hpi_byte* newData_end,
                     const hpi_byte* oldData,const hpi_byte* oldData_end,
                     const hpi_byte* lite_diff,const hpi_byte* lite_diff_end,
                     hpatch_TDecompress* decompressPlugin){
    TPatchiListener listener;
    listener.diffData_cur=lite_diff;
    listener.diffData_end=lite_diff_end;
    hpi_compressType _compress_type;
    hpi_pos_t saved_newSize;
    hpi_pos_t saved_uncompressSize;
    if (!_try_open_hpatchi_and_inplace(listener,&_compress_type,
                                       &saved_newSize,&saved_uncompressSize)) return false;
    if (saved_newSize!=(size_t)(newData_end-newData)) return false;
    listener.diff_data=&listener;
    listener.decompressPlugin=(_compress_type!=hpi_compressType_no)?decompressPlugin:0;
    if (listener.decompressPlugin){
        listener.uncompressSize=saved_uncompressSize;
        mem_as_hStreamInput(&listener.diffStream,listener.diffData_cur,lite_diff_end);
        listener.decompresser=decompressPlugin->open(decompressPlugin,saved_uncompressSize,&listener.diffStream,
                                                     0,(size_t)(lite_diff_end-listener.diffData_cur));
        if (listener.decompresser==0) return false;
        listener.read_diff=listener._read_diff_dec;
    }else{
        listener.read_diff=listener._read_diff;
    }
    listener.newData_cur=newData;
    listener.newData_end=newData_end;
    listener.write_new=listener._write_new;
    listener.oldData=oldData;
    listener.oldData_end=oldData_end;
    listener.read_old=listener._read_old;

    const size_t kACacheBufSize=1024*32;
    hdiff_private::TAutoMem _cache(kACacheBufSize+listener.extraSafeSize);
    
    if (listener.isInplacePatch){
        if (!hpatchi_inplaceB(&listener,saved_newSize,_cache.data(),listener.extraSafeSize,(hpi_size_t)_cache.size()))
            return false;
    }else if (!hpatch_lite_patch(&listener,saved_newSize,_cache.data(),(hpi_size_t)_cache.size())){
        return false;
    }
    return listener.newData_cur==listener.newData_end;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, %r13
movq %rcx, %rbx
leaq 0x30(%rsp), %rbp
andq $0x0, 0x20(%rbp)
movq %rdx, %r14
andq $0x0, 0x90(%rbp)
movq %rsi, %r15
movq %rdi, %r12
movq %r8, 0x30(%rbp)
movq %r9, 0x38(%rbp)
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %rbp, %rdi
callq 0xe9d2
testb %al, %al
je 0xeb42
movl 0x10(%rsp), %eax
movq %r15, %rcx
subq %r12, %rcx
cmpq %rax, %rcx
jne 0xeb42
movq %rbp, 0x30(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x14(%rsp)
cmovneq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
testq %rax, %rax
je 0xeb62
movl 0xc(%rsp), %eax
leaq 0x70(%rsp), %rbp
movl %eax, 0x20(%rbp)
movq -0x10(%rbp), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x3a60a
movl 0xc(%rsp), %esi
subq 0x60(%rsp), %r13
movq 0x100(%rsp), %rdi
movq %rbp, %rdx
xorl %ecx, %ecx
movq %r13, %r8
callq *0x8(%rdi)
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0xeb42
leaq 0x10c(%rip), %rax       # 0xec4c
jmp 0xeb69
xorl %ebx, %ebx
leaq 0x30(%rsp), %rdi
callq 0xea5a
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11b(%rip), %rax       # 0xec84
movq %rax, 0x38(%rsp)
movq %r12, 0x98(%rsp)
movq %r15, 0xa0(%rsp)
leaq 0x13d(%rip), %rax       # 0xecc2
movq %rax, 0x48(%rsp)
movq %r14, 0xa8(%rsp)
movq %rbx, 0xb0(%rsp)
leaq 0x16d(%rip), %rax       # 0xed0e
movq %rax, 0x40(%rsp)
movl 0xbc(%rsp), %esi
addq $0x8000, %rsi           # imm = 0x8000
leaq 0x18(%rsp), %rdi
callq 0x11e94
movl 0x10(%rsp), %esi
movq 0x18(%rsp), %rdx
cmpb $0x1, 0xb8(%rsp)
jne 0xebeb
leaq 0x30(%rsp), %rdi
movl 0x8c(%rdi), %ecx
movl 0x20(%rsp), %r8d
subl %edx, %r8d
callq 0xb682
jmp 0xebfb
movl 0x20(%rsp), %ecx
subl %edx, %ecx
leaq 0x30(%rsp), %rdi
callq 0xb2b1
testl %eax, %eax
je 0xec14
movq 0x98(%rsp), %rax
cmpq 0xa0(%rsp), %rax
sete %bl
jmp 0xec16
xorl %ebx, %ebx
leaq 0x18(%rsp), %rdi
callq 0x13a5c
jmp 0xeb44
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x13a5c
jmp 0xec39
jmp 0xec36
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xea5a
movq %rbx, %rdi
callq 0x4600
nop