// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: bytesRle_load
static hpatch_BOOL _bytesRle_load(TByte* out_data,TByte* out_dataEnd,
                                  const TByte* rle_code,const TByte* rle_code_end){
    const TByte*    ctrlBuf,*ctrlBuf_end;
    hpatch_size_t ctrlSize;
    unpackUIntTo(&ctrlSize,&rle_code,rle_code_end);
#ifdef __RUN_MEM_SAFE_CHECK
    if (ctrlSize>(hpatch_size_t)(rle_code_end-rle_code)) return _hpatch_FALSE;
#endif
    ctrlBuf=rle_code;
    rle_code+=ctrlSize;
    ctrlBuf_end=rle_code;
    while (ctrlBuf_end-ctrlBuf>0){
        enum TByteRleType type=(enum TByteRleType)((*ctrlBuf)>>(8-kByteRleType_bit));
        hpatch_size_t length;
        unpackUIntWithTagTo(&length,&ctrlBuf,ctrlBuf_end,kByteRleType_bit);
#ifdef __RUN_MEM_SAFE_CHECK
        if (length>=(hpatch_size_t)(out_dataEnd-out_data)) return _hpatch_FALSE;
#endif
        ++length;
        switch (type){
            case kByteRleType_rle0:{
                memset(out_data,0,length);
                out_data+=length;
            }break;
            case kByteRleType_rle255:{
                memset(out_data,255,length);
                out_data+=length;
            }break;
            case kByteRleType_rle:{
#ifdef __RUN_MEM_SAFE_CHECK
                if (1>(hpatch_size_t)(rle_code_end-rle_code)) return _hpatch_FALSE;
#endif
                memset(out_data,*rle_code,length);
                ++rle_code;
                out_data+=length;
            }break;
            case kByteRleType_unrle:{
#ifdef __RUN_MEM_SAFE_CHECK
                if (length>(hpatch_size_t)(rle_code_end-rle_code)) return _hpatch_FALSE;
#endif
                memcpy(out_data,rle_code,length);
                rle_code+=length;
                out_data+=length;
            }break;
        }
    }
    
    if (  (ctrlBuf==ctrlBuf_end)
        &&(rle_code==rle_code_end)
        &&(out_data==out_dataEnd))
        return hpatch_TRUE;
    else
        return _hpatch_FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x863b0
cmpl $0x0, %eax
jne 0x8642c
movl $0x0, -0x4(%rbp)
jmp 0x86613
jmp 0x8642e
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x8644e
movl $0x0, -0x4(%rbp)
jmp 0x86613
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x0, %rax
jle 0x865e5
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
sarl $0x6, %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rdx
movl $0x2, %ecx
callq 0x863b0
cmpl $0x0, %eax
jne 0x864b3
movl $0x0, -0x4(%rbp)
jmp 0x86613
jmp 0x864b5
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jb 0x864d5
movl $0x0, -0x4(%rbp)
jmp 0x86613
movq -0x50(%rbp), %rax
incq %rax
movq %rax, -0x50(%rbp)
movl -0x44(%rbp), %eax
movq %rax, -0x58(%rbp)
subq $0x3, %rax
ja 0x865e0
movq -0x58(%rbp), %rax
leaq 0x2e4b4(%rip), %rcx     # 0xb49b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rdx
xorl %esi, %esi
callq 0x4210
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x865e0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0xff, %esi
callq 0x4210
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x865e0
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x1, %eax
cmpq %rcx, %rax
jbe 0x86569
movl $0x0, -0x4(%rbp)
jmp 0x86613
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
movq -0x50(%rbp), %rdx
movzbl %al, %esi
callq 0x4210
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x865e0
movq -0x50(%rbp), %rax
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x865b7
movl $0x0, -0x4(%rbp)
jmp 0x86613
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x4320
movq -0x50(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x8646a
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x8660c
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x8660c
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x8660c
movl $0x1, -0x4(%rbp)
jmp 0x86613
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)