// File: /workspace/github_c_makefile_star2_O3/JimKent[P]linearSat/lib/kxTok.c
// Function: kxTokenizeFancy
struct kxTok *kxTokenizeFancy(char *text, boolean wildAst,
			      boolean wildPercent, boolean includeHyphen)
/* Convert text to stream of tokens. If 'wildAst' is
 * TRUE then '*' character will be treated as wildcard
 * rather than multiplication sign.  
 * If wildPercent is TRUE then the '%' character will be treated as a 
 * wildcard (as in SQL) rather than a modulo (kxtMod) or percent sign.
 * If includeHyphen is TRUE then a '-' character in the middle of a String 
 * token will be treated as a hyphen (part of the String token) instead of 
 * a new kxtSub token. */
{
struct kxTok *tokList = NULL, *tok;
char c, *s, *start = NULL, *end = NULL;
enum kxTokType type = 0;
boolean spaceBefore = FALSE;

s = text;
for (;;)
    {
    if ((c = *s) == 0)
        break;
    start = s++;
    if (isspace(c))
        {
	spaceBefore = TRUE;
        continue;
        }
    else if (isalnum(c) || c == '?' || (wildAst && c == '*') ||
	     (wildPercent && c == '%'))
        {
        if (c == '?')
            type = kxtWildString;
	else if (wildAst && c == '*')
            type = kxtWildString;
	else if (wildPercent && c == '%')
            type = kxtWildString;
        else
            type = kxtString;
        for (;;)
            {
            c = *s;
            if (isalnum(c) || c == ':' || c == '_' || c == '.' ||
		(includeHyphen && c == '-'))
                ++s;
            else if (c == '?' || (wildAst && c == '*') ||
		     (wildPercent && c == '%'))
                {
                type = kxtWildString;
                ++s;
                }
            else
                break;
            }
        end = s;
        }
    else if (c == '"')
        {
        type = kxtString;
        if (! includeQuotes)
	    start = s;
        for (;;)
            {
            c = *s++;
            if (c == '"')
                break;
            if (c == '*' || c == '?' || (wildPercent && c == '%'))
                type = kxtWildString;
            }
	if (! includeQuotes)
	    end = s-1;
	else
	    end = s;
        }
    else if (c == '\'')
        {
        type = kxtString;
        if (! includeQuotes)
	    start = s;
        for (;;)
            {
            c = *s++;
            if (c == '\'')
                break;
            if (c == '*' || c == '?' || (wildPercent && c == '%'))
                type = kxtWildString;
            }
	if (! includeQuotes)
	    end = s-1;
	else
	    end = s;
        } 
    else if (c == '=')
        {
        type = kxtEquals;
        end = s;
        }
    else if (c == '&')
        {
        type = kxtAnd;
        end = s;
        }
    else if (c == '|')
        {
        type = kxtOr;
        end = s;
        }
    else if (c == '^')
        {
        type = kxtXor;
        end = s;
        }
    else if (c == '+')
        {
	type = kxtAdd;
	end = s;
	}
    else if (c == '-')
        {
	type = kxtSub;
	end = s;
	}
    else if (c == '*')
        {
	type = kxtMul;
	end = s;
	}
    else if (c == '/')
        {
	type = kxtDiv;
	end = s;
	}
    else if (c == '(')
        {
        type = kxtOpenParen;
        end = s;
        }
    else if (c == ')')
        {
        type = kxtCloseParen;
        end = s;
        }
    else if (c == '!')
        {
        type = kxtNot;
        end = s;
        }
    else if (c == '>')
        {
        if (*s == '=')
            {
            ++s;
            type = kxtGE;
            }
        else
            type = kxtGT;
        end = s;
        }
    else if (c == '<')
        {
        if (*s == '=')
            {
            ++s;
            type = kxtLE;
            }
        else
            type = kxtLT;
        end = s;
        }
    else if (c == '.')
        {
        type = kxtDot;
        end = s;
	}
    else if (c == '%')
        {
        type = kxtMod;
        end = s;
	}
    else if (ispunct(c))
        {
        type = kxtPunct;
        end = s;
	}
    else
        {
        errAbort("Unrecognized character %c", c);
        }
    tok = kxTokNew(type, start, end-start, spaceBefore);
    slAddHead(&tokList, tok);
    spaceBefore = FALSE;
    }
tok = kxTokNew(kxtEnd, "end", 3, spaceBefore);
slAddHead(&tokList, tok);
slReverse(&tokList);
return tokList;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r13d
movl %edx, 0x4(%rsp)
movl %esi, 0x14(%rsp)
movq %rdi, %r12
movq $0x0, 0x30(%rsp)
movabsq $0x2000000001001, %r14  # imm = 0x2000000001001
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
xorl %ebx, %ebx
xorl %edx, %edx
movl %edx, %ebp
movsbq (%r12), %r15
testq %r15, %r15
je 0x164fc
incq %r12
callq 0x37a0
movq (%rax), %rax
movzwl (%rax,%r15,2), %ecx
movb $0x1, %dl
btl $0xd, %ecx
jb 0x16191
movzbl %r15b, %edx
cmpl $0x0, 0x14(%rsp)
setne %dil
cmpb $0x2a, %r15b
sete %sil
andb %dil, %sil
leaq -0x1(%r12), %rdi
movq %rdi, 0x8(%rsp)
cmpb $0x3f, %r15b
movl %r13d, 0x24(%rsp)
je 0x1627a
movl %ecx, %edi
andl $0x8, %edi
jne 0x1627a
movl $0x2, %edi
testb %sil, %sil
jne 0x162a0
cmpl $0x0, 0x4(%rsp)
je 0x16210
cmpb $0x25, %r15b
je 0x1628b
cmpl $0x3c, %edx
jg 0x16364
leal -0x22(%rdx), %eax
cmpl $0xb, %eax
ja 0x16413
leaq 0x6224(%rip), %rsi      # 0x1c450
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
movl $0x1, %ebx
movl 0x222b8(%rip), %eax     # 0x384f8
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %rdi, %rdx
movq %rdx, %rdi
movzbl (%rdx), %ecx
cmpl $0x22, %ecx
je 0x163ce
cmpl $0x2a, %ecx
je 0x16270
cmpl $0x3f, %ecx
je 0x16270
leaq 0x1(%rdi), %rdx
testl %esi, %esi
je 0x1624a
cmpb $0x25, %cl
jne 0x1624a
incq %rdi
movl $0x2, %ebx
jmp 0x16247
cmpb $0x3f, %r15b
sete %cl
orb %sil, %cl
movl $0x2, %edi
jne 0x162a0
cmpl $0x0, 0x4(%rsp)
setne %cl
cmpl $0x25, %edx
sete %dl
andb %cl, %dl
movzbl %dl, %edi
incl %edi
movl %edi, %ebx
movl 0x4(%rsp), %r10d
movl 0x14(%rsp), %r11d
movsbq (%r12), %rcx
movzwl (%rax,%rcx,2), %edx
testb $0x8, %dl
jne 0x162cb
movzbl %cl, %edx
leal -0x2e(%rdx), %esi
cmpl $0x31, %esi
ja 0x162d4
btq %rsi, %r14
jae 0x162d4
movl %ebx, %ecx
incq %r12
movl %ecx, %ebx
jmp 0x162ac
testl %r13d, %r13d
je 0x162de
cmpb $0x2d, %cl
je 0x162cb
testl %r10d, %r10d
setne %sil
testl %r11d, %r11d
setne %dil
cmpl $0x2a, %edx
sete %r9b
cmpl $0x25, %edx
sete %r8b
movl $0x2, %ecx
cmpl $0x3f, %edx
je 0x162cd
andb %r9b, %dil
jne 0x162cd
andb %r8b, %sil
jne 0x162cd
movq %r12, %rdi
movq %rdi, %rax
movq %rdi, 0x28(%rsp)
subl 0x8(%rsp), %eax
movslq %eax, %r15
leal 0x10(%r15), %eax
movslq %eax, %rdi
callq 0xee10
movq %rax, %r13
movl %ebx, 0x8(%rax)
movb %bpl, 0xc(%rax)
leaq 0xd(%rax), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x34a0
movq 0x18(%rsp), %rax
movq %rax, (%r13)
movq %r13, 0x30(%rsp)
movq %r13, 0x18(%rsp)
movl 0x24(%rsp), %r13d
jmp 0x1618f
cmpl $0x7c, %edx
je 0x163ff
cmpl $0x5e, %edx
je 0x16409
cmpl $0x3d, %edx
jne 0x16413
movl $0x3, %ebx
jmp 0x1630e
movl $0xe, %ebx
jmp 0x1630e
movl $0x1, %ebx
movl 0x22160(%rip), %eax     # 0x384f8
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %rdi, %rdx
movq %rdx, %rdi
movzbl (%rdx), %ecx
cmpl $0x27, %ecx
je 0x163ce
cmpl $0x2a, %ecx
je 0x163c4
cmpl $0x3f, %ecx
je 0x163c4
leaq 0x1(%rdi), %rdx
testl %esi, %esi
je 0x163a2
cmpb $0x25, %cl
jne 0x163a2
incq %rdi
movl $0x2, %ebx
jmp 0x1639f
testl %eax, %eax
movq 0x8(%rsp), %rax
cmoveq %r12, %rax
movq %rax, 0x8(%rsp)
leaq 0x1(%rdi), %r12
cmovneq %r12, %rdi
jmp 0x16311
movl $0x8, %ebx
jmp 0x1630e
movl $0xf, %ebx
jmp 0x1630e
movl $0x9, %ebx
jmp 0x1630e
movl $0xa, %ebx
jmp 0x1630e
cmpl $0x2a, %edx
jne 0x16425
movq %r12, %rdi
movl $0x11, %ebx
jmp 0x16311
movzbl %r15b, %eax
cmpl $0x3b, %eax
jg 0x16450
leal -0x28(%rax), %esi
cmpl $0x7, %esi
ja 0x16475
leaq 0x6043(%rip), %rdi      # 0x1c480
movslq (%rdi,%rsi,4), %rax
addq %rdi, %rax
jmpq *%rax
movl $0xc, %ebx
jmp 0x1630e
cmpl $0x3c, %eax
je 0x164b4
cmpl $0x3e, %eax
jne 0x16484
leaq 0x1(%r12), %rax
xorl %ebx, %ebx
cmpb $0x3d, (%r12)
sete %bl
cmoveq %rax, %r12
orl $0x4, %ebx
jmp 0x1630e
cmpl $0x21, %eax
jne 0x16484
movl $0xb, %ebx
jmp 0x1630e
cmpl $0x25, %edx
jne 0x164cf
movq %r12, %rdi
movl $0x13, %ebx
jmp 0x16311
movl $0x12, %ebx
jmp 0x1630e
movl $0x10, %ebx
jmp 0x1630e
movl $0xd, %ebx
jmp 0x1630e
leaq 0x1(%r12), %rax
xorl %ebx, %ebx
cmpb $0x3d, (%r12)
sete %bl
cmoveq %rax, %r12
orl $0x6, %ebx
jmp 0x1630e
testb $0x4, %cl
jne 0x164ef
leaq 0x5fc5(%rip), %rdi      # 0x1c4a0
movl %r15d, %esi
xorl %eax, %eax
callq 0xb6c8
movq 0x28(%rsp), %rdi
jmp 0x16311
movq %r12, %rdi
movl $0x14, %ebx
jmp 0x16311
movl $0x13, %edi
callq 0xee10
movl $0x0, 0x8(%rax)
movb %bpl, 0xc(%rax)
movw $0x6e65, 0xd(%rax)      # imm = 0x6E65
movb $0x64, 0xf(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x30(%rsp), %rbx
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x66bb
movq (%rbx), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq