// File: /workspace/github_cpp_makefile_star2_O3/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 0x107b9
movq %rdi, %r15
cmpq $0x0, 0x10(%rdi)
je 0x107d8
movq %rdx, %r13
testq %rdx, %rdx
je 0x107f7
cmpq $0x0, 0x18(%r13)
je 0x10816
movq %r8, %r12
movq %rcx, %rbx
movq %rsi, %r14
leaq 0x128(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r15, %rdx
callq 0x4462e
testl %eax, %eax
je 0x10835
testq %r14, %r14
setne %cl
movl 0x138(%rsp), %eax
testl %eax, %eax
sete %dl
orb %cl, %dl
je 0x10853
testq %r14, %r14
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x10409
leaq 0x13c(%rsp), %rdi
callq *(%r14)
testl %eax, %eax
je 0x10871
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x253fa
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x4bf02(%rip), %rdx     # 0x5c335
movq %rbx, %rsi
callq 0x1091e
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
subq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x254ce
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10469
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0xc8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
leaq 0x30(%rsp), %rdi
movq $0x0, 0x40(%rdi)
movq %r15, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25098
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x258bc
leaq 0x30(%rsp), %rdi
callq 0x25d20
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x25544
movq %rbx, %rsi
testq %rbx, %rbx
je 0x104cf
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x25544
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x1079a
movq %r12, 0x118(%rsp)
movq %rax, 0x120(%rsp)
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x25544
movq %rbx, %rsi
testq %rbx, %rbx
je 0x1051d
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x25544
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x1079a
movq %r12, 0x108(%rsp)
movq %rax, 0x110(%rsp)
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x25544
movq %rbx, %rsi
testq %rbx, %rbx
je 0x1056b
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x25544
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x1079a
movq %r12, 0xf8(%rsp)
movq %rax, 0x100(%rsp)
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x25544
movq %rbx, %rsi
testq %rbx, %rbx
je 0x105b9
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x25544
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x1079a
movq %r12, 0xe8(%rsp)
movq %rax, 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 $0x0, 0x40(%rdi)
movq %r15, %rsi
callq 0x25098
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25976
leaq 0x30(%rsp), %rdi
callq 0x25d20
movq 0x98(%rsp), %r9
movq 0xa0(%rsp), %r8
testq %r8, %r8
movq %r8, %r13
cmoveq %r9, %r13
cmovneq %r14, %r8
movq 0xe0(%rsp), %rdx
addq %rdx, %r13
leaq 0x30(%rsp), %rdi
movq $0x0, 0x40(%rdi)
movq %r15, %rsi
movq %r13, %rcx
callq 0x25098
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x108(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25976
leaq 0x30(%rsp), %rdi
callq 0x25d20
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 $0x0, 0x40(%rdi)
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x25098
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25976
leaq 0x30(%rsp), %rdi
callq 0x25d20
movq 0xc0(%rsp), %rcx
testq %rcx, %rcx
cmoveq %rcx, %r14
movq 0xb8(%rsp), %r9
cmoveq %r9, %rcx
addq %r12, %rcx
leaq 0x30(%rsp), %rdi
movq $0x0, 0x40(%rdi)
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %r8
callq 0x25098
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xe8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25976
leaq 0x30(%rsp), %rdi
callq 0x25d20
leaq 0x8(%rsp), %rdi
callq 0x254a8
addq $0x240, %rsp            # imm = 0x240
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x4bb9c(%rip), %rdi     # 0x5c33d
leaq 0x4bba4(%rip), %rsi     # 0x5c34c
leaq 0x4bbd5(%rip), %rcx     # 0x5c384
movl $0x6f, %edx
callq 0x4200
leaq 0x4b231(%rip), %rdi     # 0x5b9f1
leaq 0x4b170(%rip), %rsi     # 0x5b937
leaq 0x4b22e(%rip), %rcx     # 0x5b9fc
movl $0x563, %edx            # imm = 0x563
callq 0x4200
leaq 0x4b2b7(%rip), %rdi     # 0x5ba96
leaq 0x4b151(%rip), %rsi     # 0x5b937
leaq 0x4b20f(%rip), %rcx     # 0x5b9fc
movl $0x564, %edx            # imm = 0x564
callq 0x4200
leaq 0x4b2a9(%rip), %rdi     # 0x5baa7
leaq 0x4b132(%rip), %rsi     # 0x5b937
leaq 0x4b1f0(%rip), %rcx     # 0x5b9fc
movl $0x565, %edx            # imm = 0x565
callq 0x4200
leaq 0x4b296(%rip), %rdi     # 0x5bab3
leaq 0x4b113(%rip), %rsi     # 0x5b937
leaq 0x4b1d1(%rip), %rcx     # 0x5b9fc
movl $0x566, %edx            # imm = 0x566
callq 0x4200
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4b27d(%rip), %rsi     # 0x5bac6
movq %rax, %rdi
callq 0x4110
jmp 0x1088d
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4b291(%rip), %rsi     # 0x5baf8
movq %rax, %rdi
callq 0x4110
jmp 0x1088d
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4b2a9(%rip), %rsi     # 0x5bb2e
movq %rax, %rdi
callq 0x4110
movq 0x6b754(%rip), %rsi     # 0x7bfe8
movq 0x6b71d(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
jmp 0x108a7
jmp 0x108a7
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x108fa
jmp 0x108d0
jmp 0x108d8
jmp 0x108ed
jmp 0x108d0
jmp 0x108d8
jmp 0x108ed
jmp 0x108d0
jmp 0x108d8
jmp 0x108ed
jmp 0x108d0
jmp 0x108d8
jmp 0x108ed
jmp 0x108ed
jmp 0x108ed
movq %rax, %rdi
callq 0x9b7c
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x15506
jmp 0x108f0
jmp 0x108ed
jmp 0x108ed
jmp 0x108ed
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x254a8
movq %rbx, %rdi
callq 0x45e0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x108f0
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
jmp 0x108f0