// File: /workspace/github_c_makefile_star2_O2/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:
movzbl 0xe(%rsi), %edx
movl (%rdi), %ecx
movzwl %cx, %eax
movq 0x200010(%rdi,%rax,8), %r8
movzwl (%r8), %eax
movzwl 0x2(%r8), %r10d
cmpl $0x1, %edx
je 0x4e5c
testl %edx, %edx
jne 0x4f09
addq $0x32082a, %rdi         # imm = 0x32082A
jmp 0x4fbb
pushq %rbx
movl %ecx, %r9d
shrl $0x6, %r9d
andl $0x3, %r9d
movl %ecx, %r8d
shrl $0xc, %r8d
andl $0xc, %r8d
shrl $0x12, %ecx
andl $0x30, %ecx
movzbl 0x10(%rsi), %r11d
andl $-0x40, %r11d
xorl %ebx, %ebx
cmpw $0x4, %ax
setae %bl
shll $0x9, %ebx
orl $0x1, %r10d
bsrl %r10d, %eax
movl %eax, %edx
shll $0xa, %edx
cmpl $0x4, %eax
movl $0xc00, %r10d           # imm = 0xC00
cmovbl %edx, %r10d
movzwl 0xc(%rsi), %eax
movw $0x3, %si
xorl %edx, %edx
divw %si
leal 0x1(,%rax,2), %eax
movzwl %ax, %eax
bsrl %eax, %eax
movl %eax, %edx
shll $0xc, %edx
cmpl $0x8, %eax
movl $0x7000, %eax           # imm = 0x7000
cmovbl %edx, %eax
movzbl 0x2a0829(%rdi), %edx
shll $0xf, %edx
orl %r9d, %r8d
orl %ecx, %r8d
orl %ebx, %r8d
orl %r10d, %r8d
orl %r11d, %r8d
orl %edx, %r8d
orl %eax, %r8d
orl $0x10000, %r8d          # imm = 0x10000
leaq (%rdi,%r8,4), %rdi
addq $0x2a082a, %rdi         # imm = 0x2A082A
popq %rbx
jmp 0x4fbb
movl %ecx, %r8d
shrl $0x6, %r8d
andl $0x3, %r8d
movl %ecx, %r9d
shrl $0xc, %r9d
andl $0xc, %r9d
orl %r8d, %r9d
shrl $0x12, %ecx
andl $0x30, %ecx
orl %r9d, %ecx
subl %edx, %r10d
xorl %r8d, %r8d
testl %r10d, %r10d
cmovgl %r10d, %r8d
orl $0x1, %r8d
bsrl %r8d, %r8d
movl %r8d, %r9d
shll $0x6, %r9d
cmpl $0x4, %r8d
movl $0xc0, %r8d
cmovbl %r9d, %r8d
xorl %r9d, %r9d
cmpw $0x4, %ax
setae %r9b
shll $0x9, %r9d
orl $0x1, %edx
bsrl %edx, %eax
movl %eax, %edx
shll $0xa, %edx
cmpl $0x4, %eax
movl $0xc00, %eax            # imm = 0xC00
cmovbl %edx, %eax
movzwl 0xc(%rsi), %edx
shrl $0x2, %edx
orl $0x1, %edx
bsrl %edx, %edx
movl %edx, %esi
shll $0xc, %esi
cmpl $0x8, %edx
movl $0x7000, %edx           # imm = 0x7000
cmovbl %esi, %edx
movzbl 0x2a0829(%rdi), %esi
shll $0xf, %esi
orl %ecx, %r9d
orl %eax, %r9d
orl %esi, %r9d
orl %edx, %r9d
orl %r8d, %r9d
leaq (%rdi,%r9,4), %rdi
addq $0x2a082a, %rdi         # imm = 0x2A082A
movq %rdi, %rax
retq