// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: TBytesRle_load_stream_mem_add
static hpatch_BOOL _TBytesRle_load_stream_mem_add(_TBytesRle_load_stream* loader,
                                                  hpatch_size_t* _decodeSize,TByte** _out_data){
    hpatch_size_t  decodeSize=*_decodeSize;
    TByte* out_data=*_out_data;
    TStreamCacheClip* rleCodeClip=&loader->rleCodeClip;
    
    hpatch_StreamPos_t memSetLength=loader->memSetLength;
    if (memSetLength!=0){
        hpatch_size_t memSetStep=((memSetLength<=decodeSize)?(hpatch_size_t)memSetLength:decodeSize);
        const TByte byteSetValue=loader->memSetValue;
        if (out_data!=0){
            if (byteSetValue!=0)
                memSet_add(out_data,byteSetValue,memSetStep);
            out_data+=memSetStep;
        }
        decodeSize-=memSetStep;
        loader->memSetLength=memSetLength-memSetStep;
    }
    while ((loader->memCopyLength>0)&&(decodeSize>0)) {
        TByte* rleData;
        hpatch_size_t decodeStep=rleCodeClip->cacheEnd;
        if (decodeStep>loader->memCopyLength)
            decodeStep=(hpatch_size_t)loader->memCopyLength;
        if (decodeStep>decodeSize)
            decodeStep=decodeSize;
        rleData=_TStreamCacheClip_readData(rleCodeClip,decodeStep);
        if (rleData==0) return _hpatch_FALSE;
        if (out_data){
            addData(out_data,rleData,decodeStep);
            out_data+=decodeStep;
        }
        decodeSize-=decodeStep;
        loader->memCopyLength-=decodeStep;
    }
    *_decodeSize=decodeSize;
    *_out_data=out_data;
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq (%rsi), %r13
movq (%rdx), %rbp
movq 0x8(%rdi), %rax
testq %rax, %rax
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
je 0x4808d
cmpq %r13, %rax
movq %r13, %rcx
cmovbq %rax, %rcx
testq %rbp, %rbp
je 0x48081
movb 0x10(%r15), %r8b
testb %r8b, %r8b
sete %r9b
testq %r13, %r13
sete %dil
orb %r9b, %dil
jne 0x4807c
xorl %edi, %edi
addb %r8b, (%rbp,%rdi)
incq %rdi
cmpq %rdi, %rcx
jne 0x4806f
addq %rcx, %rbp
jmp 0x48083
xorl %ebp, %ebp
subq %rcx, %r13
subq %rcx, %rax
movq %rax, 0x8(%r15)
leaq 0x48(%r15), %r12
movq (%r15), %rbx
testq %rbx, %rbx
je 0x48127
testq %r13, %r13
je 0x48127
movq 0x70(%r15), %r14
cmpq %rbx, %r14
cmovbq %r14, %rbx
cmpq %r13, %rbx
cmovaeq %r13, %rbx
movq %r14, %rax
subq 0x68(%r15), %rax
cmpq %rbx, %rax
jae 0x480e1
movq %r12, %rdi
callq 0x445b4
testl %eax, %eax
je 0x480dd
movq 0x70(%r15), %rax
subq 0x68(%r15), %rax
cmpq %rbx, %rax
jae 0x480e1
xorl %eax, %eax
jmp 0x480e9
movq 0x60(%r15), %rax
addq 0x68(%r15), %rax
addq %rbx, 0x68(%r15)
testq %rax, %rax
je 0x4811a
testq %rbp, %rbp
je 0x48112
testq %r14, %r14
je 0x4810d
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
addb %dl, (%rbp,%rcx)
incq %rcx
cmpq %rcx, %rbx
jne 0x480fe
addq %rbx, %rbp
jmp 0x48114
xorl %ebp, %ebp
subq %rbx, %r13
subq %rbx, (%r15)
testq %rax, %rax
jne 0x48091
xorl %eax, %eax
jmp 0x4813c
movq 0x8(%rsp), %rax
movq %r13, (%rax)
movq 0x10(%rsp), %rax
movq %rbp, (%rax)
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq