// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp
// Function: hdiff_private::TDiffStream::pushStream(hpatch_TStreamInput const*, hdiff_TCompress const*, hdiff_private::TPlaceholder const&, bool, unsigned long long)
hpatch_StreamPos_t TDiffStream::pushStream(const hpatch_TStreamInput* stream,
                                           const hdiff_TCompress* compressPlugin,
                                           const TPlaceholder& update_compress_sizePos,
                                           bool isMustCompress,const hpatch_StreamPos_t cancelSizeOnCancelCompress){
    hpatch_StreamPos_t compressed_size=0;
    check(writePos>=cancelSizeOnCancelCompress);
    check(stream->streamSize>=cancelSizeOnCancelCompress);
    if ((compressPlugin)&&(isMustCompress||(stream->streamSize>=1+cancelSizeOnCancelCompress))){
        hpatch_StreamPos_t kLimitOutCodeSize=isMustCompress?compressPlugin->maxCompressedSize(stream->streamSize+1)
                                            :(stream->streamSize-(1+cancelSizeOnCancelCompress));
        TCompressedStream  out_stream(out_diff,writePos,kLimitOutCodeSize);
        compressed_size=compressPlugin->compress(compressPlugin,&out_stream,stream);
        if (out_stream.is_overLimit()||(compressed_size==0)||(compressed_size>kLimitOutCodeSize)){
            check(!isMustCompress);
            compressed_size=0;//NOTICE: compress is canceled
        }else{
            writePos+=compressed_size; //compress ok
        }
    }

    if (compressed_size==0){
        writePos-=cancelSizeOnCancelCompress;//revoke some data
        _pushStream(stream);
    }
    if (!update_compress_sizePos.isNullPos())
        packUInt_update(update_compress_sizePos,compressed_size);
    return (compressed_size==0)?stream->streamSize:compressed_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq 0x8(%rdi), %rax
cmpq %r9, %rax
jb 0x20b9d
movq %r9, %r12
movq %rsi, %rbx
movq 0x8(%rsi), %rbp
cmpq %r9, %rbp
jb 0x20bb9
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %r15
testq %rdx, %rdx
je 0x20b53
leaq 0x1(%r12), %rcx
cmpq %rcx, %rbp
setb %cl
movl %r8d, %edx
xorb $0x1, %dl
testb %dl, %cl
jne 0x20b53
movl %r8d, 0xc(%rsp)
testb %r8b, %r8b
je 0x20ae2
incq %rbp
movq %rbp, %rdi
callq *0x8(%r13)
movq %rax, %rbp
movq 0x8(%r15), %rax
jmp 0x20aeb
movq %r12, %rcx
notq %rcx
addq %rcx, %rbp
movq (%r15), %rcx
leaq 0x10(%rsp), %rsi
movq %rcx, 0x20(%rsi)
movq %rax, 0x28(%rsi)
addq %rbp, %rax
movq %rax, 0x30(%rsi)
andq $0x0, 0x38(%rsi)
movb $0x0, 0x40(%rsi)
movq %rsi, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
leaq -0x2122(%rip), %rax     # 0x1e9fa
movq %rax, 0x18(%rsi)
movq %r13, %rdi
movq %rbx, %rdx
callq *0x18(%r13)
movq %rax, %r13
decq %rax
cmpq %rbp, %rax
jae 0x20b44
cmpb $0x0, 0x50(%rsp)
jne 0x20b44
addq %r13, 0x8(%r15)
xorl %ebp, %ebp
jmp 0x20b6b
cmpb $0x0, 0xc(%rsp)
jne 0x20be9
movq 0x8(%r15), %rax
subq %r12, %rax
movq %rax, 0x8(%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x209be
movb $0x1, %bpl
xorl %r13d, %r13d
movq (%r14), %rax
orq 0x8(%r14), %rax
je 0x20b82
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x207c0
testb %bpl, %bpl
je 0x20b8b
movq 0x8(%rbx), %r13
movq %r13, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x321d5(%rip), %rsi     # 0x52d84
movq %rax, %rdi
callq 0x4120
jmp 0x20bd3
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x321eb(%rip), %rsi     # 0x52db6
movq %rax, %rdi
callq 0x4120
movq 0x5440e(%rip), %rsi     # 0x74fe8
movq 0x543d7(%rip), %rdx     # 0x74fb8
movq %r14, %rdi
callq 0x45b0
pushq $0x10
popq %rdi
callq 0x41c0
movq %rax, %r14
leaq 0x321f7(%rip), %rsi     # 0x52df2
movq %rax, %rdi
callq 0x4120
jmp 0x20bd3
jmp 0x20c09
jmp 0x20c09
movq %rax, %rbx
movq %r14, %rdi
callq 0x4290
movq %rbx, %rdi
callq 0x4600