// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movl %r9d, 0x20(%rsp)
movl %r8d, 0x24(%rsp)
movq %rsi, 0x40(%rsp)
movl (%rsi), %esi
movq %rsi, 0x10(%rsp)
testl %esi, %esi
je 0xb8b4
movq %rdx, 0x28(%rsp)
movq (%rdx), %rax
movq %rax, 0x30(%rsp)
movsbq (%rax), %rax
movl 0x1000(%rdi,%rax,4), %eax
movq %rcx, 0x8(%rsp)
movl $0x0, (%rcx)
movq %rax, 0x38(%rsp)
incl %eax
movl %eax, 0x1c(%rsp)
movb $0x1, %bl
movl $0x1, %r15d
xorl %r12d, %r12d
leaq 0x16a65(%rip), %r14     # 0x22180
cmpl 0x38(%rsp), %r15d
jle 0xb736
testb %bl, %bl
je 0xb734
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jg 0xb8a3
xorl %ebx, %ebx
movl %r15d, %r13d
testb %bl, %bl
setne %bpl
jne 0xb756
movq 0x10(%rsp), %rax
addl %r15d, %eax
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
movq 0x40(%rsp), %rdi
movl %r13d, %esi
callq 0x911c
movq (%rax), %rcx
movq 0x30(%rsp), %rax
movzbl (%rcx), %edx
cmpl $0x20, %edx
je 0xb7a7
testl %edx, %edx
je 0xb7e0
movzbl (%rax), %edi
movl (%r14,%rdi,4), %esi
leal -0x3(%rsi), %r8d
cmpl $0x2, %r8d
setb %r12b
cmpb %dl, %dil
jne 0xb7e0
cmpl $0x6, %esi
je 0xb7a2
movzbl 0x1(%rax), %edx
incq %rax
cmpl $0x0, (%r14,%rdx,4)
je 0xb794
incq %rcx
jmp 0xb76b
cmpb $0x20, 0x1(%rcx)
jne 0xb7b2
cmpb $0x20, (%rax)
jne 0xb7dd
decq %rcx
cmpb $0x20, 0x1(%rcx)
leaq 0x1(%rcx), %rcx
je 0xb7b5
jmp 0xb7c4
incq %rax
movzbl (%rax), %edx
cmpl $0x9, %edx
je 0xb7c1
cmpl $0x20, %edx
je 0xb7c1
cmpl $0x0, (%r14,%rdx,4)
je 0xb7c1
xorl %r12d, %r12d
jmp 0xb76b
xorl %r12d, %r12d
testb %r12b, %r12b
je 0xb7f4
movzbl (%rax), %esi
movl (%r14,%rsi,4), %esi
addl $-0x3, %esi
cmpl $0x2, %esi
jb 0xb80a
cmpb $0x0, 0x24(%rsp)
je 0xb805
movzbl (%rax), %esi
cmpl $0x6, (%r14,%rsi,4)
jne 0xb80a
movb $0x1, %sil
jmp 0xb80f
movb $0x1, %bpl
xorl %esi, %esi
testb %dl, %dl
sete %dil
testb %sil, %dil
je 0xb833
movq 0x8(%rsp), %rcx
movl %r13d, (%rcx)
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
testb %bl, %bl
je 0xb8a3
incl %r15d
jmp 0xb892
testb %bpl, %bpl
je 0xb866
testb %dl, %dl
je 0xb882
movzbl (%rcx), %edx
cmpl $0x1, (%r14,%rdx,4)
jne 0xb855
incq %rcx
movzbl (%rcx), %edx
cmpl $0x0, (%r14,%rdx,4)
jne 0xb83c
jmp 0xb846
movzbl (%rax), %ecx
incq %rax
cmpl $0x1, (%r14,%rcx,4)
je 0xb855
cmpb %dl, %cl
jge 0xb882
testb %bl, %bl
je 0xb887
cmpb $0x0, 0x20(%rsp)
je 0xb8a3
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
movl 0x1c(%rsp), %r13d
je 0xb895
jmp 0xb8a3
incl %r13d
jmp 0xb895
decl %r13d
movl %r13d, %eax
movq %rax, 0x10(%rsp)
movl %r15d, %r13d
movl %r13d, %r15d
cmpl 0x10(%rsp), %r13d
jle 0xb71b
movl $0x1, %eax
movq 0x8(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0xb8bf
jmp 0xb8ba
movl $0x1, %r15d
movl %r15d, (%rcx)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq