// File: /workspace/github_cpp_makefile_star2_O3/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 0x25aaa
movq %r9, %r12
movq %rsi, %rbx
movq 0x8(%rsi), %rbp
cmpq %r9, %rbp
jb 0x25ac8
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %r15
testq %rdx, %rdx
je 0x25a60
leaq 0x1(%r12), %rcx
cmpq %rcx, %rbp
setb %cl
movl %r8d, %edx
xorb $0x1, %dl
testb %dl, %cl
jne 0x25a60
movl %r8d, 0xc(%rsp)
testb %r8b, %r8b
je 0x259ec
incq %rbp
movq %rbp, %rdi
callq *0x8(%r13)
movq %rax, %rbp
movq 0x8(%r15), %rax
jmp 0x259f5
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)
movq $0x0, 0x38(%rsi)
movb $0x0, 0x40(%rsi)
movq %rsi, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
leaq -0x267b(%rip), %rax     # 0x233ae
movq %rax, 0x18(%rsi)
movq %r13, %rdi
movq %rbx, %rdx
callq *0x18(%r13)
movq %rax, %r13
decq %rax
cmpq %rbp, %rax
jae 0x25a51
cmpb $0x0, 0x50(%rsp)
jne 0x25a51
addq %r13, 0x8(%r15)
xorl %ebp, %ebp
jmp 0x25a78
cmpb $0x0, 0xc(%rsp)
jne 0x25afa
movq 0x8(%r15), %rax
subq %r12, %rax
movq %rax, 0x8(%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x258bc
movb $0x1, %bpl
xorl %r13d, %r13d
movq (%r14), %rax
orq 0x8(%r14), %rax
je 0x25a8f
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x256b6
testb %bpl, %bpl
je 0x25a98
movq 0x8(%rbx), %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 0x381a6(%rip), %rsi     # 0x5dc64
movq %rax, %rdi
callq 0x4110
jmp 0x25ae4
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x381ba(%rip), %rsi     # 0x5dc96
movq %rax, %rdi
callq 0x4110
movq 0x564fd(%rip), %rsi     # 0x7bfe8
movq 0x564c6(%rip), %rdx     # 0x7bfb8
movq %r14, %rdi
callq 0x4590
movl $0x10, %edi
callq 0x4190
movq %rax, %r14
leaq 0x381c4(%rip), %rsi     # 0x5dcd2
movq %rax, %rdi
callq 0x4110
jmp 0x25ae4
jmp 0x25b1c
jmp 0x25b1c
movq %rax, %rbx
movq %r14, %rdi
callq 0x4260
movq %rbx, %rdi
callq 0x45e0
nop