// File: /workspace/github_c_makefile_star2_O0/MuvikLabs[P]runt/runt.c
// Function: runt_tokenize
runt_int runt_tokenize(runt_vm *vm,
        const char *str,
        runt_uint size,
        runt_uint *pos,
        runt_uint *wsize,
        runt_uint *next)
{
    runt_uint s;
    runt_uint p;
    runt_uint mode = 0;
    runt_uint stop = 0;
    char m = '"';
    *wsize = 0;

    *pos = *next;
    p = *pos;


    if(*pos > size) return RUNT_OK;

    if(*pos == size) {
        *next = size + 1;
        return RUNT_CONTINUE;
    }

    for(s = p; s < size; s++) {

        if(stop != 0) {
            break;
        }
        switch (mode) {
            case 3:
                if(str[s] == m) {
                    mode = 2;
                    *wsize = (s - *pos) + 1;
                }
                continue;
            case 2:
                if(str[s] != ' ' && str[s] != '\n') {
                    *next = s;
                    stop = 1;
                    break;
                }
                continue;
            case 1:
                if(str[s] == ' ' || str[s] == '\n') {
                    mode = 2;
                    *wsize = (s - *pos);
                }
                continue;
            case 0:
                if(str[s] == '#') return RUNT_OK;

                if(str[s] != ' ' && str[s] != '\n') {
                    if(str[s] == '\'' || str[s] == '\"') {
                        mode = 3;
                        m = str[s];
                    } else {
                        mode = 1;
                        *pos = s;
                    }
                }
                *pos = s;
                continue;
            default: break;
        }

    }
    /* if we are at the end, make next larger than the size */
    if(s == size) {
        if(mode == 1) {
            *wsize = (s - *pos);
        } if(mode == 2 && *next == size - 1) {
            return RUNT_CONTINUE;
        }
        *next = size + 1;
    }
    return RUNT_CONTINUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movb $0x22, -0x49(%rbp)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x3523
movl $0x1, -0x4(%rbp)
jmp 0x371e
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x3546
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x371e
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x36cf
cmpl $0x0, -0x48(%rbp)
je 0x3563
jmp 0x36cf
movl -0x44(%rbp), %eax
movq %rax, -0x58(%rbp)
subq $0x3, %rax
ja 0x36bd
movq -0x58(%rbp), %rax
leaq 0x5a85(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movsbl -0x49(%rbp), %ecx
cmpl %ecx, %eax
jne 0x35b4
movl $0x2, -0x44(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
subl (%rax), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x36c1
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x35ee
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x35ee
movl -0x3c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x48(%rbp)
jmp 0x36bf
jmp 0x36c1
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x3613
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x3629
movl $0x2, -0x44(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
subl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x36c1
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x23, %eax
jne 0x364a
movl $0x1, -0x4(%rbp)
jmp 0x371e
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x36b2
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x36b2
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
je 0x368a
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x36a0
movl $0x3, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
jmp 0x36b0
movl $0x1, -0x44(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x36b2
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x36c1
jmp 0x36bf
jmp 0x36c1
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x354c
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x3717
cmpl $0x1, -0x44(%rbp)
jne 0x36ec
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
subl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x2, -0x44(%rbp)
jne 0x370b
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x370b
movl $0x2, -0x4(%rbp)
jmp 0x371e
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)