// File: /workspace/github_cpp_makefile_star2_O1/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
cmpq %r9, 0x8(%rdi)
jb 0x25d7a
movq %r9, %r12
movq 0x8(%rsi), %rbx
cmpq %r9, %rbx
jb 0x25d98
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %r15
movq %rsi, %rbp
testq %rdx, %rdx
je 0x25d31
leaq 0x1(%r12), %rax
cmpq %rax, %rbx
setb %al
movl %r8d, %ecx
xorb $0x1, %cl
testb %cl, %al
jne 0x25d31
movl %r8d, 0xc(%rsp)
testb %r8b, %r8b
je 0x25cbf
incq %rbx
movq %rbx, %rdi
callq *0x8(%r13)
movq %rax, %rbx
jmp 0x25cc8
movq %r12, %rax
notq %rax
addq %rax, %rbx
movq (%r15), %rax
movq 0x8(%r15), %rcx
leaq 0x10(%rsp), %rsi
movq %rax, 0x20(%rsi)
movq %rcx, 0x28(%rsi)
addq %rbx, %rcx
movq %rcx, 0x30(%rsi)
movq $0x0, 0x38(%rsi)
movb $0x0, 0x40(%rsi)
movq %rsi, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
leaq -0x26be(%rip), %rax     # 0x23642
movq %rax, 0x18(%rsi)
movq %r13, %rdi
movq %rbp, %rdx
callq *0x18(%r13)
movq %rax, %r13
decq %rax
cmpq %rbx, %rax
jae 0x25d26
cmpb $0x0, 0x50(%rsp)
jne 0x25d26
addq %r13, 0x8(%r15)
jmp 0x25d34
cmpb $0x0, 0xc(%rsp)
jne 0x25dca
xorl %r13d, %r13d
testq %r13, %r13
jne 0x25d48
subq %r12, 0x8(%r15)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x25b96
movq (%r14), %rax
orq 0x8(%r14), %rax
je 0x25d5f
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x25990
testq %r13, %r13
jne 0x25d68
movq 0x8(%rbp), %r13
movq %r13, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x37ee6(%rip), %rsi     # 0x5dc74
movq %rax, %rdi
callq 0x4110
jmp 0x25db4
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x37efa(%rip), %rsi     # 0x5dca6
movq %rax, %rdi
callq 0x4110
movq 0x5622d(%rip), %rsi     # 0x7bfe8
movq 0x561f6(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x37f04(%rip), %rsi     # 0x5dce2
movq %rax, %rdi
callq 0x4110
jmp 0x25db4
jmp 0x25dec
jmp 0x25dec
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
movq %rbx, %rdi
callq 0x45e0
nop