// File: /workspace/github_c_makefile_star2_O3/heltilda[P]cicada/cmpile.c
// Function: addTokenSpec
ccInt addTokenSpec(compiler_type *compiler, char **tokenCharPtr, char **newName, ccInt tokenID, ccBool isVariableName,
        ccBool expectLHarg, ccBool optionalLHarg, ccInt nthToken, ccInt varID)
{
    linkedlist *theList = compiler->tokens + ((ccInt) **tokenCharPtr);
    ccInt whichElement, ifFound, LLrtrn, numChars = 1;
    char *tokenStringCopy = NULL, *tokenStringCopy2, *tokenChar = *tokenCharPtr;
    tokenStringType *oneTokenString;
    
    
        // calculate the length of the token string, so we know how much memory to allocate
    
    while ( (*tokenChar != 0) && ((*tokenChar < *type0arg) || (*tokenChar > *commentarg)) )  {
        if ((isVariableName) && (lettertype(tokenChar) != a_letter) && (lettertype(tokenChar) != a_number))  break;
        if (lettertype(tokenChar) != unprintable)  numChars++;
        tokenChar++;    }
    
    
        // allocate memory for our copy of the string
    
    tokenStringCopy = (char *) malloc(numChars);
    if (tokenStringCopy == NULL)  {
        freeCompiler(compiler);
        return out_of_memory_err;        }
    
    
        // finally, copy the string into our own memory
    
    tokenChar = *tokenCharPtr;
    tokenStringCopy2 = tokenStringCopy;
    while ( (*tokenChar != 0) && ((*tokenChar < *type0arg) || (*tokenChar > *commentarg)) )  {
        if ((isVariableName) && (lettertype(tokenChar) != a_letter) && (lettertype(tokenChar) != a_number))  break;
        if (lettertype(tokenChar) != unprintable)  {
            *tokenStringCopy2 = *tokenChar;
            tokenStringCopy2++;     }
        tokenChar++;     }
    *tokenStringCopy2 = 0;     // append a null even if there's an argument command
    
    
        // now we need to add the pointer to the appropriate tokens list
        // findToken() returns the alphabetical location in the list where we need to insert this pointer
    
    tokenStringCopy2 = tokenStringCopy;
    ifFound = findToken(compiler, theList, &tokenStringCopy2, &whichElement, ccTrue, isVariableName);
    
    if (!ifFound)  {
        if (!isVariableName)  compiler->numLanguageOps[(ccInt) **tokenCharPtr]++;
        LLrtrn = insertElements(theList, whichElement, 1, ccTrue);
        if (LLrtrn != passed)  {
            freeCompiler(compiler);
            return LLrtrn;
    }   }
    
    oneTokenString = (tokenStringType *) element(theList, whichElement);
    
    if (!ifFound)  {
        oneTokenString->name = tokenStringCopy;
        if (isVariableName)  {
            varNameType *newVarNameEntry;
            LLrtrn = addElements(&(compiler->varNames), 1, ccFalse);
            if (LLrtrn != passed)  {  freeCompiler(compiler);  return LLrtrn;  }
            
            newVarNameEntry = (varNameType *) element(&(compiler->varNames), compiler->varNames.elementNum);
            newVarNameEntry->theName = tokenStringCopy;
            newVarNameEntry->nameLength = numChars-1;
    }   }
    else  free(tokenStringCopy);       // if we already have it, then never mind
    
    if (nthToken == 0)  {
        if ((!expectLHarg) || (optionalLHarg))  oneTokenString->tokenID_noLHarg = tokenID;
        if ((expectLHarg) || (optionalLHarg))  oneTokenString->tokenID_LHarg = tokenID;        }
    
    oneTokenString->varID = varID;
    
    *tokenCharPtr = tokenChar;
    
    if (newName != NULL)  *newName = oneTokenString->name;
    
    return passed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, 0x14(%rsp)
movl %r8d, %r13d
movl %ecx, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
movq (%rsi), %r12
movsbq (%r12), %rbp
testq %rbp, %rbp
setne %al
leal -0x1e(%rbp), %ecx
cmpb $-0xe, %cl
setb %r15b
andb %al, %r15b
cmpb $0x1, %r15b
jne 0xa5d1
leaq 0x1(%r12), %rax
movl $0x1, %r14d
leaq 0x17c30(%rip), %rbx     # 0x22180
movl %ebp, %ecx
movzbl %cl, %ecx
movl (%rbx,%rcx,4), %ecx
testb %r13b, %r13b
je 0xa565
leal -0x3(%rcx), %edx
cmpl $0x1, %edx
ja 0xa57d
cmpl $0x1, %ecx
sbbl $-0x1, %r14d
movb (%rax), %cl
testb %cl, %cl
je 0xa57d
leal -0x1e(%rcx), %edx
incq %rax
cmpb $-0xe, %dl
jb 0xa552
movl %r14d, %edi
callq 0x81d0
testq %rax, %rax
je 0xa699
testb %r15b, %r15b
je 0xa5ea
movl %ebp, %ecx
movq %rax, %rsi
movq 0x8(%rsp), %r15
movzbl %cl, %edx
movl (%rbx,%rdx,4), %edx
testb %r13b, %r13b
je 0xa5b2
addl $-0x3, %edx
cmpl $0x2, %edx
jb 0xa5b6
jmp 0xa5f2
testl %edx, %edx
je 0xa5bb
movb %cl, (%rsi)
incq %rsi
movb 0x1(%r12), %cl
incq %r12
testb %cl, %cl
je 0xa5f2
leal -0x1e(%rcx), %edx
cmpb $-0xe, %dl
jb 0xa59d
jmp 0xa5f2
movl $0x1, %edi
callq 0x81d0
testq %rax, %rax
je 0xa699
movl $0x1, %r14d
movq %rax, %rsi
movq 0x8(%rsp), %r15
shlq $0x5, %rbp
addq %r15, %rbp
movb $0x0, (%rsi)
leaq 0x30(%rsp), %rdx
movq %rax, (%rdx)
movsbl %r13b, %r9d
leaq 0x18(%rsp), %rcx
movq %rax, %rbx
movq %r15, %rdi
movq %rbp, %rsi
movl $0x1, %r8d
callq 0xb567
testl %eax, %eax
je 0xa6aa
movl 0x18(%rsp), %esi
movq %rbp, %rdi
callq 0x91d8
movq %rax, %rbp
movq %rbx, %rdi
callq 0x81c0
movl 0x80(%rsp), %eax
cmpl $0x0, 0x78(%rsp)
movq 0x28(%rsp), %rdi
jne 0xa67e
movb 0x70(%rsp), %cl
cmpb $0x0, 0x14(%rsp)
setne %dl
testb %cl, %cl
sete %sil
testb %sil, %dl
jne 0xa671
movl 0x10(%rsp), %edx
movl %edx, 0xc(%rbp)
orb 0x14(%rsp), %cl
je 0xa67e
movl 0x10(%rsp), %ecx
movl %ecx, 0x8(%rbp)
movl %eax, 0x10(%rbp)
movq 0x20(%rsp), %rax
movq %r12, (%rax)
xorl %ebx, %ebx
testq %rdi, %rdi
je 0xa6f0
movq (%rbp), %rax
movq %rax, (%rdi)
jmp 0xa6f0
movq 0x8(%rsp), %rdi
callq 0xa407
movl $0x1, %ebx
jmp 0xa6f0
movq %rbx, 0x8(%rsp)
testb %r13b, %r13b
jne 0xa6c8
movq 0x20(%rsp), %rax
movq (%rax), %rax
movsbq (%rax), %rax
incl 0x1000(%r15,%rax,4)
movl 0x18(%rsp), %esi
movq %rbp, %rdi
movl %esi, 0x1c(%rsp)
movl $0x1, %edx
movl $0x1, %ecx
callq 0x84af
testl %eax, %eax
je 0xa701
movl %eax, %ebx
movq %r15, %rdi
callq 0xa407
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
movl 0x1c(%rsp), %esi
callq 0x91d8
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq %rax, (%rbp)
testb %r13b, %r13b
je 0xa640
leaq 0x14a0(%r15), %r13
movq %r13, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8bb3
testl %eax, %eax
jne 0xa6e6
movl (%r13), %esi
movq %r13, %rdi
callq 0x91d8
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
decl %r14d
movl %r14d, 0x8(%rax)
jmp 0xa640