// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/cmpile.c
// Function: findToken
ccInt findToken(compiler_type *compiler, linkedlist *tokenStringList, char **scriptStringPtr, ccInt *whichElement,
        ccBool endWithNull, ccBool maybeVariableName)
{
    ccInt loopElement, searchBottom = 1, searchTop = tokenStringList->elementNum;
    ccInt numLanguageOps = compiler->numLanguageOps[(ccInt) **scriptStringPtr], directionToAdjust;
    char *scriptChar, *storedChar, *scriptStringStart = *scriptStringPtr;
    ccBool isWord = ccFalse, comparingLanguageOp = ccTrue, maybeFinishedScriptToken, finishedScriptToken, finishedStoredToken;
    
    if (searchTop == 0)  {  *whichElement = 1;  return ccFalse;  }
    
    
        // loop over all tokens in the current list
    
    *whichElement = 0;
    do  {
        scriptChar = scriptStringStart;
        
        if (searchBottom > numLanguageOps)  {
            if ((comparingLanguageOp) && (*whichElement > 0))  break;       // interpret it as a language op if possible
            comparingLanguageOp = ccFalse;      }
        
        if (comparingLanguageOp)  loopElement = searchBottom;               // first do an enumerative search over all built-in operators,
        else  loopElement = (searchBottom+searchTop)/2;                     // then a binary search over the stored variable names
        
        
            // try to match all of the characters of this particular token
        
        storedChar = ((tokenStringType *) element(tokenStringList, loopElement))->name;
        while (*storedChar != 0)  {
            
            isWord = ccFalse;
            if (*storedChar != ' ')  {
                if ((lettertype(scriptChar) == a_letter) || (lettertype(scriptChar) == a_number))  isWord = ccTrue;
                if (*scriptChar != *storedChar)  break;
                
                nextChar(&scriptChar);
                storedChar++;       }
            
            else  {                         // spaces get special treatment
                if ((*(storedChar+1) == ' ') && (*scriptChar != *storedChar))  break;
                else  {
                    while (*storedChar == ' ')  storedChar++;
                    while ((*scriptChar == ' ') || (*scriptChar == '\t') || (lettertype(scriptChar) == unprintable))  {
                        scriptChar++;
        }   }   }   }
        
        
            // figure out if we have to move up (directionToAdjust = 1), down (directionToAdjust = -1), or if we have a match
        
        if ( ((isWord) && ((lettertype(scriptChar) == a_letter) || (lettertype(scriptChar) == a_number)))
                    || ((endWithNull) && (lettertype(scriptChar) != a_null)) )  {
            finishedScriptToken = maybeFinishedScriptToken = ccFalse;       }
        else  {
            finishedScriptToken = (!comparingLanguageOp);
            maybeFinishedScriptToken = ccTrue;            }
        finishedStoredToken = (*storedChar == 0);
        
        if ((maybeFinishedScriptToken) && (finishedStoredToken))  directionToAdjust = 0;
        else if (finishedScriptToken)  directionToAdjust = -1;
        else if (finishedStoredToken) directionToAdjust = 1;
        else  {
            while (lettertype(storedChar) == a_space)  nextChar(&storedChar);       // operator spaces confuse the alphabetization
            while (lettertype(scriptChar) == a_space)  scriptChar++;
            
            if (*scriptChar < *storedChar)  directionToAdjust = -1;
            else  directionToAdjust = 1;            }
        
        
            // adjust searchBottom/searchTop accordingly
        
        if (directionToAdjust == -1)  {
            if (!comparingLanguageOp)  searchTop = loopElement-1;
            else if ((!maybeVariableName) || (!(*whichElement == 0)))  break;
            else  searchBottom = numLanguageOps+1;      }
        
        else if (directionToAdjust == 0)  {
            *whichElement = loopElement;
            *scriptStringPtr = scriptChar;
            if (!comparingLanguageOp)  break;
            else  searchBottom++;           }
        
        else  searchBottom = loopElement+1;
        
    }  while (searchBottom <= searchTop);
    
    
        // if the string wasn't found, return the position where a new entry can be inserted
    
    if (*whichElement == 0)  {
        *whichElement = searchBottom;
        return  ccFalse;       }
    
    else  return ccTrue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, 0x40(%rsp)
movl %r8d, 0x44(%rsp)
movq %rsi, 0x60(%rsp)
movl (%rsi), %esi
testl %esi, %esi
je 0xb208
movq %rdx, 0x48(%rsp)
movq (%rdx), %rax
movq %rax, 0x58(%rsp)
movsbq (%rax), %rax
movl 0x1000(%rdi,%rax,4), %eax
movq %rcx, 0x18(%rsp)
andl $0x0, (%rcx)
movq %rax, 0x50(%rsp)
incl %eax
movl %eax, 0x3c(%rsp)
movb $0x1, %al
movl %eax, 0x14(%rsp)
pushq $0x1
popq %rax
xorl %r15d, %r15d
leaq 0x1617d(%rip), %r13     # 0x21180
leaq 0x28(%rsp), %r14
leaq 0x8(%rsp), %rbp
movl %eax, %edi
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl 0x50(%rsp), %edi
jle 0xb035
cmpb $0x0, 0x14(%rsp)
je 0xb045
movq 0x18(%rsp), %rax
cmpl $0x0, (%rax)
jle 0xb045
jmp 0xb20d
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl %edi, %r12d
cmpb $0x0, 0x14(%rsp)
jne 0xb061
leal (%rdi,%rsi), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r12d
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
movq %rdi, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x60(%rsp), %rdi
movl %r12d, %esi
callq 0x9088
movq (%rax), %rbx
movq %rbx, 0x28(%rsp)
movzbl (%rbx), %eax
cmpl $0x20, %eax
je 0xb0b4
testl %eax, %eax
je 0xb0fa
movq 0x8(%rsp), %rcx
movzbl (%rcx), %ecx
movl (%r13,%rcx,4), %edx
addl $-0x3, %edx
cmpl $0x2, %edx
setb %r15b
cmpb %al, %cl
jne 0xb0fa
movq %rbp, %rdi
callq 0xa083
incq %rbx
jmp 0xb080
cmpb $0x20, 0x1(%rbx)
jne 0xb0c4
movq 0x8(%rsp), %rcx
cmpb $0x20, (%rcx)
jne 0xb11b
decq %rbx
cmpb $0x20, 0x1(%rbx)
leaq 0x1(%rbx), %rbx
je 0xb0c7
movq 0x8(%rsp), %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0xb0eb
cmpl $0x20, %ecx
je 0xb0eb
cmpl $0x0, (%r13,%rcx,4)
jne 0xb0f0
incq %rax
jmp 0xb0d6
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
jmp 0xb080
movq %rbx, 0x28(%rsp)
testb %r15b, %r15b
je 0xb120
movq 0x8(%rsp), %rcx
movzbl (%rcx), %ecx
movl (%r13,%rcx,4), %ecx
addl $-0x3, %ecx
cmpl $0x2, %ecx
jae 0xb123
jmp 0xb14b
movq %rbx, 0x28(%rsp)
xorl %r15d, %r15d
cmpb $0x0, 0x44(%rsp)
je 0xb13a
movq 0x8(%rsp), %rcx
movzbl (%rcx), %ecx
cmpl $0x6, (%r13,%rcx,4)
jne 0xb14b
testb %al, %al
je 0xb1cb
cmpb $0x0, 0x10(%rsp)
jne 0xb15e
jmp 0xb1be
testb %al, %al
jne 0xb15e
jmp 0xb1b1
movq %r14, %rdi
callq 0xa083
movq 0x28(%rsp), %rbx
movzbl (%rbx), %eax
cmpl $0x1, (%r13,%rax,4)
je 0xb151
movq 0x8(%rsp), %rcx
decq %rcx
movzbl 0x1(%rcx), %edx
incq %rcx
cmpl $0x1, (%r13,%rdx,4)
je 0xb171
movq %rcx, 0x8(%rsp)
cmpb %al, %dl
jge 0xb1b1
cmpb $0x0, 0x10(%rsp)
je 0xb1be
movq 0x18(%rsp), %rax
movl (%rax), %r12d
cmpb $0x0, 0x40(%rsp)
je 0xb212
movl 0x3c(%rsp), %eax
movl %eax, %edi
testl %r12d, %r12d
movq 0x30(%rsp), %rsi
je 0xb1f3
jmp 0xb20d
incl %r12d
movl %r12d, %edi
movq 0x30(%rsp), %rsi
jmp 0xb1f3
decl %r12d
movl %r12d, %esi
movq 0x20(%rsp), %rdi
jmp 0xb1f3
movq 0x18(%rsp), %rax
movl %r12d, (%rax)
movq 0x8(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rax, (%rcx)
cmpb $0x0, 0x10(%rsp)
movq 0x30(%rsp), %rsi
je 0xb212
movq 0x20(%rsp), %rdi
incl %edi
cmpl %esi, %edi
jle 0xb00f
movq 0x18(%rsp), %rcx
movl (%rcx), %r12d
pushq $0x1
popq %rax
jmp 0xb21f
pushq $0x1
popq %rdi
jmp 0xb224
pushq $0x1
popq %rax
jmp 0xb228
movq 0x18(%rsp), %rcx
pushq $0x1
popq %rax
movq 0x20(%rsp), %rdi
testl %r12d, %r12d
jne 0xb228
movl %edi, (%rcx)
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq