// File: /workspace/github_cpp_makefile_star2_O3/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 0x10a6c
movq %r8, %r14
leaq 0x38(%r8), %rdi
jmp 0x10a92
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x46721
testl %eax, %eax
je 0x10e06
leaq 0xd0(%rsp), %rdi
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x10ac2
leaq (%rbx,%r15), %rax
addq 0x20(%r14), %rax
cmpq 0x8(%r13), %rax
jne 0x10de8
testq %r12, %r12
je 0x10cfe
callq *(%r12)
testl %eax, %eax
je 0x10cfe
movq 0x210(%rsp), %rdx
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x253fa
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x4b8e5(%rip), %rdx     # 0x5c3d6
movq 0x18(%rsp), %rsi
callq 0x1091e
movq (%r14), %rdx
leaq 0x8(%rsp), %rax
movq %rsp, %rdi
movq %rax, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43254
testl %eax, %eax
je 0x10d1f
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9c50
movq 0x8(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43254
testl %eax, %eax
je 0x10d3d
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9c50
movq 0x28(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43254
testl %eax, %eax
je 0x10d5b
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9c50
movq 0x30(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43254
testl %eax, %eax
je 0x10d79
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x9c50
movq 0x10(%r14), %rdx
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x13(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43254
testl %eax, %eax
je 0x10d97
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq (%rsp), %rcx
leaq 0x8(%rsp), %rdx
callq 0x9c50
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
subq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x254ce
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10c51
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 0x25098
cmpq $0x0, 0x18(%rsp)
je 0x10c8d
movq 0x10(%r14), %rsi
jmp 0x10c8f
xorl %esi, %esi
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rbx
callq 0x25544
movq 0x78(%rsp), %rax
cmpq %rax, %rbx
ja 0x10dc9
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 0x25976
leaq 0x20(%rsp), %rdi
callq 0x25d20
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rbx
callq 0x254a8
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 0x4aec4(%rip), %rsi     # 0x5bbd6
movq %rax, %rdi
callq 0x4110
jmp 0x10e22
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x496cd(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x10db3
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x496af(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x10db3
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x49691(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x10db3
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x49673(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
jmp 0x10db3
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x49655(%rip), %rsi     # 0x5a400
movq %rax, %rdi
callq 0x4110
movq 0x6b22e(%rip), %rsi     # 0x7bfe8
movq 0x6b1f7(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
leaq 0x4b56d(%rip), %rdi     # 0x5c33d
leaq 0x4b575(%rip), %rsi     # 0x5c34c
leaq 0x4b5a6(%rip), %rcx     # 0x5c384
movl $0x6f, %edx
callq 0x4200
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4adaa(%rip), %rsi     # 0x5bba6
movq %rax, %rdi
callq 0x4110
jmp 0x10e22
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4ad61(%rip), %rsi     # 0x5bb7b
movq %rax, %rdi
callq 0x4110
movq 0x6b1bf(%rip), %rsi     # 0x7bfe8
movq 0x6b188(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
jmp 0x10e51
jmp 0x10e51
jmp 0x10e44
jmp 0x10e44
jmp 0x10e44
jmp 0x10e44
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x10e7d
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x10e9e
movq %rax, %rdi
callq 0x9b7c
movq %rax, %rbx
jmp 0x10e94
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x15506
jmp 0x10e94
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10e94
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0x70(%rsp), %rdi
callq 0x254a8
movq %rbx, %rdi
callq 0x45e0