// File: /workspace/github_c_makefile_star2_O1/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 0x68fc
movl $0x0, 0x8(%rbx)
xorl %eax, %eax
movq 0x10(%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x68af
cmpb $0x1, 0xf(%rdx)
ja 0x68af
movq (%rdx), %rsi
movq %rsi, 0x10(%rbx,%rax,8)
movq 0x2a0820(%rbx), %rsi
movq 0x8(%rsi), %rdi
movq %rdi, (%rdx)
movq %rdx, 0x8(%rsi)
jmp 0x6883
movq 0x10(%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x68f1
movb 0xf(%rdx), %sil
movl %esi, %edi
shrb %dil
movb %dil, 0xf(%rdx)
cmpb $0x1, %sil
ja 0x68e6
movq (%rdx), %rsi
movq %rsi, (%rcx)
movq 0x2a0820(%rbx), %rsi
movq 0x8(%rsi), %rdi
movq %rdi, (%rdx)
movq %rdx, 0x8(%rsi)
jmp 0x68ec
incl 0x8(%rbx)
movq %rdx, %rcx
movq (%rcx), %rdx
jmp 0x68b4
incq %rax
cmpq $0x40000, %rax          # imm = 0x40000
jne 0x6883
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 0x694b
movq %rsi, %rdx
movq %r14, %rsi
cmpl %ecx, 0x8(%r14)
jne 0x691a
testq %rdx, %rdx
je 0x69e5
movq (%r14), %rcx
movq %rcx, (%rdx)
movq (%rax), %rcx
movq %rcx, (%r14)
movq %r14, (%rax)
jmp 0x69e5
movq 0x2a0820(%rbx), %r15
cmpq $0x0, 0x8(%r15)
jne 0x69a0
movl $0x128008, %edi         # imm = 0x128008
callq 0x1190
movq (%r15), %rcx
movq %rcx, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
xorl %edx, %edx
leaq (%rcx,%rdx), %rsi
movq %rsi, 0x9c(%rax,%rdx)
addq $0x94, %rdx
cmpq $0x127f6c, %rdx         # imm = 0x127F6C
jne 0x6977
movq %rax, (%r15)
addq $0x127f74, %rax         # imm = 0x127F74
movq %rax, 0x8(%r15)
movq 0x8(%r15), %r14
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