// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: patch_single_stream
hpatch_BOOL patch_single_stream(sspatch_listener_t* listener,
                                const hpatch_TStreamOutput* __out_newData,
                                const hpatch_TStreamInput*  oldData,
                                const hpatch_TStreamInput*  singleCompressedDiff, 
                                hpatch_StreamPos_t  diffInfo_pos,
                                sspatch_coversListener_t* coversListener){
    hpatch_BOOL result=hpatch_TRUE;
    hpatch_TDecompress*     decompressPlugin=0;
    unsigned char*          temp_cache=0;
    unsigned char*          temp_cacheEnd=0;
    hpatch_singleCompressedDiffInfo diffInfo;
    hpatch_TStreamOutput    _out_newData=*__out_newData;
    hpatch_TStreamOutput*   out_newData=&_out_newData;
    TDiffToSingleStream     _toSStream;
    assert((listener)&&(listener->onDiffInfo));
    TDiffToSingleStream_init(&_toSStream,singleCompressedDiff);
    singleCompressedDiff=&_toSStream.base;

    if (!getSingleCompressedDiffInfo(&diffInfo,singleCompressedDiff,diffInfo_pos))
        return _hpatch_FALSE;
    if (diffInfo.newDataSize>out_newData->streamSize)
        return _hpatch_FALSE;
    out_newData->streamSize=diffInfo.newDataSize;
    if (diffInfo.oldDataSize!=oldData->streamSize)
        return _hpatch_FALSE;
    if (!listener->onDiffInfo(listener,&diffInfo,&decompressPlugin,&temp_cache,&temp_cacheEnd))
        return _hpatch_FALSE;

    if ((temp_cache==0)||(temp_cache>=temp_cacheEnd))
        result=_hpatch_FALSE;
    if (result){
        result=patch_single_compressed_diff(out_newData,oldData,singleCompressedDiff,diffInfo.diffDataPos,
                                            diffInfo.uncompressedSize,diffInfo.compressedSize,decompressPlugin,
                                            diffInfo.coverCount,(size_t)diffInfo.stepMemSize,
                                            temp_cache,temp_cacheEnd,coversListener);
    }
    if (listener->onPatchFinish)
        listener->onPatchFinish(listener,temp_cache,temp_cacheEnd);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1238, %rsp           # imm = 0x1238
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq %r8, -0x48(%rbp)
movq %r9, -0x50(%rbp)
movl $0x1, -0x54(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x1d0(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x1c8(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x1c0(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x1d0(%rbp), %rax
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x8a7b8
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x8a7b8
jmp 0x8a7d7
leaq 0x2a8cb(%rip), %rdi     # 0xb508a
leaq 0x2a214(%rip), %rsi     # 0xb49da
movl $0x937, %edx            # imm = 0x937
leaq 0x2a8db(%rip), %rcx     # 0xb50ad
callq 0x4270
movq -0x40(%rbp), %rsi
leaq -0x1218(%rbp), %rdi
callq 0x8a450
leaq -0x1218(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x1b0(%rbp), %rdi
callq 0x89e00
cmpl $0x0, %eax
jne 0x8a817
movl $0x0, -0x1c(%rbp)
jmp 0x8a944
movq -0x1b0(%rbp), %rax
movq -0x1d8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x8a837
movl $0x0, -0x1c(%rbp)
jmp 0x8a944
movq -0x1b0(%rbp), %rcx
movq -0x1d8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x1a8(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x8a866
movl $0x0, -0x1c(%rbp)
jmp 0x8a944
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x68(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq *%rax
cmpl $0x0, %eax
jne 0x8a898
movl $0x0, -0x1c(%rbp)
jmp 0x8a944
cmpq $0x0, -0x68(%rbp)
je 0x8a8a9
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jb 0x8a8b0
movl $0x0, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x8a91d
movq -0x1d8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x190(%rbp), %rcx
movq -0x1a0(%rbp), %r8
movq -0x198(%rbp), %r9
movq -0x60(%rbp), %r15
movq -0x188(%rbp), %r14
movq -0x180(%rbp), %rbx
movq -0x68(%rbp), %r11
movq -0x70(%rbp), %r10
movq -0x50(%rbp), %rax
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
callq 0x896c0
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x8a93e
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq *%rax
movl -0x54(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x1238, %rsp           # imm = 0x1238
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)