// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: resave_single_compressed_diff(hpatch_TStreamInput const*, hpatch_TDecompress*, hpatch_TStreamOutput const*, hdiff_TCompress const*, hpatch_singleCompressedDiffInfo const*, unsigned long long, unsigned long long)
hpatch_StreamPos_t
     resave_single_compressed_diff(const hpatch_TStreamInput*  in_diff,
                                   hpatch_TDecompress*         decompressPlugin,
                                   const hpatch_TStreamOutput* out_diff,
                                   const hdiff_TCompress*      compressPlugin,
                                   const hpatch_singleCompressedDiffInfo* diffInfo,
                                   hpatch_StreamPos_t          in_diff_curPos,
                                   hpatch_StreamPos_t          out_diff_curPos){
    hpatch_singleCompressedDiffInfo _diffInfo;
    if (diffInfo==0){
        checki(getSingleCompressedDiffInfo(&_diffInfo,in_diff,in_diff_curPos),
               "getSingleCompressedDiffInfo() return fail!");
        diffInfo=&_diffInfo;
    }
    const bool isCompressed=(diffInfo->compressedSize>0);
    if (isCompressed){ //check
        checki(diffInfo->compressedSize+(in_diff_curPos+diffInfo->diffDataPos)==in_diff->streamSize,
               "resave_single_compressed_diff() diffInfo error!");
        checki((decompressPlugin!=0)&&(decompressPlugin->is_can_open(diffInfo->compressType)),
               "resave_single_compressed_diff() decompressPlugin error!");
    }

    TDiffStream outDiff(out_diff,out_diff_curPos);
    {//type & head
        std::vector<TByte> outBuf;
        _outType(outBuf, compressPlugin,kHDiffSFVersionType);
        packUInt(outBuf, diffInfo->newDataSize);
        packUInt(outBuf, diffInfo->oldDataSize);
        packUInt(outBuf, diffInfo->coverCount);
        packUInt(outBuf, diffInfo->stepMemSize);
        packUInt(outBuf, diffInfo->uncompressedSize);
        outDiff.pushBack(outBuf.data(),outBuf.size());
        //no compressedSize
    }
    {//save single stream data
        TStreamClip clip(in_diff,diffInfo->diffDataPos+in_diff_curPos,in_diff->streamSize,
                         isCompressed?decompressPlugin:0,diffInfo->uncompressedSize);
        TPlaceholder compressedSize_pos=outDiff.packUInt_pos(compressPlugin?diffInfo->uncompressedSize:0);
        outDiff.pushStream(&clip,compressPlugin,compressedSize_pos);
    }
    return outDiff.getWritedPos();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %r9, %r15
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r13
testq %r8, %r8
je 0x10db3
movq %r8, %r14
leaq 0x38(%r8), %rdi
jmp 0x10dd9
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x472a1
testl %eax, %eax
je 0x1114d
leaq 0xd0(%rsp), %rdi
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x10e09
leaq (%rbx,%r15), %rax
addq 0x20(%r14), %rax
cmpq 0x8(%r13), %rax
jne 0x1112f
testq %r12, %r12
je 0x11045
callq *(%r12)
testl %eax, %eax
je 0x11045
movq 0x210(%rsp), %rdx
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x256c4
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x4b59e(%rip), %rdx     # 0x5c3d6
movq 0x18(%rsp), %rsi
callq 0x10c65
movq (%r14), %rdx
leaq 0x8(%rsp), %rax
movq %rsp, %rdi
movq %rax, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x437d8
testl %eax, %eax
je 0x11066
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9e84
movq 0x8(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x437d8
testl %eax, %eax
je 0x11084
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9e84
movq 0x28(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x437d8
testl %eax, %eax
je 0x110a2
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9e84
movq 0x30(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x437d8
testl %eax, %eax
je 0x110c0
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9e84
movq 0x10(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x437d8
testl %eax, %eax
je 0x110de
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rdx
callq 0x9e84
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
subq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x257a8
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10f98
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq 0x20(%r14), %r15
testq %rbx, %rbx
cmoveq %rbx, %r12
movq 0x8(%r13), %rcx
movq 0x10(%r14), %r9
leaq 0x20(%rsp), %rdi
movq $0x0, 0x40(%rdi)
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %r8
callq 0x25364
cmpq $0x0, 0x18(%rsp)
je 0x10fd4
movq 0x10(%r14), %rsi
jmp 0x10fd6
xorl %esi, %esi
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rbx
callq 0x2581e
movq 0x78(%rsp), %rax
cmpq %rax, %rbx
ja 0x11110
leaq 0x8(%rsp), %rcx
movq %rbx, (%rcx)
movq %rax, 0x8(%rcx)
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25c50
leaq 0x20(%rsp), %rdi
callq 0x25ff0
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rbx
callq 0x25782
movq %rbx, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4ab7d(%rip), %rsi     # 0x5bbd6
movq %rax, %rdi
callq 0x4110
jmp 0x11169
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x49386(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x110fa
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x49368(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x110fa
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4934a(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x110fa
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4932c(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x110fa
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4930e(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
movq 0x6aee7(%rip), %rsi     # 0x7bfe8
movq 0x6aeb0(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
leaq 0x4b226(%rip), %rdi     # 0x5c33d
leaq 0x4b22e(%rip), %rsi     # 0x5c34c
leaq 0x4b25f(%rip), %rcx     # 0x5c384
movl $0x6f, %edx
callq 0x4200
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4aa63(%rip), %rsi     # 0x5bba6
movq %rax, %rdi
callq 0x4110
jmp 0x11169
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4aa1a(%rip), %rsi     # 0x5bb7b
movq %rax, %rdi
callq 0x4110
movq 0x6ae78(%rip), %rsi     # 0x7bfe8
movq 0x6ae41(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
jmp 0x11198
jmp 0x11198
jmp 0x1118b
jmp 0x1118b
jmp 0x1118b
jmp 0x1118b
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x111c4
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x111e5
movq %rax, %rdi
callq 0x9db0
movq %rax, %rbx
jmp 0x111db
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x15840
jmp 0x111db
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x111db
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0x70(%rsp), %rdi
callq 0x25782
movq %rbx, %rdi
callq 0x45e0