// File: /workspace/github_c_makefile_star2_O0/ijleesw[P]data-compression/src/lz78/lz78.c
// Function: compress_byte
void compress_byte(lz78_c* o, int c_in) {
    /* Optimization pointers */
    ht_dictionary* d_main = o->main;
    ht_dictionary* d_sec = o->secondary;

    switch(d_main->cur_node) {
    case DICT_CODE_START:
            o->bitbuf = d_main->d_size;
            o->n_bits = bitlen(DICT_SIZE_MAX);
            d_main->cur_node = -1;
            break;
    case DICT_CODE_EOF:
            o->bitbuf = d_main->cur_node;
            o->n_bits = bitlen(d_main->d_next);
            d_main->cur_node = DICT_CODE_STOP;
            return;
        case DICT_CODE_STOP:
            o->completed = 1;
            return;
    default:
            break;
    }

    c_in = c_in == EOF ? DICT_CODE_EOF : c_in;
    /* Dictonaries update */
    if (ht_dictionary_update(d_main, c_in) != 0) {
        if (d_main->d_next >= d_main->d_thr)
            ht_dictionary_update(d_sec, c_in);
        return;
    }

    o->bitbuf = d_main->prev_node;
    o->n_bits = bitlen(d_main->d_next - 1);

    /* Dictonaries swap */
    if (d_main->d_next == d_main->d_size) {
        o->main = o->secondary;
        o->secondary = d_main;
        d_main = d_sec;
        d_sec = o->secondary;
        d_main->cur_node = c_in;
        ht_dictionary_reset(d_sec);
    }
    /* Update of secondary if threshold is reached */
    if (d_main->d_next >= d_main->d_thr)
        ht_dictionary_update(d_sec, c_in);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
subl $0x100, %eax            # imm = 0x100
je 0x22cb
jmp 0x227e
movl 0x4(%rsp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x2298
jmp 0x228b
movl 0x4(%rsp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x2304
jmp 0x2311
movq 0x10(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x18(%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x1ba0
movzbl %al, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x10(%rsp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
jmp 0x2313
movq 0x10(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x10(%rsp), %rax
movl 0x18(%rax), %edi
callq 0x1ba0
movzbl %al, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x10(%rsp), %rax
movl $0x103, 0x8(%rax)       # imm = 0x103
jmp 0x241e
movq 0x20(%rsp), %rax
movb $0x1, (%rax)
jmp 0x241e
jmp 0x2313
cmpl $-0x1, 0x1c(%rsp)
jne 0x2324
movl $0x100, %eax            # imm = 0x100
movl %eax, (%rsp)
jmp 0x232b
movl 0x1c(%rsp), %eax
movl %eax, (%rsp)
movl (%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %eax
movzwl %ax, %esi
callq 0x1cd0
cmpl $0x0, %eax
je 0x2370
movq 0x10(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jb 0x236b
movq 0x8(%rsp), %rdi
movl 0x1c(%rsp), %eax
movzwl %ax, %esi
callq 0x1cd0
jmp 0x241e
movq 0x10(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x10(%rsp), %rax
movl 0x18(%rax), %edi
subl $0x1, %edi
callq 0x1ba0
movzbl %al, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x10(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x23fb
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movl 0x1c(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x8(%rsp), %rdi
callq 0x1ee0
movq 0x10(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jb 0x241e
movq 0x8(%rsp), %rdi
movl 0x1c(%rsp), %eax
movzwl %ax, %esi
callq 0x1cd0
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)