// File: /workspace/github_cpp_makefile_star2_O1/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 0x10b00
movq %rdi, %r15
cmpq $0x0, 0x10(%rdi)
je 0x10b1f
movq %rdx, %r13
testq %rdx, %rdx
je 0x10b3e
cmpq $0x0, 0x18(%r13)
je 0x10b5d
movq %r8, %r12
movq %rcx, %rbx
movq %rsi, %r14
leaq 0x128(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r15, %rdx
callq 0x44e00
testl %eax, %eax
je 0x10b7c
testq %r14, %r14
setne %cl
movl 0x138(%rsp), %eax
testl %eax, %eax
sete %dl
orb %cl, %dl
je 0x10b9a
testq %r14, %r14
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x10750
leaq 0x13c(%rsp), %rdi
callq *(%r14)
testl %eax, %eax
je 0x10bb8
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x256c4
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x4bbbb(%rip), %rdx     # 0x5c335
movq %rbx, %rsi
callq 0x10c65
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
subq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x257a8
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x107b0
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 0x25364
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x25b96
leaq 0x30(%rsp), %rdi
callq 0x25ff0
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2581e
movq %rbx, %rsi
testq %rbx, %rbx
je 0x10816
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x2581e
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x10ae1
movq %r12, 0x118(%rsp)
movq %rax, 0x120(%rsp)
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2581e
movq %rbx, %rsi
testq %rbx, %rbx
je 0x10864
movq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x2581e
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x10ae1
movq %r12, 0x108(%rsp)
movq %rax, 0x110(%rsp)
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2581e
movq %rbx, %rsi
testq %rbx, %rbx
je 0x108b2
movq 0xa8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x2581e
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x10ae1
movq %r12, 0xf8(%rsp)
movq %rax, 0x100(%rsp)
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2581e
movq %rbx, %rsi
testq %rbx, %rbx
je 0x10900
movq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0x2581e
movq 0x10(%rsp), %rax
cmpq %rax, %r12
ja 0x10ae1
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 0x25364
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25c50
leaq 0x30(%rsp), %rdi
callq 0x25ff0
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 0x25364
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x108(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25c50
leaq 0x30(%rsp), %rdi
callq 0x25ff0
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 0x25364
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25c50
leaq 0x30(%rsp), %rdi
callq 0x25ff0
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 0x25364
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xe8(%rsp), %rcx
movq %rbx, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x25c50
leaq 0x30(%rsp), %rdi
callq 0x25ff0
leaq 0x8(%rsp), %rdi
callq 0x25782
addq $0x240, %rsp            # imm = 0x240
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x4b855(%rip), %rdi     # 0x5c33d
leaq 0x4b85d(%rip), %rsi     # 0x5c34c
leaq 0x4b88e(%rip), %rcx     # 0x5c384
movl $0x6f, %edx
callq 0x4200
leaq 0x4aeea(%rip), %rdi     # 0x5b9f1
leaq 0x4ae29(%rip), %rsi     # 0x5b937
leaq 0x4aee7(%rip), %rcx     # 0x5b9fc
movl $0x563, %edx            # imm = 0x563
callq 0x4200
leaq 0x4af70(%rip), %rdi     # 0x5ba96
leaq 0x4ae0a(%rip), %rsi     # 0x5b937
leaq 0x4aec8(%rip), %rcx     # 0x5b9fc
movl $0x564, %edx            # imm = 0x564
callq 0x4200
leaq 0x4af62(%rip), %rdi     # 0x5baa7
leaq 0x4adeb(%rip), %rsi     # 0x5b937
leaq 0x4aea9(%rip), %rcx     # 0x5b9fc
movl $0x565, %edx            # imm = 0x565
callq 0x4200
leaq 0x4af4f(%rip), %rdi     # 0x5bab3
leaq 0x4adcc(%rip), %rsi     # 0x5b937
leaq 0x4ae8a(%rip), %rcx     # 0x5b9fc
movl $0x566, %edx            # imm = 0x566
callq 0x4200
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4af36(%rip), %rsi     # 0x5bac6
movq %rax, %rdi
callq 0x4110
jmp 0x10bd4
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4af4a(%rip), %rsi     # 0x5baf8
movq %rax, %rdi
callq 0x4110
jmp 0x10bd4
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x4af62(%rip), %rsi     # 0x5bb2e
movq %rax, %rdi
callq 0x4110
movq 0x6b40d(%rip), %rsi     # 0x7bfe8
movq 0x6b3d6(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
jmp 0x10bee
jmp 0x10bee
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
jmp 0x10c41
jmp 0x10c17
jmp 0x10c1f
jmp 0x10c34
jmp 0x10c17
jmp 0x10c1f
jmp 0x10c34
jmp 0x10c17
jmp 0x10c1f
jmp 0x10c34
jmp 0x10c17
jmp 0x10c1f
jmp 0x10c34
jmp 0x10c34
jmp 0x10c34
movq %rax, %rdi
callq 0x9db0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x15840
jmp 0x10c37
jmp 0x10c34
jmp 0x10c34
jmp 0x10c34
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x25782
movq %rbx, %rdi
callq 0x45e0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10c37
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
jmp 0x10c37