// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/diff.cpp
// Function: serialize_single_compressed_diff(hpatch_TStreamInput const*, hpatch_TStreamInput const*, bool, hdiff_private::TCovers const&, hpatch_TStreamOutput const*, hdiff_TCompress const*, unsigned long)
static void serialize_single_compressed_diff(const hpatch_TStreamInput* newStream,const hpatch_TStreamInput* oldStream,
                                             bool isZeroSubDiff,const TCovers& covers,const hpatch_TStreamOutput* out_diff,
                                             const hdiff_TCompress* compressPlugin,size_t patchStepMemSize){
    check(patchStepMemSize>=hpatch_kStreamCacheSize);
    if (patchStepMemSize>newStream->streamSize){
        patchStepMemSize=(size_t)newStream->streamSize;
        if (patchStepMemSize<hpatch_kStreamCacheSize)
            patchStepMemSize=hpatch_kStreamCacheSize;
    }
    TStepStream stepStream(newStream,oldStream,isZeroSubDiff,covers,patchStepMemSize);
    
    TDiffStream outDiff(out_diff);
    {//type
        std::vector<TByte> out_type;
        _outType(out_type,compressPlugin,kHDiffSFVersionType);
        outDiff.pushBack(out_type.data(),out_type.size());
    }
    outDiff.packUInt(newStream->streamSize);
    outDiff.packUInt(oldStream->streamSize);
    outDiff.packUInt(stepStream.getCoverCount());
    outDiff.packUInt(stepStream.getMaxStepMemSize());
    outDiff.packUInt(stepStream.streamSize);
    TPlaceholder compressed_sizePos=outDiff.packUInt_pos(compressPlugin?stepStream.streamSize:0);
    outDiff.pushStream(&stepStream,compressPlugin,compressed_sizePos);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3a0, %rsp            # imm = 0x3A0
movb %dl, %al
movq 0x10(%rbp), %rdx
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x1000, 0x10(%rbp)     # imm = 0x1000
jae 0x1a3c0
movl $0x10, %edi
callq 0x41e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x358(%rbp)
leaq 0x9542f(%rip), %rsi     # 0xaf7b1
callq 0x4140
jmp 0x1a389
movq -0x358(%rbp), %rdi
movq 0xcbc59(%rip), %rsi     # 0xe5ff0
movq 0xcbc22(%rip), %rdx     # 0xe5fc0
callq 0x4630
movq -0x358(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x42e0
jmp 0x1a626
movq 0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x1a3ee
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rbp)
cmpq $0x1000, 0x10(%rbp)     # imm = 0x1000
jae 0x1a3ec
movq $0x1000, 0x10(%rbp)     # imm = 0x1000
jmp 0x1a3ee
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %r8
movq 0x10(%rbp), %r9
movzbl -0x11(%rbp), %ecx
andl $0x1, %ecx
leaq -0x300(%rbp), %rdi
callq 0x4de90
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x328(%rbp), %rdi
callq 0x4f3c0
jmp 0x1a427
leaq -0x340(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0xbe70
movq -0x360(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0xcc134(%rip), %rdx     # 0xe6580
callq 0x1c330
jmp 0x1a453
leaq -0x340(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0xbb60
movq -0x370(%rbp), %rdi
movq %rax, -0x368(%rbp)
callq 0xbe90
movq -0x368(%rbp), %rsi
movq %rax, %rdx
leaq -0x328(%rbp), %rdi
callq 0x4f450
jmp 0x1a491
leaq -0x340(%rbp), %rdi
callq 0xbb80
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4f510
jmp 0x1a4b3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4f510
jmp 0x1a4c9
leaq -0x300(%rbp), %rdi
callq 0x2b3d0
movq %rax, -0x378(%rbp)
jmp 0x1a4de
movq -0x378(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4f510
jmp 0x1a4f3
leaq -0x300(%rbp), %rdi
callq 0x2b3f0
movq %rax, -0x380(%rbp)
jmp 0x1a508
movq -0x380(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4f510
jmp 0x1a51d
movq -0x2f8(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4f510
jmp 0x1a532
cmpq $0x0, -0x30(%rbp)
je 0x1a549
movq -0x2f8(%rbp), %rax
movq %rax, -0x388(%rbp)
jmp 0x1a554
xorl %eax, %eax
movq %rax, -0x388(%rbp)
jmp 0x1a554
movq -0x388(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x29eb0
movq %rdx, -0x398(%rbp)
movq %rax, -0x390(%rbp)
jmp 0x1a577
movq -0x398(%rbp), %rax
movq -0x390(%rbp), %rcx
movq %rcx, -0x350(%rbp)
movq %rax, -0x348(%rbp)
movq -0x30(%rbp), %rdx
xorl %r8d, %r8d
movl %r8d, %r9d
leaq -0x328(%rbp), %rdi
leaq -0x300(%rbp), %rsi
leaq -0x350(%rbp), %rcx
callq 0x4fd10
jmp 0x1a5b9
leaq -0x328(%rbp), %rdi
callq 0x4f430
leaq -0x300(%rbp), %rdi
callq 0x2b410
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1a61a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x340(%rbp), %rdi
callq 0xbb80
jmp 0x1a60e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x4f430
leaq -0x300(%rbp), %rdi
callq 0x2b410
movq -0x38(%rbp), %rdi
callq 0x4680
nop