// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/src/../HDiffPatch/compress_plugin_demo.h
// Function: lzma_compress(hdiff_TCompress const*, hpatch_TStreamOutput const*, hpatch_TStreamInput const*)
static hpatch_StreamPos_t _lzma_compress(const hdiff_TCompress* compressPlugin,
                                             const hpatch_TStreamOutput* out_code,
                                             const hpatch_TStreamInput*  in_data){
        const TCompressPlugin_lzma* plugin=(const TCompressPlugin_lzma*)compressPlugin;
        struct __lzma_SeqOutStream_t outStream={{__lzma_SeqOutStream_Write},out_code,0,0};
        struct __lzma_SeqInStream_t  inStream={{__lzma_SeqInStream_Read},in_data,0};
        hpatch_StreamPos_t result=0;
        const char*        errAt="";
#if (IS_REUSE_compress_handle)
        static CLzmaEncHandle   s=0;
#else
        CLzmaEncHandle          s=0;
#endif
        CLzmaEncProps      props;
        unsigned char      properties_buf[LZMA_PROPS_SIZE+1];
        SizeT              properties_size=LZMA_PROPS_SIZE;
        SRes               ret;
        hpatch_uint32_t    dictSize=plugin->dict_size;
        if (!s) s=LzmaEnc_Create(&__lzma_enc_alloc);
        if (!s) _compress_error_return("LzmaEnc_Create()");
        LzmaEncProps_Init(&props);
        props.level=plugin->compress_level;
        props.dictSize=dictSize;
        props.reduceSize=in_data->streamSize;
        props.numThreads=plugin->thread_num;
        LzmaEncProps_Normalize(&props);
        if (SZ_OK!=LzmaEnc_SetProps(s,&props)) _compress_error_return("LzmaEnc_SetProps()");
#       if (IS_NOTICE_compress_canceled)
        printf("  (used one lzma dictSize: %" PRIu64 "  (input data: %" PRIu64 "))\n",
               (hpatch_StreamPos_t)props.dictSize,in_data->streamSize);
#       endif
        
        //save properties_size+properties
        assert(LZMA_PROPS_SIZE<256);
        if (SZ_OK!=LzmaEnc_WriteProperties(s,properties_buf+1,&properties_size))
            _compress_error_return("LzmaEnc_WriteProperties()");
        properties_buf[0]=(unsigned char)properties_size;
        
        if (1+properties_size!=__lzma_SeqOutStream_Write(&outStream.base,properties_buf,1+properties_size))
            _compress_error_return("out_code->write()");
        
        ret=LzmaEnc_Encode(s,&outStream.base,&inStream.base,0,&__lzma_enc_alloc,&__lzma_enc_alloc);
        if (SZ_OK==ret){
            result=outStream.writeToPos;
        }else{//fail
            if (ret==SZ_ERROR_READ)
                _compress_error_return("in_data->read()");
            else if (ret==SZ_ERROR_WRITE)
                _compress_error_return("out_code->write()");
            else
                _compress_error_return("LzmaEnc_Encode()");
        }
    clear:
#if (!IS_REUSE_compress_handle)
        if (s) { LzmaEnc_Destroy(s,&__lzma_enc_alloc,&__lzma_enc_alloc); s=0; }
#endif
        _check_compress_result(result,outStream.isCanceled,"_lzma_compress()",errAt);
        return result;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdx, %r15
movq %rdi, %r12
leaq 0xdfc(%rip), %rax       # 0x6bfd
movq %rax, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
xorl %r14d, %r14d
movq %r14, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
leaq 0xe1b(%rip), %rax       # 0x6c3d
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq $0x5, 0x8(%rsp)
movl 0x2c(%rdi), %ebp
leaq 0x7668c(%rip), %rdi     # 0x7c4d0
callq 0x33628
movq %rax, %rbx
testq %rax, %rax
je 0x5e9e
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x330dc
movl 0x28(%r12), %eax
movl %eax, (%r14)
movl %ebp, 0x4(%r14)
movq 0x8(%r15), %rax
movq %rax, 0x38(%r14)
movl 0x30(%r12), %eax
movl %eax, 0x30(%r14)
movq %r14, %rdi
callq 0x33112
movq %rbx, %rdi
movq %r14, %rsi
callq 0x334f0
testl %eax, %eax
je 0x5ea7
leaq 0x536c1(%rip), %r15     # 0x5955a
xorl %r14d, %r14d
jmp 0x5edd
leaq 0x53560(%rip), %r15     # 0x59405
jmp 0x5edd
movl 0x4c(%rsp), %esi
movq 0x8(%r15), %rdx
leaq 0x536b7(%rip), %rdi     # 0x5956d
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x4060
leaq 0x3(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x366a0
testl %eax, %eax
je 0x5f32
leaq 0x536c6(%rip), %r15     # 0x595a3
testq %rbx, %rbx
je 0x5ef4
leaq 0x765e7(%rip), %rdx     # 0x7c4d0
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x3375d
testq %r14, %r14
jne 0x5f1f
cmpl $0x0, 0x28(%rsp)
je 0x5f0e
leaq 0x54063(%rip), %rdi     # 0x59f6a
callq 0x44e0
jmp 0x5f1f
leaq 0x536b9(%rip), %rdi     # 0x595ce
movq %r15, %rsi
xorl %eax, %eax
callq 0x4060
movq %r14, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r14
movb %r14b, 0x2(%rsp)
incq %r14
je 0x5f5f
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
leaq (%rsp,%r14), %rcx
addq $0x2, %rcx
leaq 0x2(%rsp), %rdx
callq *0x18(%rdi)
testl %eax, %eax
je 0x5fbb
addq %r14, 0x20(%rsp)
movq %r14, %rax
leaq 0x531d3(%rip), %r15     # 0x59141
cmpq %rax, %r14
jne 0x5e99
leaq 0x76552(%rip), %r8      # 0x7c4d0
xorl %r14d, %r14d
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
movq %r8, %r9
callq 0x365cb
cmpl $0x9, %eax
je 0x5e99
cmpl $0x8, %eax
je 0x5fc7
testl %eax, %eax
jne 0x5fd3
leaq 0x54cc8(%rip), %r15     # 0x5ac79
movq 0x20(%rsp), %r14
jmp 0x5edd
movl $0x1, 0x28(%rsp)
xorl %eax, %eax
jmp 0x5f67
leaq 0x53185(%rip), %r15     # 0x59153
jmp 0x5edd
leaq 0x535e3(%rip), %r15     # 0x595bd
jmp 0x5e99