// File: /workspace/github_cpp_makefile_star2_O3/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
je 0x473e0
cmpq %r13, %rax
movq %r13, %rcx
cmovbq %rax, %rcx
testq %rbp, %rbp
je 0x473d4
movb 0x10(%r15), %r8b
testb %r8b, %r8b
sete %r9b
testq %r13, %r13
sete %dil
orb %r9b, %dil
jne 0x473cf
xorl %edi, %edi
addb %r8b, (%rbp,%rdi)
incq %rdi
cmpq %rdi, %rcx
jne 0x473c2
addq %rcx, %rbp
jmp 0x473d6
xorl %ebp, %ebp
subq %rcx, %r13
subq %rcx, %rax
movq %rax, 0x8(%r15)
movq (%r15), %rax
testq %rax, %rax
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
je 0x47490
testq %r13, %r13
je 0x47490
leaq 0x48(%r15), %r12
movq 0x70(%r15), %r14
cmpq %rax, %r14
cmovbq %r14, %rax
cmpq %r13, %rax
movq %rax, %rbx
cmovaeq %r13, %rbx
movq 0x68(%r15), %rcx
movq %r14, %rax
subq %rcx, %rax
cmpq %rbx, %rax
jae 0x47443
movq %r12, %rdi
callq 0x43e2c
movq 0x68(%r15), %rcx
testl %eax, %eax
je 0x474a7
movq 0x70(%r15), %rax
subq %rcx, %rax
cmpq %rbx, %rax
jb 0x474a7
movq 0x60(%r15), %rax
leaq (%rcx,%rbx), %rdx
movq %rdx, 0x68(%r15)
testq %rax, %rax
je 0x474ae
testq %rbp, %rbp
je 0x47477
testq %r14, %r14
je 0x47472
addq %rcx, %rax
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
addb %dl, (%rbp,%rcx)
incq %rcx
cmpq %rcx, %rbx
jne 0x47463
addq %rbx, %rbp
jmp 0x47479
xorl %ebp, %ebp
subq %rbx, %r13
movq (%r15), %rax
subq %rbx, %rax
movq %rax, (%r15)
je 0x47490
testq %r13, %r13
jne 0x47403
movq 0x8(%rsp), %rax
movq %r13, (%rax)
movq 0x10(%rsp), %rax
movq %rbp, (%rax)
movl $0x1, %eax
jmp 0x474b0
addq %rbx, %rcx
movq %rcx, 0x68(%r15)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq