// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl $0x18, 0x10(%rdi)
leaq 0x8(%rdi), %r12
movq %rdi, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movsbq (%rax), %rbx
testq %rbx, %rbx
je 0x64ce
leal -0x30(%rbx), %eax
cmpb $0xa, %al
setae %al
cmpb $0x2e, %bl
setne %cl
testb %al, %cl
jne 0x624d
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x3060
movsd %xmm0, 0x18(%r14)
movl $0x1e, 0x10(%r14)
jmp 0x641e
callq 0x31d0
movq (%rax), %rcx
testb $0x4, 0x1(%rcx,%rbx,2)
jne 0x62a5
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rax
movq %rax, (%r12)
movzbl (%rcx), %eax
cmpl $0x1f, %eax
jle 0x63b8
leal -0x20(%rax), %ecx
cmpl $0xf, %ecx
ja 0x642e
leaq 0x26d8(%rip), %rdx      # 0x8960
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x20, 0x10(%r14)
movq 0x5d40(%rip), %rax      # 0xbfe0
jmp 0x6406
movq (%r12), %rbx
movsbq (%rbx), %rcx
cmpq $0x5f, %rcx
je 0x62c2
movq (%rax), %rdx
movzwl (%rdx,%rcx,2), %ecx
andl $0xc00, %ecx            # imm = 0xC00
je 0x62e8
incq %rbx
movq %rbx, (%r12)
movsbq (%rbx), %rcx
incq %rbx
cmpq $0x5f, %rcx
je 0x62c5
movq (%rax), %rdx
movzwl (%rdx,%rcx,2), %ecx
andl $0xc00, %ecx            # imm = 0xC00
jne 0x62c5
decq %rbx
subq 0x8(%rsp), %rbx
movq 0x28(%r14), %r15
testq %r15, %r15
je 0x632a
movl 0x30(%r14), %r14d
testl %r14d, %r14d
je 0x632a
movslq %ebx, %r12
movq (%r15), %r13
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3050
testl %eax, %eax
jne 0x6321
cmpb $0x0, (%r13,%r12)
je 0x632d
addq $0x20, %r15
decl %r14d
jne 0x6302
xorl %r15d, %r15d
testq %r15, %r15
jne 0x63ca
movslq %ebx, %rax
movq %rax, 0x20(%rsp)
movl $0x17, %r14d
xorl %r12d, %r12d
movl %r14d, %eax
subl %r12d, %eax
jl 0x63c7
movl %eax, %ebx
shrl $0x1f, %ebx
addl %eax, %ebx
sarl %ebx
addl %r12d, %ebx
movslq %ebx, %rbp
shlq $0x5, %rbp
leaq 0x5747(%rip), %rax      # 0xbab0
movq (%rbp,%rax), %r13
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
callq 0x3050
testl %eax, %eax
jne 0x6391
movq 0x20(%rsp), %rax
movsbl (%r13,%rax), %eax
negl %eax
testl %eax, %eax
je 0x639e
jg 0x63ad
decl %ebx
movl %ebx, %r14d
jmp 0x63b2
leaq 0x570b(%rip), %rcx      # 0xbab0
addq %rcx, %rbp
movq %rbp, %r15
jmp 0x63b2
incl %ebx
movl %ebx, %r12d
testl %eax, %eax
jne 0x6347
jmp 0x63ca
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0x641e
cmpl $0xd, %eax
je 0x641e
jmp 0x6444
xorl %r15d, %r15d
testq %r15, %r15
je 0x640c
movl 0x10(%r15), %eax
movl %eax, %ecx
andl $0x1f, %ecx
leal -0x8(%rcx), %edx
cmpl $0x8, %edx
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r12
jb 0x63fe
leal -0x10(%rcx), %edx
cmpl $0x8, %edx
jae 0x64b9
movq 0x18(%r15), %rcx
movq %rcx, 0x20(%r14)
movl %eax, 0x10(%r14)
movq 0x8(%r15), %rax
movq %rax, 0x18(%r14)
jmp 0x641e
movq 0x18(%rsp), %r14
movl $0x19, 0x10(%r14)
movq 0x10(%rsp), %r12
cmpl $0x18, 0x10(%r14)
je 0x6205
jmp 0x64d6
cmpl $0x5e, %eax
jne 0x6444
movl $0x20, 0x10(%r14)
movq 0x5b96(%rip), %rax      # 0xbfd8
jmp 0x6406
movl $0x19, 0x10(%r14)
jmp 0x641e
movl $0x20, 0x10(%r14)
leaq 0x92(%rip), %rax        # 0x64ef
jmp 0x6406
movl $0x1c, 0x10(%r14)
jmp 0x641e
movl $0x20, 0x10(%r14)
leaq 0x72(%rip), %rax        # 0x64ea
jmp 0x6406
movl $0x20, 0x10(%r14)
leaq 0x5c(%rip), %rax        # 0x64e5
jmp 0x6406
movl $0x1d, 0x10(%r14)
jmp 0x641e
movl $0x1b, 0x10(%r14)
jmp 0x641e
movl $0x20, 0x10(%r14)
leaq 0x40(%rip), %rax        # 0x64f4
jmp 0x6406
testl %ecx, %ecx
jne 0x641e
movl $0x1f, 0x10(%r14)
jmp 0x6402
movl $0x1a, 0x10(%r14)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq