// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x19ea(%rip), %rax      # 0x7820
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
leaq 0x1a68(%rip), %rax      # 0x78c0
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
leaq 0xa65cc(%rip), %rax     # 0xac447
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x5, -0xc8(%rbp)
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0xd0(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x5eb6
leaq 0xe069b(%rip), %rdi     # 0xe6548
callq 0x679d0
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x5ee6
jmp 0x5ebf
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x5ee1
leaq 0xa7027(%rip), %rax     # 0xacf04
movq %rax, -0x68(%rbp)
jmp 0x610f
leaq -0xb8(%rbp), %rdi
callq 0x670d0
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0xb8(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0xb4(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x88(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x67180
movq -0x70(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x677f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x5f71
jmp 0x5f4a
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x5f6c
leaq 0xa7126(%rip), %rax     # 0xad08e
movq %rax, -0x68(%rbp)
jmp 0x610f
movl -0xb4(%rbp), %eax
movl %eax, %esi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xa7119(%rip), %rdi     # 0xad0a1
movb $0x0, %al
callq 0x4060
movq -0x70(%rbp), %rdi
leaq -0xbe(%rbp), %rsi
addq $0x1, %rsi
leaq -0xc8(%rbp), %rdx
callq 0x69700
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x5fdb
jmp 0x5fb4
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x5fd6
leaq 0xa7105(%rip), %rax     # 0xad0d7
movq %rax, -0x68(%rbp)
jmp 0x610f
movq -0xc8(%rbp), %rax
movb %al, -0xbe(%rbp)
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xbe(%rbp), %rsi
movq -0xc8(%rbp), %rdx
addq $0x1, %rdx
callq 0x7820
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
je 0x604d
jmp 0x6026
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x6048
leaq 0xa6a25(%rip), %rax     # 0xaca69
movq %rax, -0x68(%rbp)
jmp 0x610f
movq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
leaq 0xe04e4(%rip), %r9      # 0xe6548
movq %r9, %r8
callq 0x69550
movl %eax, -0xcc(%rbp)
xorl %eax, %eax
cmpl -0xcc(%rbp), %eax
jne 0x6089
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x610d
cmpl $0x8, -0xcc(%rbp)
jne 0x60b8
jmp 0x6094
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x60b6
leaq 0xa69c9(%rip), %rax     # 0xaca7b
movq %rax, -0x68(%rbp)
jmp 0x610f
cmpl $0x9, -0xcc(%rbp)
jne 0x60e7
jmp 0x60c3
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x60e5
leaq 0xa6988(%rip), %rax     # 0xaca69
movq %rax, -0x68(%rbp)
jmp 0x610f
jmp 0x60e9
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4180
cmpq $0x0, %rax
jne 0x610b
leaq 0xa6fea(%rip), %rax     # 0xad0f1
movq %rax, -0x68(%rbp)
jmp 0x610f
jmp 0x610f
cmpq $0x0, -0x70(%rbp)
je 0x6131
movq -0x70(%rbp), %rdi
leaq 0xe0427(%rip), %rdx     # 0xe6548
movq %rdx, %rsi
callq 0x67ac0
movq $0x0, -0x70(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x6162
cmpl $0x0, -0x28(%rbp)
je 0x614e
leaq 0xa6fbd(%rip), %rdi     # 0xad102
movb $0x0, %al
callq 0x4060
jmp 0x6160
movq -0x68(%rbp), %rsi
leaq 0xa6fdd(%rip), %rdi     # 0xad136
movb $0x0, %al
callq 0x4060
jmp 0x6162
movq -0x60(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nop