// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp
// Function: hdiff_private::TCompressDetect::_add_rle(unsigned char const*, unsigned long)
void TCompressDetect::_add_rle(const unsigned char* d,size_t n){
    if (m_lastChar<0){
        if (n==0) return;
        m_lastChar=d[0];
        ++m_table->sum1char[m_lastChar];
        ++d;
        --n;
    }
    for (size_t i=0;i<n;++i) {
        unsigned char cur=d[i];
        ++m_table->sum1char[cur];
        ++m_table->sum2char[m_lastChar*256+cur];
        m_lastChar=cur;
        
        if (m_table->sum==kCacheSize){
            --m_table->sum;
            unsigned char pop=m_table->cache[m_cacheBegin++];
            if (m_cacheBegin==kCacheSize) m_cacheBegin=0;
            --m_table->sum1char[pop];
            if (m_lastPopChar>=0){
                --m_table->sum2char[m_lastPopChar*256+pop];
            }
            m_lastPopChar=pop;
        }
        ++m_table->sum;
        m_table->cache[m_cacheEnd++]=cur;
        if (m_cacheEnd==kCacheSize) m_cacheEnd=0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, 0x20(%rax)
jge 0x3d9f3
cmpq $0x0, -0x18(%rbp)
jne 0x3d9ba
jmp 0x3db50
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, 0x20(%rcx)
movq 0x18(%rcx), %rax
movslq 0x20(%rcx), %rcx
movl 0x4(%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, 0x4(%rax,%rcx,4)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x3db50
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rdx
movb (%rcx,%rdx), %cl
movb %cl, -0x21(%rbp)
movq 0x18(%rax), %rcx
movzbl -0x21(%rbp), %edx
movl 0x4(%rcx,%rdx,4), %esi
addl $0x1, %esi
movl %esi, 0x4(%rcx,%rdx,4)
movq 0x18(%rax), %rcx
movl 0x20(%rax), %edx
shll $0x8, %edx
movzbl -0x21(%rbp), %esi
addl %esi, %edx
movslq %edx, %rdx
movl 0x404(%rcx,%rdx,4), %esi
addl $0x1, %esi
movl %esi, 0x404(%rcx,%rdx,4)
movzbl -0x21(%rbp), %ecx
movl %ecx, 0x20(%rax)
movq 0x18(%rax), %rax
movl (%rax), %eax
cmpq $0x80000, %rax          # imm = 0x80000
jne 0x3dafb
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movl (%rcx), %edx
addl $-0x1, %edx
movl %edx, (%rcx)
movq 0x18(%rax), %rcx
movl 0x28(%rax), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, 0x28(%rax)
movl %edx, %edx
movb 0x40404(%rcx,%rdx), %cl
movb %cl, -0x22(%rbp)
movl 0x28(%rax), %eax
cmpq $0x80000, %rax          # imm = 0x80000
jne 0x3daab
movq -0x30(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movzbl -0x22(%rbp), %edx
movl 0x4(%rcx,%rdx,4), %esi
addl $-0x1, %esi
movl %esi, 0x4(%rcx,%rdx,4)
cmpl $0x0, 0x24(%rax)
jl 0x3daf0
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %rax
movl 0x24(%rcx), %ecx
shll $0x8, %ecx
movzbl -0x22(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movl 0x404(%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, 0x404(%rax,%rcx,4)
movq -0x30(%rbp), %rax
movzbl -0x22(%rbp), %ecx
movl %ecx, 0x24(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movl (%rcx), %edx
addl $0x1, %edx
movl %edx, (%rcx)
movb -0x21(%rbp), %sil
movq 0x18(%rax), %rcx
movl 0x2c(%rax), %edx
movl %edx, %edi
addl $0x1, %edi
movl %edi, 0x2c(%rax)
movl %edx, %edx
movb %sil, 0x40404(%rcx,%rdx)
movl 0x2c(%rax), %eax
cmpq $0x80000, %rax          # imm = 0x80000
jne 0x3db3d
movq -0x30(%rbp), %rax
movl $0x0, 0x2c(%rax)
jmp 0x3db3f
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x3d9fb
popq %rbp
retq
nopw %cs:(%rax,%rax)