// File: /workspace/github_c_makefile_star2_O2/MuvikLabs[P]runt/runt.c
// Function: runt_compile
runt_int runt_compile(runt_vm *vm, const char *str)
{
    runt_uint size = strlen(str);
    runt_uint pos = 0;
    runt_uint word_size = 0;
    runt_uint next = 0;
    runt_stacklet *s;
    runt_cell *tmp;
    runt_entry *entry;
    runt_ptr ptr;
    runt_uint c, m;
    float val = 0.0;

    runt_int rc = RUNT_OK;

    while(runt_tokenize(vm, str, size, &pos, &word_size, &next) == RUNT_CONTINUE)
    {
        switch(runt_lex(vm, str, pos, word_size)) {
            case RUNT_FLOAT:

                val = runt_atof(str, pos, word_size);
                if(!(vm->status & RUNT_MODE_INTERACTIVE)) {
                    if(runt_cell_new(vm, &tmp) == 0) return RUNT_NOT_OK;
                    /* this needs to happen after runt_new_cell */
                    s = runt_push(vm);
                    s->f = val;
                    s->t = RUNT_FLOAT;
                    runt_copy_float(vm, vm->f_cell, tmp);
                } else {
                    s = runt_push(vm);
                    s->f = val;
                    s->t = RUNT_FLOAT;
                }

                break;
            case RUNT_HEX:
                val = hex2flt(vm, str, pos, word_size);
                if(!(vm->status & RUNT_MODE_INTERACTIVE)) {
                    if(runt_cell_new(vm, &tmp) == 0) return RUNT_NOT_OK;
                    /* this needs to happen after runt_new_cell */
                    s = runt_push(vm);
                    s->f = val;
                    runt_copy_float(vm, vm->f_cell, tmp);
                } else {
                    s = runt_push(vm);
                    s->f = val;
                }
                break;
            case RUNT_STRING:
                if(runt_cell_new(vm, &tmp) == 0) return RUNT_NOT_OK;
                s = runt_push(vm);
                ptr = runt_mk_string(vm, &str[pos + 1], word_size - 2);
                s->p = ptr;
                runt_copy_string(vm, vm->s_cell, tmp);
                if(vm->status & RUNT_MODE_INTERACTIVE) {
                    s = runt_push(vm);
                    s->p = ptr;
                    s->t = RUNT_STRING;
                }
                break;
            case RUNT_WORD:
                if(runt_word_search(vm,
                            &str[pos + 1],
                            word_size - 1,
                            &entry) == RUNT_NOT_OK) {
                    runt_print(vm, "Could not find word '%*.*s'\n",
                               word_size - 1,
                               word_size - 1,
                               &str[pos + 1]);
                    return RUNT_NOT_OK;
                }
                if(!(vm->status & RUNT_MODE_INTERACTIVE)) {
                    if(runt_cell_new(vm, &tmp) == 0) return RUNT_NOT_OK;
                    s = runt_push(vm);
                    if(entry->cell->id > 0) {
                        s->f = entry->cell->id;
                        runt_copy_float(vm, vm->f_cell, tmp);
                    } else {
                        s->p = runt_mk_cptr(vm, entry->cell);
                        runt_copy_cell(vm, tmp);
                    }
                } else {
                    s = runt_push(vm);
                    s->f = entry->cell->id;
                    s->p = runt_mk_cptr(vm, entry->cell);
                }

                break;
            case RUNT_PROC:
                if(vm->status & RUNT_MODE_KEYWORD) {

                    if(str[pos] == '@' && word_size == 1) {
                        s = runt_peak(vm);
                        tmp = runt_to_cell(s->p);
                        runt_cell_clear(vm, tmp);
                        runt_entry_create(vm, tmp, &entry);
                        vm->anon = entry;
                    } else {
                        rc = runt_word_search(vm, &str[pos], word_size, &entry);

                        s = runt_peak(vm);
                        tmp = runt_to_cell(s->p);

                        if(rc == RUNT_OK) {
                            runt_print(vm,
                                "Word '%*.*s' previously defined\n",
                                word_size, word_size, &str[pos]);

                            /* on failure, break to interactive mode */
                            runt_set_state(vm, RUNT_MODE_KEYWORD, RUNT_OFF);
                            runt_set_state(vm, RUNT_MODE_INTERACTIVE, RUNT_ON);
                            return RUNT_NOT_OK;
                        } else {
                            c = runt_cell_pool_used(vm);
                            m = runt_memory_pool_used(vm);
                            entry = NULL;
                            runt_cell_clear(vm, tmp);
                            runt_entry_create(vm, tmp, &entry);
                            runt_word(vm, &str[pos], word_size, entry);
                            runt_word_last_defined(vm, entry, c - 1, m);
                        }
                    }

                    runt_set_state(vm, RUNT_MODE_KEYWORD, RUNT_OFF);
                    break;
                }

                if(runt_word_search(vm, &str[pos], word_size, &entry) == RUNT_OK) {
                    if(vm->status & RUNT_MODE_INTERACTIVE) {
                        if(runt_entry_exec(vm, entry) == RUNT_NOT_OK) {
                            runt_print(vm, "Error with word '%*.*s'\n",
                                    word_size, word_size, &str[pos]);
                            return RUNT_NOT_OK;
                        }

                    } else {
                        if(runt_cell_new(vm, &tmp) == 0) return RUNT_NOT_OK;
                        runt_entry_copy(vm, entry, tmp);
                    }
                } else {
                    /*TODO: cleaner error reporting */
                    runt_print(vm, "Could not find function '%*.*s'\n",
                            word_size, word_size, str + pos);
                    return RUNT_NOT_OK;
                }
                break;

            case RUNT_NIL:
                break;
            default:
                runt_print(vm, "UNKOWN TYPE\n");
        }
    }
    return RUNT_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x1070
leaq 0x3c(%rsp), %rbx
andl $0x0, (%rbx)
leaq 0x38(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x44(%rsp), %rcx
andl $0x0, (%rcx)
movq %rax, 0x58(%rsp)
leaq 0x1168(%r14), %rax
movq %rax, 0x48(%rsp)
leaq 0x2(%r15), %rax
movq %rax, 0x50(%rsp)
pushq $0x1
popq %rbp
movq %r15, %rsi
movq 0x58(%rsp), %rdx
movq %rbx, %rcx
leaq 0x38(%rsp), %r8
leaq 0x44(%rsp), %r9
callq 0x21bc
cmpl $0x2, %eax
jne 0x2ad7
movl 0x3c(%rsp), %r12d
movl 0x38(%rsp), %r13d
movq %r15, %rsi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x2306
cmpl $0x8, %eax
ja 0x262c
movl %eax, %eax
leaq 0x3b64(%rip), %rcx      # 0x60c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x239a
testb $0x2, 0x1158(%r14)
movss %xmm0, 0x24(%rsp)
movq %r14, %rdi
jne 0x2866
leaq 0x28(%rsp), %rsi
callq 0x1821
testl %eax, %eax
je 0x2a73
movq %r14, %rdi
callq 0x1a2e
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movl $0x1, (%rax)
jmp 0x284d
incl %r12d
addq %r15, %r12
decl %r13d
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
leaq 0x30(%rsp), %rcx
callq 0x1f65
testl %eax, %eax
je 0x2a77
testb $0x2, 0x1158(%r14)
jne 0x2914
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1821
testl %eax, %eax
je 0x2a73
movq %r14, %rdi
callq 0x1a2e
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movl 0x24(%rcx), %edx
testl %edx, %edx
je 0x2a38
movl %edx, %ecx
cvtsi2ss %rcx, %xmm0
jmp 0x2848
movq %r14, %rdi
leaq 0x3caa(%rip), %rsi      # 0x62e0
xorl %eax, %eax
callq 0x18da
jmp 0x2513
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1821
testl %eax, %eax
je 0x2a73
movq %r14, %rdi
callq 0x1a2e
movl %ebp, %ebx
movq %rax, %rbp
incl %r12d
addq %r15, %r12
addl $-0x2, %r13d
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movl %r13d, %ecx
callq 0x1c3d
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rbp)
movups 0x60(%rsp), %xmm0
movups %xmm0, 0x8(%rbp)
movl %ebx, %ebp
leaq 0x3c(%rsp), %rbx
movq 0x1188(%r14), %r12
movq 0x28(%rsp), %r13
movq %r14, %rdi
callq 0x1a7a
movq (%r12), %rcx
movq %rcx, (%r13)
movq 0x18(%rax), %rcx
movq %rcx, 0x18(%r13)
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%r13)
testb $0x2, 0x1158(%r14)
je 0x2513
movq %r14, %rdi
callq 0x1a2e
movups 0x60(%rsp), %xmm0
movups %xmm0, 0x8(%rax)
movq 0x70(%rsp), %rcx
movq %rcx, 0x18(%rax)
movl $0x2, (%rax)
jmp 0x2513
addq %r15, %r12
testb $0x4, 0x1158(%r14)
jne 0x2881
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
leaq 0x30(%rsp), %rcx
callq 0x1f65
testl %eax, %eax
je 0x2a80
testb $0x2, 0x1158(%r14)
jne 0x2a1e
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1821
testl %eax, %eax
je 0x2a73
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rdx
movq (%rax), %rsi
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x2513
leal -0x2(%r13), %eax
shll $0x2, %r13d
addb $-0xc, %r13b
movl %ebp, %edx
movl %r13d, %ecx
shll %cl, %edx
addq 0x50(%rsp), %r12
xorps %xmm1, %xmm1
xorl %ecx, %ecx
leaq 0x3987(%rip), %r8       # 0x610c
cmpq %rcx, %rax
je 0x2811
movzbl (%r12,%rcx), %esi
leal -0x31(%rsi), %edi
cmpl $0x8, %edi
ja 0x27af
leaq 0x3946(%rip), %r9       # 0x60e8
movslq (%r9,%rdi,4), %rsi
addq %r9, %rsi
jmpq *%rsi
movl %ebp, %esi
jmp 0x27f7
addl $-0x61, %esi
cmpl $0x5, %esi
ja 0x280d
movslq (%r8,%rsi,4), %rsi
addq %r8, %rsi
jmpq *%rsi
pushq $0xa
jmp 0x27f6
pushq $0x5
jmp 0x27f6
pushq $0xe
jmp 0x27f6
pushq $0x3
jmp 0x27f6
pushq $0xc
jmp 0x27f6
pushq $0x4
jmp 0x27f6
pushq $0x8
jmp 0x27f6
pushq $0xd
jmp 0x27f6
pushq $0x2
jmp 0x27f6
pushq $0xb
jmp 0x27f6
pushq $0x6
jmp 0x27f6
pushq $0xf
jmp 0x27f6
pushq $0x7
jmp 0x27f6
pushq $0x9
popq %rsi
imull %edx, %esi
cvtsi2ss %esi, %xmm0
addss %xmm0, %xmm1
shrl $0x4, %edx
incq %rcx
jmp 0x2785
xorl %esi, %esi
jmp 0x27f7
movss %xmm1, 0x24(%rsp)
testb $0x2, 0x1158(%r14)
jne 0x28fc
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1821
testl %eax, %eax
je 0x2a73
movq %r14, %rdi
callq 0x1a2e
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movq 0x1180(%r14), %rsi
movq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x2ae8
jmp 0x2513
callq 0x1a2e
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movl $0x1, (%rax)
jmp 0x2513
cmpl $0x1, %r13d
jne 0x2941
cmpb $0x40, (%r12)
jne 0x2941
movq %r14, %rdi
callq 0x195f
movq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups 0x8(%rax), %xmm0
movups %xmm0, (%rsp)
callq 0x197a
movq %rax, 0x28(%rsp)
leaq -0x1535(%rip), %rcx     # 0x138b
movq %rcx, (%rax)
movq 0x48(%rsp), %rdx
movq 0x10(%rdx), %rcx
movq %rcx, 0x18(%rax)
movups (%rdx), %xmm0
movups %xmm0, 0x8(%rax)
andl $0x0, 0x20(%rax)
movq %r14, %rdi
movq %rax, %rsi
leaq 0x30(%rsp), %rdx
callq 0x1e00
movq 0x30(%rsp), %rax
movq %rax, 0x14a8(%r14)
jmp 0x2a11
movq %r14, %rdi
callq 0x1a2e
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
jmp 0x2513
movq %r14, %rdi
callq 0x1a2e
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movl 0x24(%rcx), %edx
cvtsi2ss %rdx, %xmm0
movss %xmm0, 0x20(%rax)
movl $0x3, 0x8(%rax)
movq %rcx, 0x10(%rax)
jmp 0x2513
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
leaq 0x30(%rsp), %rcx
callq 0x1f65
movl %eax, %ebp
movq %r14, %rdi
callq 0x195f
movq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups 0x8(%rax), %xmm0
movups %xmm0, (%rsp)
callq 0x197a
movq %rax, 0x28(%rsp)
testl %ebp, %ebp
jne 0x2a89
movl 0x51c(%r14), %ecx
movl %ecx, 0x40(%rsp)
movl 0x534(%r14), %ecx
movl %ecx, 0x24(%rsp)
andq $0x0, 0x30(%rsp)
leaq -0x1619(%rip), %rcx     # 0x138b
movq %rcx, (%rax)
movq 0x48(%rsp), %rcx
movups (%rcx), %xmm0
movups %xmm0, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x18(%rax)
andl $0x0, 0x20(%rax)
movq %r14, %rdi
movq %rax, %rsi
leaq 0x30(%rsp), %rdx
callq 0x1e00
movq 0x30(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
movq %rbp, %rcx
callq 0x1e63
movl 0x40(%rsp), %eax
decl %eax
movl %eax, 0x2c(%rbp)
movl 0x24(%rsp), %eax
movl %eax, 0x30(%rbp)
movq 0x11f0(%r14), %rax
movq %rax, 0x50(%rbp)
movq %rbp, 0x11f0(%r14)
incl 0x11f8(%r14)
pushq $0x1
popq %rbp
andb $-0x5, 0x1158(%r14)
jmp 0x2513
movq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x1e5b
testl %eax, %eax
jne 0x2513
jmp 0x2abb
movl $0x3, 0x8(%rax)
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %r12
movq %r14, %rdi
callq 0x1a7a
leaq 0xa0d(%rip), %rcx       # 0x3464
movq %rcx, (%r12)
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%r12)
movq 0x18(%rax), %rax
movq %rax, 0x18(%r12)
jmp 0x2513
xorl %ebp, %ebp
jmp 0x2ad7
leaq 0x37ea(%rip), %rsi      # 0x6268
jmp 0x2ac2
leaq 0x3838(%rip), %rsi      # 0x62bf
jmp 0x2ac2
leaq 0x37f5(%rip), %rsi      # 0x6285
xorl %ebp, %ebp
movq %r14, %rdi
movl %r13d, %edx
movl %r13d, %ecx
movq %r12, %r8
xorl %eax, %eax
callq 0x18da
movl 0x1158(%r14), %eax
andl $-0x7, %eax
orl $0x2, %eax
movl %eax, 0x1158(%r14)
jmp 0x2ad7
leaq 0x37e4(%rip), %rsi      # 0x62a6
xorl %ebp, %ebp
movq %r14, %rdi
movl %r13d, %edx
movl %r13d, %ecx
movq %r12, %r8
xorl %eax, %eax
callq 0x18da
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq