// File: /workspace/github_c_makefile_star2_O1/dolphinking[P]slimox/src/slimox-ppm.h
// Function: _ppm_see_context_o4
static inline see_model_t* __ppm_see_context_o4(ppm_model_t* model, o4_context_t* o4) {
    int curcnt = o4->m_cnt;
    int lowsum = __o2(model)->m_sum;
    int lowcnt = __o2(model)->m_cnt;
    uint32_t context = 0;

    if(curcnt == 0) return &model->m_see_01; /* no symbols under current context -- always escape */
    if(curcnt == 1) {
        /* QUANTIZE(binary) = (last_esc[1] | sum[3] | lowcnt[2] | lowsum[1] | bin_symbol[3] | previous symbols[6]) */
        context |= ((model->m_context >>  6) & 0x03);
        context |= ((model->m_context >> 14) & 0x03) << 2;
        context |= ((model->m_context >> 22) & 0x03) << 4;
        context |= (__context_sym(o4, 0) >> 6) << 6;
        context |= (lowsum >= 4) << 9;
        context |= min2(__fast_log2(lowcnt / 2), 3) << 10;
        context |= min2(__fast_log2(o4->m_sum / 3), 7) << 12;
        context |= model->m_sse_last_esc << 15;
        context |= 1 << 16;
        return &model->m_see[context];
    } else {
        /* QUANTIZE = (last_esc[1] | sum[3] | curcnt[2] | lowsum[1] | (lowcnt - curcnt)[3] | previous symbols[6]) */
        context |= ((model->m_context >>  6) & 0x03);
        context |= ((model->m_context >> 14) & 0x03) << 2;
        context |= ((model->m_context >> 22) & 0x03) << 4;
        context |= min2(__fast_log2(max2(lowcnt - curcnt, 0) / 2), 3) << 6;
        context |= (lowsum >= 4) << 9;
        context |= min2(__fast_log2(curcnt / 2), 3) << 10;
        context |= min2(__fast_log2(o4->m_sum / 8), 7) << 12;
        context |= model->m_sse_last_esc << 15;
        context |= 0 << 16;
        return &model->m_see[context];
    }
    return NULL;
}

// Assembly:
movq %rdi, %rax
movzbl 0xe(%rsi), %edx
movl (%rdi), %ecx
movzwl %cx, %edi
movq 0x200010(%rax,%rdi,8), %r8
movzwl (%r8), %edi
movzwl 0x2(%r8), %r8d
cmpl $0x1, %edx
je 0x6a2e
testl %edx, %edx
jne 0x6ad0
addq $0x32082a, %rax         # imm = 0x32082A
retq
movl %ecx, %r9d
shrl $0x6, %r9d
andl $0x3, %r9d
movl %ecx, %edx
shrl $0xc, %edx
andl $0xc, %edx
shrl $0x12, %ecx
andl $0x30, %ecx
movzbl 0x10(%rsi), %r10d
andl $-0x40, %r10d
xorl %r11d, %r11d
cmpw $0x4, %di
setae %r11b
shll $0x9, %r11d
orl $0x1, %r8d
bsrl %r8d, %edi
movl %edi, %r8d
shll $0xa, %r8d
cmpl $0x4, %edi
movl $0xc00, %edi            # imm = 0xC00
cmovbl %r8d, %edi
movzwl 0xc(%rsi), %esi
imull $0xaaab, %esi, %esi     # imm = 0xAAAB
shrl $0x10, %esi
orl $0x1, %esi
bsrl %esi, %esi
movl %esi, %r8d
shll $0xc, %r8d
cmpl $0x8, %esi
movl $0x7000, %esi           # imm = 0x7000
cmovbl %r8d, %esi
movzbl 0x2a0829(%rax), %r8d
shll $0xf, %r8d
orl %esi, %r8d
orl %r9d, %edx
orl %ecx, %edx
orl %r11d, %edx
orl %edi, %edx
orl %r10d, %edx
orl %r8d, %edx
orl $0x10000, %edx          # imm = 0x10000
leaq (%rax,%rdx,4), %rax
addq $0x2a082a, %rax         # imm = 0x2A082A
retq
movl %ecx, %r9d
shrl $0x6, %r9d
andl $0x3, %r9d
movl %ecx, %r10d
shrl $0xc, %r10d
andl $0xc, %r10d
orl %r9d, %r10d
shrl $0x12, %ecx
andl $0x30, %ecx
orl %r10d, %ecx
subl %edx, %r8d
xorl %r9d, %r9d
testl %r8d, %r8d
cmovgl %r8d, %r9d
orl $0x1, %r9d
bsrl %r9d, %r8d
movl %r8d, %r9d
shll $0x6, %r9d
cmpl $0x4, %r8d
movl $0xc0, %r8d
cmovbl %r9d, %r8d
xorl %r9d, %r9d
cmpw $0x4, %di
setae %r9b
shll $0x9, %r9d
orl $0x1, %edx
bsrl %edx, %edx
movl %edx, %edi
shll $0xa, %edi
cmpl $0x4, %edx
movl $0xc00, %edx            # imm = 0xC00
cmovbl %edi, %edx
movzwl 0xc(%rsi), %esi
shrl $0x2, %esi
orl $0x1, %esi
bsrl %esi, %esi
movl %esi, %edi
shll $0xc, %edi
cmpl $0x8, %esi
movl $0x7000, %esi           # imm = 0x7000
cmovbl %edi, %esi
movzbl 0x2a0829(%rax), %edi
shll $0xf, %edi
orl %ecx, %r9d
orl %edx, %r9d
orl %edi, %r9d
orl %esi, %r9d
orl %r8d, %r9d
leaq (%rax,%r9,4), %rax
addq $0x2a082a, %rax         # imm = 0x2A082A
retq