// File: /workspace/github_c_makefile_star2_O3/dolphinking[P]slimox/src/slimox-ppm.h
// Function: _o4_context_node
static inline o4_context_t* __o4_context_node(ppm_model_t* model) {
    o4_context_t* o4;
    o4_context_t* o4_prev;
    int i;

    if(model->m_o4_counts >= 1048576) { /* too many o4-context/symbol nodes */
        model->m_o4_counts = 0;
        for(i = 0; i < 262144; i++) {
            while(model->m_o4_buckets[i] && model->m_o4_buckets[i]->m_visited / 2 == 0) {
                o4 = model->m_o4_buckets[i];
                model->m_o4_buckets[i] = model->m_o4_buckets[i]->m_next;
                allocator_free(model->m_o4_allocator, o4);
            }
            for(o4 = model->m_o4_buckets[i]; o4 != NULL; o4 = o4->m_next) {
                if((o4->m_visited /= 2) == 0) {
                    o4_prev->m_next = o4->m_next;
                    allocator_free(model->m_o4_allocator, o4);
                    o4 = o4_prev;
                } else {
                    model->m_o4_counts += 1;
                    o4_prev = o4;
                }
            }
        }
    }

    o4 = model->m_o4_buckets[__o4_hash(model->m_context)];
    o4_prev = NULL;
    while(o4 && o4->m_context != model->m_context) { /* search for o4 context */
        o4_prev = o4;
        o4 = o4->m_next;
    }
    if(o4 != NULL) { /* found -- bring to front of linked-list */
        if(o4_prev != NULL) {
            o4_prev->m_next = o4->m_next;
            o4->m_next = model->m_o4_buckets[__o4_hash(model->m_context)];
            model->m_o4_buckets[__o4_hash(model->m_context)] = o4;
        }
    } else { /* not found -- create new node for context */
        o4 = allocator_alloc(model->m_o4_allocator, sizeof(o4_context_t), 8192);
        memset(o4->m_symbols, 0, sizeof(o4->m_symbols));
        o4->m_context = model->m_context;
        o4->m_sum = 0;
        o4->m_cnt = 0;
        o4->m_visited = 0;
        o4->m_next = model->m_o4_buckets[__o4_hash(model->m_context)];
        model->m_o4_counts += 1;
        model->m_o4_buckets[__o4_hash(model->m_context)] = o4;
    }
    o4->m_visited += (o4->m_visited < 255);
    return o4;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x100000, 0x8(%rdi)    # imm = 0x100000
jb 0x6e21
movl $0x0, 0x8(%rbx)
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x10(%rbx,%rcx,8), %rsi
testq %rsi, %rsi
je 0x6e15
cmpb $0x2, 0xf(%rsi)
jae 0x6dd7
movq (%rsi), %rdi
movq %rdi, 0x10(%rbx,%rcx,8)
movq 0x2a0820(%rbx), %rdi
movq 0x8(%rdi), %r8
movq %r8, (%rsi)
movq %rsi, 0x8(%rdi)
jmp 0x6dab
movb 0xf(%rsi), %dil
movl %edi, %r8d
shrb %r8b
movb %r8b, 0xf(%rsi)
cmpb $0x1, %dil
ja 0x6e05
movq (%rsi), %rdi
movq %rdi, (%rdx)
movq 0x2a0820(%rbx), %rdi
movq 0x8(%rdi), %r8
movq %r8, (%rsi)
movq %rsi, 0x8(%rdi)
jmp 0x6e0d
incl %eax
movl %eax, 0x8(%rbx)
movq %rsi, %rdx
movq (%rdx), %rsi
testq %rsi, %rsi
jne 0x6dd7
incq %rcx
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x6dab
movl (%rbx), %ecx
movl %ecx, %eax
shrl $0xe, %eax
movl %ecx, %edx
andl $0x3ffff, %edx          # imm = 0x3FFFF
xorl %eax, %edx
leaq (%rbx,%rdx,8), %rax
addq $0x10, %rax
xorl %esi, %esi
movq %rax, %r14
movq (%r14), %r14
testq %r14, %r14
je 0x6e70
movq %rsi, %rdx
movq %r14, %rsi
cmpl %ecx, 0x8(%r14)
jne 0x6e3f
testq %rdx, %rdx
je 0x6f6e
movq (%r14), %rcx
movq %rcx, (%rdx)
movq (%rax), %rcx
movq %rcx, (%r14)
movq %r14, (%rax)
jmp 0x6f6e
movq 0x2a0820(%rbx), %r15
movq 0x8(%r15), %r14
testq %r14, %r14
jne 0x6f2d
movl $0x128008, %edi         # imm = 0x128008
callq 0x1180
movq %rax, %r14
movq (%r15), %rax
movq %rax, (%r14)
movq $0x0, 0x8(%r14)
leaq 0x9c(%r14), %rax
xorl %ecx, %ecx
movdqa 0x4170(%rip), %xmm0     # 0xb020
movdqa 0x4178(%rip), %xmm1     # 0xb030
movdqa 0x41f0(%rip), %xmm2     # 0xb0b0
pshufd $0xf5, %xmm2, %xmm3     # xmm3 = xmm2[1,1,3,3]
movq %rcx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm0, %xmm4
pxor %xmm1, %xmm4
movdqa %xmm2, %xmm5
pcmpgtd %xmm4, %xmm5
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pcmpeqd %xmm3, %xmm4
pand %xmm5, %xmm4
movd %xmm4, %edx
testb $0x1, %dl
je 0x6eff
leaq -0x94(%rax), %rdx
movq %rdx, (%rax)
pextrw $0x4, %xmm4, %edx
testb $0x1, %dl
je 0x6f10
movq %rax, 0x94(%rax)
addq $0x2, %rcx
addq $0x128, %rax            # imm = 0x128
cmpq $0x2000, %rcx           # imm = 0x2000
jne 0x6ec5
movq %r14, (%r15)
addq $0x127f74, %r14         # imm = 0x127F74
movq (%r14), %rax
movq %rax, 0x8(%r15)
leaq 0x10(%r14), %rdi
movl $0x84, %edx
xorl %esi, %esi
callq 0x10e0
movl (%rbx), %eax
movl %eax, 0x8(%r14)
movl $0x0, 0xc(%r14)
movl %eax, %ecx
shrl $0xe, %ecx
andl $0x3ffff, %eax          # imm = 0x3FFFF
xorl %ecx, %eax
movq 0x10(%rbx,%rax,8), %rcx
movq %rcx, (%r14)
incl 0x8(%rbx)
movq %r14, 0x10(%rbx,%rax,8)
movb 0xf(%r14), %al
cmpb $-0x1, %al
setne %cl
addb %al, %cl
movb %cl, 0xf(%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq