// File: sisong[P]ApkDiffPatch/src/../HDiffPatch/compress_plugin_demo.h
// Function: lzma2_compress(hdiff_TCompress const*, hpatch_TStreamOutput const*, hpatch_TStreamInput const*)
static hpatch_StreamPos_t _lzma2_compress(const hdiff_TCompress* compressPlugin,
                                              const hpatch_TStreamOutput* out_code,
                                              const hpatch_TStreamInput*  in_data){
        const TCompressPlugin_lzma2* plugin=(const TCompressPlugin_lzma2*)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 CLzma2EncHandle  s=0;
#else
        CLzma2EncHandle         s=0;
#endif
        CLzma2EncProps     props;
        Byte               properties_size=0;
        SRes               ret;
        hpatch_uint32_t    dictSize=plugin->dict_size;
        if (!s) s=Lzma2Enc_Create(&__lzma_enc_alloc,&__lzma_enc_alloc);
        if (!s) _compress_error_return("LzmaEnc_Create()");
        Lzma2EncProps_Init(&props);
        props.lzmaProps.level=plugin->compress_level;
        props.lzmaProps.dictSize=dictSize;
        props.lzmaProps.reduceSize=in_data->streamSize;
        props.blockSize=LZMA2_ENC_PROPS_BLOCK_SIZE_AUTO;
        props.numTotalThreads=plugin->thread_num;
        Lzma2EncProps_Normalize(&props);
        if (SZ_OK!=Lzma2Enc_SetProps(s,&props)) _compress_error_return("Lzma2Enc_SetProps()");
#       if (IS_NOTICE_compress_canceled)
        printf("  (used one lzma2 dictSize: %" PRIu64 "  (input data: %" PRIu64 "))\n",
               (hpatch_StreamPos_t)props.lzmaProps.dictSize,in_data->streamSize);
#       endif
        
        //save properties_size+properties
        assert(LZMA_PROPS_SIZE<256);
        properties_size=Lzma2Enc_WriteProperties(s);
        
        if (1!=__lzma_SeqOutStream_Write(&outStream.base,&properties_size,1))
            _compress_error_return("out_code->write()");
        
        ret=Lzma2Enc_Encode2(s,&outStream.base,0,0,&inStream.base,0,0,0);
        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("Lzma2Enc_Encode2()");
        }
    clear:
#if (!IS_REUSE_compress_handle)
        if (s) { Lzma2Enc_Destroy(s); s=0; }
#endif
        _check_compress_result(result,outStream.isCanceled,"_lzma2_compress()",errAt);
        return result;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x100a(%rip), %rax      # 0x7820
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
leaq 0x1088(%rip), %rax      # 0x78c0
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
leaq 0xa5bec(%rip), %rax     # 0xac447
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movb $0x0, -0xd1(%rbp)
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0xdc(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x6895
leaq 0xdfcbf(%rip), %rsi     # 0xe6548
movq %rsi, %rdi
callq 0x65c00
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x68c5
jmp 0x689e
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x68c0
leaq 0xa6648(%rip), %rax     # 0xacf04
movq %rax, -0x68(%rbp)
jmp 0x6aa3
leaq -0xd0(%rbp), %rdi
callq 0x658b0
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0xd0(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x78(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x65900
movq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x65ea0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x695b
jmp 0x6934
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x6956
leaq 0xa65c3(%rip), %rax     # 0xacf15
movq %rax, -0x68(%rbp)
jmp 0x6aa3
movl -0xcc(%rbp), %eax
movl %eax, %esi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xa65b7(%rip), %rdi     # 0xacf29
movb $0x0, %al
callq 0x4060
movq -0x70(%rbp), %rdi
callq 0x65f40
movb %al, -0xd1(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xd1(%rbp), %rsi
movl $0x1, %edx
callq 0x7820
movq %rax, %rcx
movl $0x1, %eax
cmpq %rcx, %rax
je 0x69d3
jmp 0x69ac
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x69ce
leaq 0xa609f(%rip), %rax     # 0xaca69
movq %rax, -0x68(%rbp)
jmp 0x6aa3
movq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rdx
movq %r9, %rcx
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x65fa0
movl %eax, -0xd8(%rbp)
xorl %eax, %eax
cmpl -0xd8(%rbp), %eax
jne 0x6a1d
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x6aa1
cmpl $0x8, -0xd8(%rbp)
jne 0x6a4c
jmp 0x6a28
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x6a4a
leaq 0xa6035(%rip), %rax     # 0xaca7b
movq %rax, -0x68(%rbp)
jmp 0x6aa3
cmpl $0x9, -0xd8(%rbp)
jne 0x6a7b
jmp 0x6a57
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x6a79
leaq 0xa5ff4(%rip), %rax     # 0xaca69
movq %rax, -0x68(%rbp)
jmp 0x6aa3
jmp 0x6a7d
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x6a9f
leaq 0xa64c5(%rip), %rax     # 0xacf60
movq %rax, -0x68(%rbp)
jmp 0x6aa3
jmp 0x6aa3
cmpq $0x0, -0x70(%rbp)
je 0x6abb
movq -0x70(%rbp), %rdi
callq 0x65d20
movq $0x0, -0x70(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x6aec
cmpl $0x0, -0x28(%rbp)
je 0x6ad8
leaq 0xa64a4(%rip), %rdi     # 0xacf73
movb $0x0, %al
callq 0x4060
jmp 0x6aea
movq -0x68(%rbp), %rsi
leaq 0xa64c5(%rip), %rdi     # 0xacfa8
movb $0x0, %al
callq 0x4060
jmp 0x6aec
movq -0x60(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)