// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: resave_compressed_diff(hpatch_TStreamInput const*, hpatch_TDecompress*, hpatch_TStreamOutput const*, hdiff_TCompress const*, unsigned long long)
void resave_compressed_diff(const hpatch_TStreamInput*  in_diff,
                            hpatch_TDecompress*         decompressPlugin,
                            const hpatch_TStreamOutput* out_diff,
                            const hdiff_TCompress*      compressPlugin,
                            hpatch_StreamPos_t          out_diff_curPos){
    _THDiffzHead              head;
    hpatch_compressedDiffInfo diffInfo;
    assert(in_diff!=0);
    assert(in_diff->read!=0);
    assert(out_diff!=0);
    assert(out_diff->write!=0);
    
    {//read head
        checki(read_diffz_head(&diffInfo,&head,in_diff),
               "resave_compressed_diff() read_diffz_head() error!");
        checki((decompressPlugin!=0)||(diffInfo.compressedCount<=0),
               "resave_compressed_diff() decompressPlugin null error!");
        if ((decompressPlugin)&&(diffInfo.compressedCount>0)){
            checki(decompressPlugin->is_can_open(diffInfo.compressType),
                   "resave_compressed_diff() decompressPlugin cannot open compressed data error!");
        }
    }
    
    TDiffStream outDiff(out_diff,out_diff_curPos);
    {//type
        std::vector<TByte> out_type;
        _outType(out_type,compressPlugin);
        outDiff.pushBack(out_type.data(),out_type.size());
    }
    {//copy other
        TStreamClip clip(in_diff,head.typesEndPos,head.compressSizeBeginPos);
        outDiff.pushStream(&clip);
    }
    outDiff.packUInt(head.cover_buf_size);
    TPlaceholder compress_cover_buf_sizePos=
        outDiff.packUInt_pos(compressPlugin?head.cover_buf_size:0);//compress_cover_buf size
    outDiff.packUInt(head.rle_ctrlBuf_size);//rle_ctrlBuf size
    TPlaceholder compress_rle_ctrlBuf_sizePos=
        outDiff.packUInt_pos(compressPlugin?head.rle_ctrlBuf_size:0);//compress_rle_ctrlBuf size
    outDiff.packUInt(head.rle_codeBuf_size);//rle_codeBuf size
    TPlaceholder compress_rle_codeBuf_sizePos=
        outDiff.packUInt_pos(compressPlugin?head.rle_codeBuf_size:0);//compress_rle_codeBuf size
    outDiff.packUInt(head.newDataDiff_size);
    TPlaceholder compress_newDataDiff_sizePos=
        outDiff.packUInt_pos(compressPlugin?head.newDataDiff_size:0);//compress_newDataDiff size
    
    {//save covers
        TStreamClip clip(in_diff,head.headEndPos,head.coverEndPos,
                         (head.compress_cover_buf_size>0)?decompressPlugin:0,head.cover_buf_size);
        outDiff.pushStream(&clip,compressPlugin,compress_cover_buf_sizePos);
    }
    hpatch_StreamPos_t diffPos0=head.coverEndPos;
    {//save rle ctrl
        bool isCompressed=(head.compress_rle_ctrlBuf_size>0);
        hpatch_StreamPos_t bufSize=isCompressed?head.compress_rle_ctrlBuf_size:head.rle_ctrlBuf_size;
        TStreamClip clip(in_diff,diffPos0,diffPos0+bufSize,
                         isCompressed?decompressPlugin:0,head.rle_ctrlBuf_size);
        outDiff.pushStream(&clip,compressPlugin,compress_rle_ctrlBuf_sizePos);
        diffPos0+=bufSize;
    }
    {//save rle code
        bool isCompressed=(head.compress_rle_codeBuf_size>0);
        hpatch_StreamPos_t bufSize=isCompressed?head.compress_rle_codeBuf_size:head.rle_codeBuf_size;
        TStreamClip clip(in_diff,diffPos0,diffPos0+bufSize,
                         isCompressed?decompressPlugin:0,head.rle_codeBuf_size);
        outDiff.pushStream(&clip,compressPlugin,compress_rle_codeBuf_sizePos);
        diffPos0+=bufSize;
    }
    {//save newDataDiff
        bool isCompressed=(head.compress_newDataDiff_size>0);
        hpatch_StreamPos_t bufSize=isCompressed?head.compress_newDataDiff_size:head.newDataDiff_size;
        TStreamClip clip(in_diff,diffPos0,diffPos0+bufSize,
                         isCompressed?decompressPlugin:0,head.newDataDiff_size);
        outDiff.pushStream(&clip,compressPlugin,compress_newDataDiff_sizePos);
        diffPos0+=bufSize;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x240, %rsp            # imm = 0x240
testq %rdi, %rdi
je 0xdf38
movq %rdi, %r15
cmpq $0x0, 0x10(%rdi)
je 0xdf57
movq %rdx, %r13
testq %rdx, %rdx
je 0xdf76
cmpq $0x0, 0x18(%r13)
je 0xdf95
movq %r8, %r12
movq %rcx, %rbx
movq %rsi, %r14
leaq 0x128(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r15, %rdx
callq 0x3b682
testl %eax, %eax
je 0xdfb4
testq %r14, %r14
setne %cl
movl 0x138(%rsp), %eax
testl %eax, %eax
sete %dl
orb %cl, %dl
je 0xdfd0
testq %r14, %r14
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0xdc27
leaq 0x13c(%rsp), %rdi
callq *(%r14)
testl %eax, %eax
je 0xdfec
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x20594
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
leaq 0x4380b(%rip), %rdx     # 0x51459
movq %rbx, %rsi
callq 0xe07a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
subq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x205e2
leaq 0x30(%rsp), %rdi
callq 0x8b88
movq 0xc8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x11ea4
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x11eae
leaq 0x30(%rsp), %rdi
callq 0x11ebe
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20656
movq %rbx, %rsi
testq %rbx, %rbx
je 0xdcd5
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x11ece
movq %rax, 0x118(%rsp)
movq %rdx, 0x120(%rsp)
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20656
movq %rbx, %rsi
testq %rbx, %rbx
je 0xdd11
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x11ece
movq %rax, 0x108(%rsp)
movq %rdx, 0x110(%rsp)
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20656
movq %rbx, %rsi
testq %rbx, %rbx
je 0xdd4d
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x11ece
movq %rax, 0xf8(%rsp)
movq %rdx, 0x100(%rsp)
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20656
movq %rbx, %rsi
testq %rbx, %rbx
je 0xdd89
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x11ece
movq %rax, 0xe8(%rsp)
movq %rdx, 0xf0(%rsp)
movq 0xd8(%rsp), %rdx
movq 0xe0(%rsp), %rcx
movq 0x88(%rsp), %r9
movq 0x90(%rsp), %r8
testq %r8, %r8
cmovneq %r14, %r8
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x11ea4
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x20a6c
leaq 0x30(%rsp), %rdi
callq 0x11ebe
movq 0x98(%rsp), %r9
movq 0xa0(%rsp), %r8
testq %r8, %r8
movq %r8, %r13
cmoveq %r9, %r13
movq 0xe0(%rsp), %rdx
cmovneq %r14, %r8
addq %rdx, %r13
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rcx
callq 0x11ea4
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x108(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x20a6c
leaq 0x30(%rsp), %rdi
callq 0x11ebe
movq 0xa8(%rsp), %r9
movq 0xb0(%rsp), %r8
testq %r8, %r8
movq %r8, %r12
cmoveq %r9, %r12
cmovneq %r14, %r8
addq %r13, %r12
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x11ea4
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x20a6c
leaq 0x30(%rsp), %rdi
callq 0x11ebe
movq 0xb8(%rsp), %r9
movq 0xc0(%rsp), %rcx
testq %rcx, %rcx
cmoveq %rcx, %r14
cmoveq %r9, %rcx
addq %r12, %rcx
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %r8
callq 0x11ea4
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xe8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x20a6c
leaq 0x30(%rsp), %rdi
callq 0x11ebe
leaq 0x8(%rsp), %rdi
callq 0x205d8
addq $0x240, %rsp            # imm = 0x240
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x42ab2(%rip), %rdi     # 0x509f1
leaq 0x429f1(%rip), %rsi     # 0x50937
leaq 0x42aaf(%rip), %rcx     # 0x509fc
movl $0x563, %edx            # imm = 0x563
callq 0x4230
leaq 0x42b38(%rip), %rdi     # 0x50a96
leaq 0x429d2(%rip), %rsi     # 0x50937
leaq 0x42a90(%rip), %rcx     # 0x509fc
movl $0x564, %edx            # imm = 0x564
callq 0x4230
leaq 0x42b2a(%rip), %rdi     # 0x50aa7
leaq 0x429b3(%rip), %rsi     # 0x50937
leaq 0x42a71(%rip), %rcx     # 0x509fc
movl $0x565, %edx            # imm = 0x565
callq 0x4230
leaq 0x42b17(%rip), %rdi     # 0x50ab3
leaq 0x42994(%rip), %rsi     # 0x50937
leaq 0x42a52(%rip), %rcx     # 0x509fc
movl $0x566, %edx            # imm = 0x566
callq 0x4230
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x42b00(%rip), %rsi     # 0x50ac6
movq %rax, %rdi
callq 0x4120
jmp 0xe006
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x42b16(%rip), %rsi     # 0x50af8
movq %rax, %rdi
callq 0x4120
jmp 0xe006
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x42b30(%rip), %rsi     # 0x50b2e
movq %rax, %rdi
callq 0x4120
movq 0x66fdb(%rip), %rsi     # 0x74fe8
movq 0x66fa4(%rip), %rdx     # 0x74fb8
movq %r14, %rdi
callq 0x45b0
jmp 0xe020
jmp 0xe020
movq %rax, %rbx
movq %r14, %rdi
callq 0x4290
jmp 0xe063
jmp 0xe041
jmp 0xe056
jmp 0xe041
jmp 0xe056
jmp 0xe041
jmp 0xe056
jmp 0xe041
jmp 0xe056
jmp 0xe056
jmp 0xe056
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x11ebe
jmp 0xe059
jmp 0xe056
jmp 0xe056
jmp 0xe056
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x205d8
movq %rbx, %rdi
callq 0x4600
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8b88
jmp 0xe059