// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: TBytesRle_load_stream_decode_add
static hpatch_BOOL _TBytesRle_load_stream_decode_add(_TBytesRle_load_stream* loader,
                                                     TByte* out_data,hpatch_size_t decodeSize){
    if (!_TBytesRle_load_stream_mem_add(loader,&decodeSize,&out_data))
        return _hpatch_FALSE;

    while ((decodeSize>0)&&(!_TStreamCacheClip_isFinish(&loader->ctrlClip))){
        enum TByteRleType type;
        hpatch_StreamPos_t length;
        const TByte* pType=_TStreamCacheClip_accessData(&loader->ctrlClip,1);
        if (pType==0) return _hpatch_FALSE;
        type=(enum TByteRleType)((*pType)>>(8-kByteRleType_bit));
        _clip_unpackUIntWithTagTo(&length,&loader->ctrlClip,kByteRleType_bit);
        ++length;
        switch (type){
            case kByteRleType_rle0:{
                loader->memSetLength=length;
                loader->memSetValue=0;
            }break;
            case kByteRleType_rle255:{
                loader->memSetLength=length;
                loader->memSetValue=255;
            }break;
            case kByteRleType_rle:{
                const TByte* pSetValue=_TStreamCacheClip_readData(&loader->rleCodeClip,1);
                if (pSetValue==0) return _hpatch_FALSE;
                loader->memSetValue=*pSetValue;
                loader->memSetLength=length;
            }break;
            case kByteRleType_unrle:{
                loader->memCopyLength=length;
            }break;
        }
        if (!_TBytesRle_load_stream_mem_add(loader,&decodeSize,&out_data)) return _hpatch_FALSE;
    }

    if (decodeSize==0)
        return hpatch_TRUE;
    else
        return _hpatch_FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x8c6d0
cmpl $0x0, %eax
jne 0x8c536
movl $0x0, -0x4(%rbp)
jmp 0x8c6c0
jmp 0x8c538
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x41(%rbp)
jbe 0x8c574
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
subq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rdx
subq 0x38(%rdx), %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x8c580
jmp 0x8c6a9
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movl $0x1, %esi
callq 0x86ac0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x8c5a9
movl $0x0, -0x4(%rbp)
jmp 0x8c6c0
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
sarl $0x6, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x30(%rbp), %rsi
movl $0x2, %edx
callq 0x86d00
cmpl $0x0, %eax
jne 0x8c5dd
movl $0x0, -0x4(%rbp)
jmp 0x8c6c0
movq -0x30(%rbp), %rax
incq %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movq %rax, -0x50(%rbp)
subq $0x3, %rax
ja 0x8c685
movq -0x50(%rbp), %rax
leaq 0x283bc(%rip), %rcx     # 0xb49c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x10(%rax)
jmp 0x8c685
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $-0x1, 0x10(%rax)
jmp 0x8c685
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movl $0x1, %esi
callq 0x86f90
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x8c65f
movl $0x0, -0x4(%rbp)
jmp 0x8c6c0
movq -0x40(%rbp), %rax
movb (%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x8c685
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x8c6d0
cmpl $0x0, %eax
jne 0x8c6a4
movl $0x0, -0x4(%rbp)
jmp 0x8c6c0
jmp 0x8c538
cmpq $0x0, -0x20(%rbp)
jne 0x8c6b9
movl $0x1, -0x4(%rbp)
jmp 0x8c6c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)