// File: /workspace/github_c_makefile_star2_O2/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 %r8d, %r13d
movl %ecx, 0x8(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq (%rsi), %r15
movsbq (%r15), %r12
movq %r12, %rbp
shlq $0x5, %rbp
movq %rdi, (%rsp)
addq %rdi, %rbp
leaq 0x1(%r15), %rax
pushq $0x1
popq %r14
leaq 0x17094(%rip), %rbx     # 0x21180
movl %r12d, %ecx
testb %cl, %cl
je 0xa11c
leal -0x1e(%rcx), %edx
cmpb $-0xf, %dl
ja 0xa11c
movzbl %cl, %ecx
movl (%rbx,%rcx,4), %ecx
testb %r13b, %r13b
je 0xa10e
leal -0x3(%rcx), %edx
cmpl $0x1, %edx
ja 0xa11c
cmpl $0x1, %ecx
sbbl $-0x1, %r14d
movb (%rax), %cl
incq %rax
jmp 0xa0ef
movl %r9d, 0x1c(%rsp)
movl %r14d, %edi
callq 0x81d0
testq %rax, %rax
je 0xa22b
movq %rax, %rdx
testb %r12b, %r12b
je 0xa16d
leal -0x1e(%r12), %ecx
cmpb $-0xf, %cl
ja 0xa16d
movzbl %r12b, %ecx
movl (%rbx,%rcx,4), %ecx
testb %r13b, %r13b
je 0xa15a
addl $-0x3, %ecx
cmpl $0x2, %ecx
jb 0xa15e
jmp 0xa16d
testl %ecx, %ecx
je 0xa164
movb %r12b, (%rdx)
incq %rdx
movb 0x1(%r15), %r12b
incq %r15
jmp 0xa135
movb $0x0, (%rdx)
leaq 0x30(%rsp), %rdx
movq %rax, 0x10(%rsp)
movq %rax, (%rdx)
movsbl %r13b, %r9d
leaq 0xc(%rsp), %rcx
pushq $0x1
popq %r8
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0xaf9e
movl %eax, 0x18(%rsp)
testl %eax, %eax
je 0xa239
movl 0xc(%rsp), %r12d
movq %rbp, %rdi
movl %r12d, %esi
callq 0x9088
movq %rax, %rbp
cmpl $0x0, 0x18(%rsp)
je 0xa27a
movq 0x10(%rsp), %rdi
callq 0x81c0
cmpl $0x0, 0x78(%rsp)
movq 0x28(%rsp), %rdx
jne 0xa202
movl 0x1c(%rsp), %esi
testb %sil, %sil
setne %al
movb 0x70(%rsp), %dil
testb %dil, %dil
sete %cl
testb %cl, %al
jne 0xa1f6
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rbp)
orb %sil, %dil
je 0xa202
movl 0x8(%rsp), %eax
movl %eax, 0x8(%rbp)
movl 0x80(%rsp), %eax
movl %eax, 0x10(%rbp)
movq 0x20(%rsp), %rax
movq %r15, (%rax)
xorl %ebx, %ebx
testq %rdx, %rdx
je 0xa2b2
movq (%rbp), %rax
movq %rax, (%rdx)
jmp 0xa2b2
movq (%rsp), %rdi
callq 0x9fbe
pushq $0x1
popq %rbx
jmp 0xa2b2
testb %r13b, %r13b
jne 0xa255
movq 0x20(%rsp), %rax
movq (%rax), %rax
movsbq (%rax), %rax
movq (%rsp), %rcx
incl 0x1000(%rcx,%rax,4)
movl 0xc(%rsp), %r12d
pushq $0x1
popq %rcx
movq %rbp, %rdi
movl %r12d, %esi
movl %ecx, %edx
callq 0x8496
testl %eax, %eax
je 0xa1a7
movl %eax, %ebx
movq (%rsp), %rdi
jmp 0xa2ad
movq 0x10(%rsp), %rax
movq %rax, (%rbp)
testb %r13b, %r13b
je 0xa1ca
movq (%rsp), %r13
leaq 0x14a0(%r13), %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
je 0xa2c3
movl %eax, %ebx
movq %r13, %rdi
callq 0x9fbe
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r12), %esi
movq %r12, %rdi
callq 0x9088
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
decl %r14d
movl %r14d, 0x8(%rax)
jmp 0xa1ca