// File: /workspace/github_cpp_makefile_star2_O1/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
movl %edi, %ebx
leaq 0x13f9e(%rip), %r14     # 0x1f06a
leaq 0x20b83dd(%rip), %r15   # 0x20c34b0
leaq 0x13fe6(%rip), %r12     # 0x1f0c0
cmpb $0x1, 0x20b93e4(%rip)   # 0x20c44c5
je 0xb3c1
movq 0x20b93ca(%rip), %rax   # 0x20c44b8
movq 0x1008(%rax), %rcx
cmpq 0x1010(%rax), %rcx
jae 0xb3ab
movq 0x20b93af(%rip), %rsi   # 0x20c44b8
leaq 0x1008(%rsi), %rax
movq 0x1008(%rsi), %rcx
movb (%rcx), %dl
cmpb $0x20, %dl
ja 0xb183
cmpq 0x1010(%rsi), %rcx
jae 0xb3ab
leaq 0x1(%rcx), %rdx
movq %rdx, (%rax)
cmpb $0xa, (%rcx)
jne 0xb167
testb %bl, %bl
jne 0xb14b
movl 0x20b937f(%rip), %esi   # 0x20c44c0
movq %r14, %rdi
xorl %eax, %eax
callq 0xa2a0
movq 0x20b9366(%rip), %rax   # 0x20c44b8
movl 0x1018(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x1018(%rax)
movl %ecx, 0x20b9359(%rip)   # 0x20c44c0
movq 0x20b934a(%rip), %rsi   # 0x20c44b8
leaq 0x1008(%rsi), %rax
movq 0x1008(%rsi), %rcx
movb (%rcx), %dl
cmpb $0x21, %dl
jb 0xb11e
cmpq 0x1010(%rsi), %rcx
jae 0xb3ab
movzbl %dl, %esi
cmpl $0x2e, %esi
jle 0xb1a7
cmpl $0x2f, %esi
je 0xb1b1
cmpl $0x3b, %esi
je 0xb1bb
jmp 0xb27f
cmpl $0x23, %esi
je 0xb1bb
jmp 0xb249
cmpb $0x2f, 0x1(%rcx)
jne 0xb27a
testb %bl, %bl
jne 0xb1cf
movl 0x20b92fb(%rip), %esi   # 0x20c44c0
movq %r14, %rdi
xorl %eax, %eax
callq 0xa2a0
movq 0x20b92e2(%rip), %rax   # 0x20c44b8
movq 0x1008(%rax), %rcx
cmpb $0x2f, (%rcx)
jne 0xb1ec
incq %rcx
movq %rcx, 0x1008(%rax)
movq 0x1008(%rax), %rcx
cmpb $0x54, 0x1(%rcx)
jne 0xb208
cmpb $0x58, 0x2(%rcx)
jne 0xb208
movb 0x3(%rcx), %cl
movb %cl, 0x20b92a8(%rip)    # 0x20c44b0
movq 0x1008(%rax), %rcx
movq %rcx, %rdx
incq %rcx
movq %rcx, 0x1008(%rax)
cmpb $0xa, (%rdx)
je 0xb22f
cmpq 0x1010(%rax), %rcx
jb 0xb20f
jmp 0xb3ab
movl 0x1018(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x1018(%rax)
movl %ecx, 0x20b927c(%rip)   # 0x20c44c0
jmp 0xb102
cmpl $0x22, %esi
jne 0xb27f
incq %rcx
movq %rcx, (%rax)
movq 0x20b925d(%rip), %rcx   # 0x20c44b8
leaq 0x1008(%rcx), %rax
movq 0x1008(%rcx), %rdx
cmpb $0x22, (%rdx)
jne 0xb30a
movq %r15, %rbp
jmp 0xb36b
cmpb $0x22, %dl
je 0xb24e
movq 0x20b9232(%rip), %rax   # 0x20c44b8
movq 0x1008(%rax), %rcx
movb (%rcx), %dl
cmpb $0x21, %dl
setb %sil
cmpb $0x3b, %dl
sete %dl
orb %sil, %dl
movq %r15, %rbp
jne 0xb373
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 0xb370
subq $0x1, %r13
jae 0xb2eb
movl 0x20b91df(%rip), %esi   # 0x20c44c0
movq %r12, %rdi
xorl %eax, %eax
callq 0xa2a0
movq 0x20b91c6(%rip), %rax   # 0x20c44b8
movq 0x1008(%rax), %rcx
movb (%rcx), %dl
incq %rbp
cmpb $0x21, %dl
jb 0xb373
cmpb $0x3b, %dl
jne 0xb2b1
jmp 0xb373
movl $0xfff, %r13d           # imm = 0xFFF
movq %r15, %rbp
leaq 0x1(%rdx), %rsi
movq %rsi, 0x1008(%rcx)
movb (%rdx), %dl
movb %dl, (%rbp)
movq 0x1008(%rcx), %rdx
cmpq 0x1010(%rcx), %rdx
je 0xb368
subq $0x1, %r13
jae 0xb349
movl 0x20b9181(%rip), %esi   # 0x20c44c0
movq %r12, %rdi
xorl %eax, %eax
callq 0xa2a0
movq 0x20b9168(%rip), %rcx   # 0x20c44b8
leaq 0x1008(%rcx), %rax
movq 0x1008(%rcx), %rdx
incq %rbp
cmpb $0x22, (%rdx)
jne 0xb313
jmp 0xb36b
incq %rbp
incq (%rax)
jmp 0xb373
incq %rbp
movb $0x0, (%rbp)
movq 0x20b8132(%rip), %rax   # 0x20c34b0
movabsq $0x6564756c636e6924, %rcx # imm = 0x6564756C636E6924
xorq %rcx, %rax
movzbl 0x20b8126(%rip), %ecx   # 0x20c34b8
orq %rax, %rcx
jne 0xb3c8
xorl %edi, %edi
callq 0xb0b8
movq %r15, %rdi
callq 0xaf18
jmp 0xb0da
movzbl %bl, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb01c
movb $0x0, 0x20b90fd(%rip)   # 0x20c44c5
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq