// File: /workspace/github_c_makefile_star2_O1/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, (%rsp)
movq %rdx, %rbx
movq %rdi, %r14
movq %rsi, 0x28(%rsp)
movq (%rsi), %r12
movsbq (%r12), %rbp
testq %rbp, %rbp
sete %al
leal -0x1e(%rbp), %ecx
cmpb $-0xe, %cl
setae %cl
movl $0x1, %r15d
orb %al, %cl
jne 0xa4fb
leaq 0x1(%r12), %rax
leaq 0x17cb4(%rip), %rcx     # 0x22180
movl %ebp, %edx
movzbl %dl, %edx
testb %r13b, %r13b
je 0xa4e1
movl (%rcx,%rdx,4), %esi
addl $-0x3, %esi
cmpl $0x1, %esi
ja 0xa4fb
cmpl $0x1, (%rcx,%rdx,4)
sbbl $-0x1, %r15d
movb (%rax), %dl
testb %dl, %dl
je 0xa4fb
leal -0x1e(%rdx), %esi
incq %rax
cmpb $-0xe, %sil
jb 0xa4ce
movl %r9d, 0x24(%rsp)
movl %r15d, %edi
callq 0x81d0
testq %rax, %rax
je 0xa571
shlq $0x5, %rbp
addq %r14, %rbp
movq %rax, 0x30(%rsp)
movb (%r12), %cl
testb %cl, %cl
sete %sil
leal -0x1e(%rcx), %edx
cmpb $-0xe, %dl
setae %dl
orb %sil, %dl
jne 0xa583
leaq 0x17c48(%rip), %rdx     # 0x22180
movq %rax, %r8
movzbl %cl, %esi
testb %r13b, %r13b
je 0xa54e
movl (%rdx,%rsi,4), %edi
addl $-0x3, %edi
cmpl $0x1, %edi
ja 0xa586
cmpl $0x0, (%rdx,%rsi,4)
je 0xa55a
movb %cl, (%r8)
incq %r8
movb 0x1(%r12), %cl
incq %r12
testb %cl, %cl
je 0xa586
leal -0x1e(%rcx), %esi
cmpb $-0xe, %sil
jb 0xa53b
jmp 0xa586
movq %r14, %rdi
callq 0xa394
movl $0x1, %ebx
jmp 0xa6fd
movq %rax, %r8
movq %rbx, 0x18(%rsp)
leaq 0x30(%rsp), %rdx
movq %r8, (%rdx)
movb $0x0, (%r8)
movq %rax, 0x10(%rsp)
movq %rax, (%rdx)
movsbl %r13b, %r9d
leaq 0x4(%rsp), %rcx
movq %r14, 0x8(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movl $0x1, %r8d
callq 0xb6af
movl %eax, %r14d
testl %eax, %eax
je 0xa64b
movl 0x4(%rsp), %esi
movq %rbp, %rdi
callq 0x911c
movq %rax, %rbp
testl %r14d, %r14d
je 0xa694
movq 0x10(%rsp), %rdi
callq 0x81c0
movq 0x18(%rsp), %rdi
movl 0x80(%rsp), %eax
cmpl $0x0, 0x78(%rsp)
jne 0xa629
movb 0x70(%rsp), %cl
movl 0x24(%rsp), %r8d
testb %r8b, %r8b
setne %dl
testb %cl, %cl
sete %sil
testb %sil, %dl
jne 0xa61e
movl (%rsp), %edx
movl %edx, 0xc(%rbp)
orb %r8b, %cl
je 0xa629
movl (%rsp), %ecx
movl %ecx, 0x8(%rbp)
movl %eax, 0x10(%rbp)
movq 0x28(%rsp), %rax
movq %r12, (%rax)
xorl %ebx, %ebx
testq %rdi, %rdi
je 0xa6fd
movq (%rbp), %rax
movq %rax, (%rdi)
jmp 0xa6fd
testb %r13b, %r13b
jne 0xa668
movq 0x28(%rsp), %rax
movq (%rax), %rax
movsbq (%rax), %rax
movq 0x8(%rsp), %rcx
incl 0x1000(%rcx,%rax,4)
movl 0x4(%rsp), %esi
movq %rbp, %rdi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x84af
testl %eax, %eax
je 0xa5c9
movl %eax, %ebx
movq 0x8(%rsp), %rdi
callq 0xa394
jmp 0xa6fd
movq 0x10(%rsp), %rax
movq %rax, (%rbp)
testb %r13b, %r13b
movq 0x18(%rsp), %rdi
je 0xa5f0
movq 0x8(%rsp), %r13
leaq 0x14a0(%r13), %r14
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8b6a
movl %eax, %ebx
testl %eax, %eax
je 0xa6d6
movq %r13, %rdi
callq 0xa394
jmp 0xa6f0
movl (%r14), %esi
movq %r14, %rdi
callq 0x911c
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
decl %r15d
movl %r15d, 0x8(%rax)
testl %ebx, %ebx
movq 0x18(%rsp), %rdi
je 0xa5f0
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq