// File: /workspace/github_c_makefile_star2_O3/codeplea[P]tinyexpr/tinyexpr.c
// Function: next_token
void next_token(state *s) {
    s->type = TOK_NULL;

    do {

        if (!*s->next){
            s->type = TOK_END;
            return;
        }

        /* Try reading a number. */
        if ((s->next[0] >= '0' && s->next[0] <= '9') || s->next[0] == '.') {
            s->value = strtod(s->next, (char**)&s->next);
            s->type = TOK_NUMBER;
        } else {
            /* Look for a variable or builtin function call. */
            if (isalpha(s->next[0])) {
                const char *start;
                start = s->next;
                while (isalpha(s->next[0]) || isdigit(s->next[0]) || (s->next[0] == '_')) s->next++;
                
                const te_variable *var = find_lookup(s, start, s->next - start);
                if (!var) var = find_builtin(start, s->next - start);

                if (!var) {
                    s->type = TOK_ERROR;
                } else {
                    switch(TYPE_MASK(var->type))
                    {
                        case TE_VARIABLE:
                            s->type = TOK_VARIABLE;
                            s->bound = var->address;
                            break;

                        case TE_CLOSURE0: case TE_CLOSURE1: case TE_CLOSURE2: case TE_CLOSURE3:         /* Falls through. */
                        case TE_CLOSURE4: case TE_CLOSURE5: case TE_CLOSURE6: case TE_CLOSURE7:         /* Falls through. */
                            s->context = var->context;                                                  /* Falls through. */

                        case TE_FUNCTION0: case TE_FUNCTION1: case TE_FUNCTION2: case TE_FUNCTION3:     /* Falls through. */
                        case TE_FUNCTION4: case TE_FUNCTION5: case TE_FUNCTION6: case TE_FUNCTION7:     /* Falls through. */
                            s->type = var->type;
                            s->function = var->address;
                            break;
                    }
                }

            } else {
                /* Look for an operator or special character. */
                switch (s->next++[0]) {
                    case '+': s->type = TOK_INFIX; s->function = add; break;
                    case '-': s->type = TOK_INFIX; s->function = sub; break;
                    case '*': s->type = TOK_INFIX; s->function = mul; break;
                    case '/': s->type = TOK_INFIX; s->function = divide; break;
                    case '^': s->type = TOK_INFIX; s->function = pow; break;
                    case '%': s->type = TOK_INFIX; s->function = fmod; break;
                    case '(': s->type = TOK_OPEN; break;
                    case ')': s->type = TOK_CLOSE; break;
                    case ',': s->type = TOK_SEP; break;
                    case ' ': case '\t': case '\n': case '\r': break;
                    default: s->type = TOK_ERROR; break;
                }
            }
        }
    } while (s->type == TOK_NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movl $0x18, 0x10(%rdi)
movq 0x8(%rdi), %rax
movq %rax, 0x8(%rsp)
movb (%rax), %bl
testb %bl, %bl
je 0x6565
leaq 0x8(%r15), %r13
movabsq $0x100000000, %rbp      # imm = 0x100000000
movq %r15, 0x10(%rsp)
movq %r13, 0x18(%rsp)
cmpb $0x2e, %bl
je 0x657c
leal -0x30(%rbx), %eax
cmpb $0x9, %al
jbe 0x657c
callq 0x31c0
movq (%rax), %rcx
movsbq %bl, %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0x63e6
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rsi
movq %rsi, (%r13)
movzbl (%rax), %eax
cmpl $0xc, %eax
jle 0x64c5
leal -0x20(%rax), %ecx
cmpl $0xf, %ecx
ja 0x652c
leaq 0x2583(%rip), %rdx      # 0x8960
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rsi
xorl %r12d, %r12d
addq %rbp, %r12
movq %rsi, (%r13)
movsbq (%rsi), %rcx
incq %rsi
cmpq $0x5f, %rcx
je 0x63f2
movq (%rax), %rdx
movzwl (%rdx,%rcx,2), %ecx
andl $0xc00, %ecx            # imm = 0xC00
jne 0x63f2
movq %rsi, 0x20(%rsp)
movq 0x28(%r15), %r14
testq %r14, %r14
je 0x645d
movl 0x30(%r15), %ebx
testl %ebx, %ebx
je 0x645d
movq %r12, %r13
sarq $0x20, %r13
movq (%r14), %rbp
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x3050
testl %eax, %eax
jne 0x6455
cmpb $0x0, (%rbp,%r13)
je 0x64e1
addq $0x20, %r14
decl %ebx
jne 0x6432
sarq $0x20, %r12
xorl %r15d, %r15d
movl $0x17, %ebx
movl %ebx, %eax
subl %r15d, %eax
movl %eax, %ebp
shrl $0x1f, %ebp
addl %eax, %ebp
sarl %ebp
addl %r15d, %ebp
movslq %ebp, %r14
shlq $0x5, %r14
leaq 0x5628(%rip), %rax      # 0xbab0
movq (%r14,%rax), %r13
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3050
testl %eax, %eax
jne 0x64ac
movsbl (%r13,%r12), %eax
testl %eax, %eax
je 0x64d2
negl %eax
testl %eax, %eax
jg 0x64b6
decl %ebp
movl %ebp, %ebx
jmp 0x64bb
incl %ebp
movl %ebp, %r15d
cmpl %r15d, %ebx
jge 0x6469
jmp 0x6557
addl $-0x9, %eax
cmpl $0x2, %eax
jb 0x6531
jmp 0x65af
leaq 0x55d7(%rip), %rax      # 0xbab0
addq %rax, %r14
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rsi
decq %rsi
movl 0x10(%r14), %eax
movl %eax, %ecx
andl $0x1f, %ecx
leal -0x8(%rcx), %edx
cmpl $0x8, %edx
movq 0x18(%rsp), %r13
movabsq $0x100000000, %rbp      # imm = 0x100000000
jb 0x6519
leal -0x10(%rcx), %edx
cmpl $0x8, %edx
jae 0x6542
movq 0x18(%r14), %rcx
movq %rcx, 0x20(%r15)
movl %eax, 0x10(%r15)
movq 0x8(%r14), %rcx
movq %rcx, 0x18(%r15)
cmpl $0x18, %eax
je 0x6531
jmp 0x656d
cmpl $0xd, %eax
jne 0x6599
movb (%rsi), %bl
movq %rsi, 0x8(%rsp)
testb %bl, %bl
jne 0x638a
jmp 0x6565
testl %ecx, %ecx
jne 0x6531
movl $0x1f, 0x10(%r15)
movq 0x8(%r14), %rax
jmp 0x6623
movq 0x10(%rsp), %rax
movl $0x19, 0x10(%rax)
jmp 0x656d
movl $0x1a, 0x10(%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x3060
movsd %xmm0, 0x18(%r15)
movl $0x1e, 0x10(%r15)
jmp 0x656d
cmpl $0x5e, %eax
jne 0x65af
movl $0x20, 0x10(%r15)
movq 0x5a2b(%rip), %rax      # 0xbfd8
jmp 0x6623
movl $0x19, 0x10(%r15)
jmp 0x656d
movl $0x1b, 0x10(%r15)
jmp 0x656d
movl $0x20, 0x10(%r15)
leaq 0x6c(%rip), %rax        # 0x663e
jmp 0x6623
movl $0x20, 0x10(%r15)
leaq 0x65(%rip), %rax        # 0x6648
jmp 0x6623
movl $0x20, 0x10(%r15)
leaq 0x4f(%rip), %rax        # 0x6643
jmp 0x6623
movl $0x1c, 0x10(%r15)
jmp 0x656d
movl $0x20, 0x10(%r15)
movq 0x59ce(%rip), %rax      # 0xbfe0
jmp 0x6623
movl $0x20, 0x10(%r15)
leaq 0x16(%rip), %rax        # 0x6639
movq %rax, 0x18(%r15)
jmp 0x656d
movl $0x1d, 0x10(%r15)
jmp 0x656d