// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/common/scriplib.cpp
// Function: GetToken(bool)
bool            GetToken(const bool crossline)
{
    char           *token_p;

    if (s_tokenready)                                        // is a g_token allready waiting?
    {
        s_tokenready = false;
        return true;
    }

    if (s_script->script_p >= s_script->end_p)
        return EndOfScript(crossline);

    // skip space
skipspace:
#ifdef ZHLT_TEXNAME_CHARSET
	while (*s_script->script_p <= 32 && *s_script->script_p >= 0)
#else
    while (*s_script->script_p <= 32)
#endif
    {
        if (s_script->script_p >= s_script->end_p)
            return EndOfScript(crossline);

        if (*s_script->script_p++ == '\n')
        {
            if (!crossline)
                Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);
            s_scriptline = s_script->line++;
        }
    }

    if (s_script->script_p >= s_script->end_p)
        return EndOfScript(crossline);

    // comment fields
    if (*s_script->script_p == ';' || *s_script->script_p == '#' || // semicolon and # is comment field
        (*s_script->script_p == '/' && *((s_script->script_p) + 1) == '/')) // also make // a comment field
    {
        if (!crossline)
            Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);

        //ets+++
        if (*s_script->script_p == '/')
            s_script->script_p++;
        if (s_script->script_p[1] == 'T' && s_script->script_p[2] == 'X')
            g_TXcommand = s_script->script_p[3];             // AR: "//TX#"-style comment

        //ets---
        while (*s_script->script_p++ != '\n')
        {
            if (s_script->script_p >= s_script->end_p)
                return EndOfScript(crossline);
        }
        //ets+++
        s_scriptline = s_script->line++;                       // AR: this line was missing
        //ets---
        goto skipspace;
    }

    // copy g_token
    token_p = g_token;

    if (*s_script->script_p == '"')
    {
        // quoted token
        s_script->script_p++;
        while (*s_script->script_p != '"')
        {
            *token_p++ = *s_script->script_p++;

            if (s_script->script_p == s_script->end_p)
                break;

            if (token_p == &g_token[MAXTOKEN])
                Error("Token too large on line %i\n", s_scriptline);
        }
        s_script->script_p++;
    }
    else
    {
        // regular token
#ifdef ZHLT_TEXNAME_CHARSET
		while ((*s_script->script_p > 32 || *s_script->script_p < 0) && *s_script->script_p != ';')
#else
        while (*s_script->script_p > 32 && *s_script->script_p != ';')
#endif
        {
            *token_p++ = *s_script->script_p++;

            if (s_script->script_p == s_script->end_p)
                break;

            if (token_p == &g_token[MAXTOKEN])
                Error("Token too large on line %i\n", s_scriptline);
        }
    }

    *token_p = 0;

    if (!strcmp(g_token, "$include"))
    {
        GetToken(false);
        AddScriptToStack(g_token);
        return GetToken(crossline);
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, 0x20b9510(%rip)   # 0x20c44b5
je 0xafbf
movb $0x0, 0x20b9507(%rip)   # 0x20c44b5
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, %ebx
leaq 0x14092(%rip), %r14     # 0x1f05a
leaq 0x20b84d1(%rip), %r15   # 0x20c34a0
leaq 0x140da(%rip), %r12     # 0x1f0b0
movq 0x20b94cb(%rip), %rax   # 0x20c44a8
movq 0x1008(%rax), %rcx
cmpq 0x1010(%rax), %rcx
jae 0xb27d
leaq 0x1008(%rax), %rdx
movb (%rcx), %sil
cmpb $0x20, %sil
ja 0xb061
cmpq 0x1010(%rax), %rcx
jae 0xb27d
leaq 0x1(%rcx), %rsi
movq %rsi, (%rdx)
cmpb $0xa, (%rcx)
jne 0xb04a
testb %bl, %bl
jne 0xb035
movl 0x20b948c(%rip), %esi   # 0x20c44b0
movq %r14, %rdi
xorl %eax, %eax
callq 0xa164
movq 0x20b9473(%rip), %rax   # 0x20c44a8
movl 0x1018(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x1018(%rax)
movl %ecx, 0x20b9466(%rip)   # 0x20c44b0
leaq 0x1008(%rax), %rdx
movq 0x1008(%rax), %rcx
movb (%rcx), %sil
cmpb $0x21, %sil
jb 0xb001
cmpq 0x1010(%rax), %rcx
jae 0xb27d
movzbl %sil, %esi
cmpl $0x2e, %esi
jle 0xb086
cmpl $0x2f, %esi
je 0xb090
cmpl $0x3b, %esi
je 0xb09a
jmp 0xb148
cmpl $0x23, %esi
je 0xb09a
jmp 0xb11e
cmpb $0x2f, 0x1(%rcx)
jne 0xb148
testb %bl, %bl
jne 0xb0b5
movl 0x20b940c(%rip), %esi   # 0x20c44b0
movq %r14, %rdi
xorl %eax, %eax
callq 0xa164
movq 0x20b93f3(%rip), %rax   # 0x20c44a8
movq 0x1008(%rax), %rcx
cmpb $0x2f, (%rcx)
jne 0xb0cb
incq %rcx
movq %rcx, 0x1008(%rax)
cmpb $0x54, 0x1(%rcx)
jne 0xb0e0
cmpb $0x58, 0x2(%rcx)
jne 0xb0e0
movb 0x3(%rcx), %dl
movb %dl, 0x20b93c0(%rip)    # 0x20c44a0
leaq 0x1(%rcx), %rdx
movq %rdx, 0x1008(%rax)
cmpb $0xa, (%rcx)
je 0xb101
movq %rdx, %rcx
cmpq 0x1010(%rax), %rdx
jb 0xb0e0
jmp 0xb27d
movl 0x1018(%rax), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x1018(%rax)
movl %edx, 0x20b939a(%rip)   # 0x20c44b0
incq %rcx
jmp 0xaff1
cmpl $0x22, %esi
jne 0xb148
incq %rcx
movq %rcx, (%rdx)
leaq 0x1008(%rax), %rcx
movq 0x1008(%rax), %rdx
cmpb $0x22, (%rdx)
jne 0xb1cd
movq %r15, %rbp
jmp 0xb22e
movq 0x1008(%rax), %rcx
movb (%rcx), %dl
cmpb $0x21, %dl
setb %sil
cmpb $0x3b, %dl
sete %dl
orb %sil, %dl
movq %r15, %rbp
jne 0xb234
movl $0xfff, %r13d           # imm = 0xFFF
movq %r15, %rbp
leaq 0x1(%rcx), %rdx
movq %rdx, 0x1008(%rax)
movb (%rcx), %cl
movb %cl, (%rbp)
movq 0x1008(%rax), %rcx
cmpq 0x1010(%rax), %rcx
je 0xb1c8
subq $0x1, %r13
jae 0xb1b0
movl 0x20b9311(%rip), %esi   # 0x20c44b0
movq %r12, %rdi
xorl %eax, %eax
callq 0xa164
movq 0x20b92f8(%rip), %rax   # 0x20c44a8
movq 0x1008(%rax), %rcx
movb (%rcx), %dl
incq %rbp
cmpb $0x21, %dl
jb 0xb234
cmpb $0x3b, %dl
jne 0xb173
jmp 0xb234
incq %rbp
jmp 0xb234
movl $0xfff, %r13d           # imm = 0xFFF
movq %r15, %rbp
leaq 0x1(%rdx), %rsi
movq %rsi, 0x1008(%rax)
movb (%rdx), %dl
movb %dl, (%rbp)
movq 0x1008(%rax), %rdx
cmpq 0x1010(%rax), %rdx
je 0xb22b
subq $0x1, %r13
jae 0xb213
movl 0x20b92ae(%rip), %esi   # 0x20c44b0
movq %r12, %rdi
xorl %eax, %eax
callq 0xa164
movq 0x20b9295(%rip), %rax   # 0x20c44a8
leaq 0x1008(%rax), %rcx
movq 0x1008(%rax), %rdx
incq %rbp
cmpb $0x22, (%rdx)
jne 0xb1d6
jmp 0xb22e
incq %rbp
incq %rdx
movq %rdx, (%rcx)
movb $0x0, (%rbp)
movq 0x20b8261(%rip), %rax   # 0x20c34a0
movabsq $0x6564756c636e6924, %rcx # imm = 0x6564756C636E6924
xorq %rcx, %rax
movzbl 0x20b8255(%rip), %ecx   # 0x20c34a8
orq %rax, %rcx
jne 0xafae
xorl %edi, %edi
callq 0xaf93
movq %r15, %rdi
callq 0xadf0
cmpb $0x0, 0x20b9243(%rip)   # 0x20c44b5
je 0xafd6
jmp 0xafa7
movzbl %bl, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaef7