// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movl %ecx, %r13d
movl %edx, 0x1c(%rsp)
movl %esi, 0x18(%rsp)
movq %rdi, %r12
movq $0x0, 0x8(%rsp)
movabsq $0x2000000001001, %r14  # imm = 0x2000000001001
movq $0x0, 0x20(%rsp)
xorl %ebx, %ebx
xorl %edx, %edx
movl %edx, %ebp
movsbq (%r12), %r15
testq %r15, %r15
je 0x16778
incq %r12
callq 0x37a0
movq (%rax), %rax
movzwl (%rax,%r15,2), %ecx
movb $0x1, %dl
btl $0xd, %ecx
jb 0x16428
movzbl %r15b, %edx
leaq -0x1(%r12), %rsi
movq %rsi, (%rsp)
cmpl $0x3f, %edx
movl 0x1c(%rsp), %r10d
movl 0x18(%rsp), %r11d
movl %r13d, 0x14(%rsp)
je 0x16496
movl %ecx, %esi
andl $0x8, %esi
jne 0x16496
testl %r11d, %r11d
je 0x16483
cmpb $0x2a, %r15b
je 0x16496
testl %r10d, %r10d
je 0x1657c
cmpb $0x25, %r15b
jne 0x1657c
cmpb $0x3f, %r15b
sete %cl
testl %r10d, %r10d
setne %sil
testl %r11d, %r11d
setne %dil
cmpl $0x2a, %edx
sete %dl
andb %dil, %dl
cmpb $0x25, %r15b
sete %dil
andb %sil, %dil
orb %cl, %dil
orb %dl, %dil
movzbl %dil, %ebx
incl %ebx
movsbq (%r12), %rcx
movzwl (%rax,%rcx,2), %edx
testb $0x8, %dl
jne 0x164ea
movzbl %cl, %edx
leal -0x2e(%rdx), %esi
cmpl $0x31, %esi
ja 0x164f3
btq %rsi, %r14
jae 0x164f3
movl %ebx, %ecx
incq %r12
movl %ecx, %ebx
jmp 0x164cb
testl %r13d, %r13d
je 0x164fd
cmpb $0x2d, %cl
je 0x164ea
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 0x164ec
andb %r9b, %dil
jne 0x164ec
andb %r8b, %sil
jne 0x164ec
movq %r12, %rsi
movq %rsi, %rax
movq %rsi, 0x20(%rsp)
subl (%rsp), %eax
movslq %eax, %r15
leal 0x10(%r15), %eax
movslq %eax, %rdi
callq 0xf07d
movq %rax, %r13
movl %ebx, 0x8(%rax)
movb %bpl, 0xc(%rax)
leaq 0xd(%rax), %rdi
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x34a0
movq 0x8(%rsp), %rax
movq %rax, (%r13)
movq %r13, 0x8(%rsp)
movl 0x14(%rsp), %r13d
jmp 0x16426
cmpl $0x3c, %edx
jg 0x165df
leal -0x22(%rdx), %eax
cmpl $0xb, %eax
ja 0x1668f
leaq 0x5ee0(%rip), %rsi      # 0x1c474
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
movl $0x1, %ebx
movl 0x21f50(%rip), %eax     # 0x384f8
movq %r12, %rsi
movq %rsi, %rdx
movq %rdx, %rsi
movzbl (%rdx), %ecx
cmpl $0x22, %ecx
je 0x1664c
cmpl $0x2a, %ecx
je 0x165d5
cmpl $0x3f, %ecx
je 0x165d5
leaq 0x1(%rsi), %rdx
testl %r10d, %r10d
je 0x165ae
cmpb $0x25, %cl
jne 0x165ae
incq %rsi
movl $0x2, %ebx
jmp 0x165ab
cmpl $0x7c, %edx
je 0x1667b
cmpl $0x5e, %edx
je 0x16685
cmpl $0x3d, %edx
jne 0x1668f
movl $0x3, %ebx
jmp 0x1652d
movl $0xe, %ebx
jmp 0x1652d
movl $0x1, %ebx
movl 0x21edf(%rip), %eax     # 0x384f8
movq %r12, %rsi
movq %rsi, %rdx
movq %rdx, %rsi
movzbl (%rdx), %ecx
cmpl $0x27, %ecx
je 0x1664c
cmpl $0x2a, %ecx
je 0x16642
cmpl $0x3f, %ecx
je 0x16642
leaq 0x1(%rsi), %rdx
testl %r10d, %r10d
je 0x1661f
cmpb $0x25, %cl
jne 0x1661f
incq %rsi
movl $0x2, %ebx
jmp 0x1661c
testl %eax, %eax
movq (%rsp), %rax
cmoveq %r12, %rax
movq %rax, (%rsp)
leaq 0x1(%rsi), %r12
cmovneq %r12, %rsi
jmp 0x16530
movl $0x8, %ebx
jmp 0x1652d
movl $0xf, %ebx
jmp 0x1652d
movl $0x9, %ebx
jmp 0x1652d
movl $0xa, %ebx
jmp 0x1652d
cmpl $0x2a, %edx
jne 0x166a1
movq %r12, %rsi
movl $0x11, %ebx
jmp 0x16530
movzbl %r15b, %eax
cmpl $0x3b, %eax
jg 0x166cc
leal -0x28(%rax), %esi
cmpl $0x7, %esi
ja 0x166f1
leaq 0x5deb(%rip), %rdi      # 0x1c4a4
movslq (%rdi,%rsi,4), %rax
addq %rdi, %rax
jmpq *%rax
movl $0xc, %ebx
jmp 0x1652d
cmpl $0x3c, %eax
je 0x16730
cmpl $0x3e, %eax
jne 0x16700
leaq 0x1(%r12), %rax
xorl %ebx, %ebx
cmpb $0x3d, (%r12)
sete %bl
cmoveq %rax, %r12
orl $0x4, %ebx
jmp 0x1652d
cmpl $0x21, %eax
jne 0x16700
movl $0xb, %ebx
jmp 0x1652d
cmpl $0x25, %edx
jne 0x1674b
movq %r12, %rsi
movl $0x13, %ebx
jmp 0x16530
movl $0x12, %ebx
jmp 0x1652d
movl $0x10, %ebx
jmp 0x1652d
movl $0xd, %ebx
jmp 0x1652d
leaq 0x1(%r12), %rax
xorl %ebx, %ebx
cmpb $0x3d, (%r12)
sete %bl
cmoveq %rax, %r12
orl $0x6, %ebx
jmp 0x1652d
testb $0x4, %cl
jne 0x1676b
leaq 0x5d6d(%rip), %rdi      # 0x1c4c4
movl %r15d, %esi
xorl %eax, %eax
callq 0xb8d7
movq 0x20(%rsp), %rsi
jmp 0x16530
movq %r12, %rsi
movl $0x14, %ebx
jmp 0x16530
movl $0x13, %edi
callq 0xf07d
movl $0x0, 0x8(%rax)
movb %bpl, 0xc(%rax)
movw $0x6e65, 0xd(%rax)      # imm = 0x6E65
movb $0x64, 0xf(%rax)
leaq 0x8(%rsp), %rbx
movq (%rbx), %rcx
movq %rcx, (%rax)
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x673b
movq (%rbx), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq