// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x1d380
movq -0x120(%rbp), %rdi
movq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xd4(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
leaq -0xdc(%rbp), %rcx
callq 0x1d3b0
movb %al, -0x111(%rbp)
jmp 0x1d529
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x1d55f
jmp 0x1d535
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
jmp 0x1d831
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe8(%rbp)
movl %eax, -0xec(%rbp)
jmp 0x1d84b
movl -0xd8(%rbp), %eax
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
je 0x1d588
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
jmp 0x1d831
leaq -0xd0(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpl $0x0, -0xd4(%rbp)
je 0x1d5ac
movq 0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
jmp 0x1d5b7
xorl %eax, %eax
movq %rax, -0x128(%rbp)
jmp 0x1d5b7
movq -0x128(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x1d662
movl -0xdc(%rbp), %eax
movl %eax, -0x70(%rbp)
leaq -0x90(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x85b30
jmp 0x1d5f5
movq 0x10(%rbp), %rdi
movq 0x8(%rdi), %rax
movl -0xdc(%rbp), %ecx
movl %ecx, %esi
leaq -0x90(%rbp), %rdx
movq -0x38(%rbp), %r8
movq -0xa0(%rbp), %rcx
subq %rcx, %r8
xorl %ecx, %ecx
callq *%rax
movq %rax, -0x130(%rbp)
jmp 0x1d627
movq -0x130(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x1d652
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
jmp 0x1d831
leaq 0x217(%rip), %rax       # 0x1d870
movq %rax, -0xc8(%rbp)
jmp 0x1d670
leaq 0x2a7(%rip), %rax       # 0x1d910
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x319(%rip), %rax       # 0x1d9a0
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x3ab(%rip), %rax       # 0x1da50
movq %rax, -0xc0(%rbp)
movq $0x8000, -0xf8(%rbp) # imm = 0x8000
movl -0x44(%rbp), %eax
movl %eax, %esi
addq $0x8000, %rsi           # imm = 0x8000
leaq -0x110(%rbp), %rdi
callq 0x29c00
jmp 0x1d6d1
testb $0x1, -0x48(%rbp)
je 0x1d78e
movl -0xd8(%rbp), %eax
movl %eax, -0x13c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x29c40
movq %rax, -0x138(%rbp)
jmp 0x1d6fc
movl -0x44(%rbp), %eax
movl %eax, -0x14c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x29f20
movq %rax, -0x148(%rbp)
jmp 0x1d71a
movl -0x14c(%rbp), %ecx
movq -0x138(%rbp), %rdx
movl -0x13c(%rbp), %esi
movq -0x148(%rbp), %rax
movl %eax, %r8d
leaq -0xd0(%rbp), %rdi
callq 0x18720
movl %eax, -0x150(%rbp)
jmp 0x1d74b
movl -0x150(%rbp), %eax
cmpl $0x0, %eax
jne 0x1d78c
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
jmp 0x1d825
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe8(%rbp)
movl %eax, -0xec(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x29ca0
jmp 0x1d84b
jmp 0x1d80b
movl -0xd8(%rbp), %eax
movl %eax, -0x15c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x29c40
movq %rax, -0x158(%rbp)
jmp 0x1d7af
leaq -0x110(%rbp), %rdi
callq 0x29f20
movq %rax, -0x168(%rbp)
jmp 0x1d7c4
movq -0x158(%rbp), %rdx
movl -0x15c(%rbp), %esi
movq -0x168(%rbp), %rax
movl %eax, %ecx
leaq -0xd0(%rbp), %rdi
callq 0x180b0
movl %eax, -0x16c(%rbp)
jmp 0x1d7ee
movl -0x16c(%rbp), %eax
cmpl $0x0, %eax
jne 0x1d809
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
jmp 0x1d825
jmp 0x1d80b
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0xf0(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x29ca0
leaq -0xd0(%rbp), %rdi
callq 0x1d470
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0xd0(%rbp), %rdi
callq 0x1d470
movq -0xe8(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)