// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/cmpile.c
// Function: writeTokenOps
ccInt writeTokenOps(compiler_type *compiler, ccInt theToken, ccBool replaceCommandWords)
{
    ccInt nextOpPosition, loopToken, loopJump, rtrn;
    ccInt tokenCharNum = scriptToken(theToken)->tokenCharNum;
    ccInt jumpMarkers[9], jumps[9], jumpTo[9], numJumps = 0;
    ccInt theTokenID = scriptToken(theToken)->tokenID;
    tokenSpecType *theTokenSpec = tokenSpec(theTokenID);
    
    
        // transcribe the bytecode words of our operator
    
    loopToken = 1;
    while (loopToken <= theTokenSpec->numCodeWords)  {
        
        ccInt *toWrite = LL_int(&(compiler->allCodeWords), theTokenSpec->firstCodeWord + loopToken-1);
        ccInt loopWrite, numTimesToWrite = 1;
        ccBool regularCommand = ccTrue;
        
        nextOpPosition = compiler->bytecode.elementNum + 1;
        
        
            // handle special bytecode commands in the code word sequence
        
        if (toWrite[0] == 0)  {
        if ((replaceCommandWords) || (toWrite[1] <= 1))  {
            
            regularCommand = ccFalse;
            
            
                // maybe we just wanted to write command #0 -- this is represented in bytecode by (0, 0)
            
            if (toWrite[1] == 0)  {
                
                if ((!replaceCommandWords) && (theTokenID != 3))  numTimesToWrite = 2;
                
                loopToken++;
                regularCommand = ccTrue;        }
            
            
                // if we are to write an argument of the operator, we call this function for the n'th argument
                // command is (0, 1, arg #)
            
            else if (toWrite[1] == 1)  {
                
                ccInt theArg, numArgsAhead;
                
                loopToken += 3;
                
                theArg = scriptToken(theToken)->firstArg;
                numArgsAhead = toWrite[2]-1;
                
                while (numArgsAhead > 0)  {
                    theArg = scriptToken(theArg)->nextExpression;
                    if (theArg == 0)  break;
                    numArgsAhead--;     }
                
                if (theArg != 0)  {
                    rtrn = writeTokenOps(compiler, theArg, replaceCommandWords);
                    if (rtrn != passed)  return rtrn;
            }   }
            
                // the code sequence for a jump-position marker is (0, 2, marker #)
            
            else if (toWrite[1] == 2)  {
                
                jumpMarkers[toWrite[2]-1] = nextOpPosition;
                
                loopToken += 3;            }
            
            
                // a jump command is represented by (0, 3, marker #)
            
            else if (toWrite[1] == 3)  {
                
                rtrn = addElements(&(compiler->bytecode), 1, ccFalse);
                if (rtrn == passed)  rtrn = addElements(&(compiler->opCharNum), 1, ccFalse);
                if (rtrn != passed)  return rtrn;
                
                *LL_int(&(compiler->opCharNum), nextOpPosition) = tokenCharNum;
                
                jumpTo[numJumps] = toWrite[2];
                jumps[numJumps] = nextOpPosition;
                numJumps++;
                
                loopToken += 3;     }
            
            
                // a new hidden variable is represented by (0, 4)
            
            else if (toWrite[1] == 4)  {
                
                compiler->anonymousMemberNum--;
                toWrite = &(compiler->anonymousMemberNum);
                regularCommand = ccTrue;
                
                loopToken++;
        }}  }
        
        
            // if it's a regular bytecode command, just copy it into the bytecode array
        
        if (regularCommand)  {
            loopToken++;
            for (loopWrite = 0; loopWrite < numTimesToWrite; loopWrite++)  {
                rtrn = addElements(&(compiler->bytecode), 1, ccFalse);
                if (rtrn == passed)  rtrn = addElements(&(compiler->opCharNum), 1, ccFalse);
                if (rtrn != passed)  return rtrn;
                
                *LL_int(&(compiler->bytecode), nextOpPosition+loopWrite) = *toWrite;
                *LL_int(&(compiler->opCharNum), nextOpPosition+loopWrite) = tokenCharNum;
    }   }   }
    
    
        // fill in all the jump offsets after the bytecode has been transcribed
    
    for (loopJump = 0; loopJump < numJumps; loopJump++)  {
        *LL_int(&(compiler->bytecode), jumps[loopJump]) = jumpMarkers[jumpTo[loopJump]-1] - jumps[loopJump];    }
    
    
        // next, copy any constant data into the bytecode
    
    if (scriptToken(theToken)->constData != NULL)  {
        
        ccInt loopInt, numInts = scriptToken(theToken)->constDataSize;
        
        nextOpPosition = compiler->bytecode.elementNum + 1;
        
        rtrn = addElements(&(compiler->bytecode), numInts, ccFalse);
        if (rtrn != passed)  return rtrn;
        
        setElements(&(compiler->bytecode), nextOpPosition, nextOpPosition+numInts-1,
                        (void *) scriptToken(theToken)->constData);
        
        if (!replaceCommandWords)  {
        for (loopInt = 0; loopInt < numInts; loopInt++)  {
        if (*LL_int(&(compiler->bytecode), nextOpPosition+loopInt) == 0)  {
            rtrn = insertElements(&(compiler->bytecode), nextOpPosition+loopInt+1, numInts, ccTrue);
            if (rtrn != passed)  return rtrn;
            numInts++;
            loopInt++;      // get past the new 0
        }}}
        
        rtrn = addElements(&(compiler->opCharNum), numInts, ccFalse);
        if (rtrn != passed)  return rtrn;
        
        for (loopInt = 1; loopInt <= numInts; loopInt++)  {
            *LL_int(&(compiler->opCharNum), nextOpPosition+loopInt-1) = tokenCharNum;
    }   }
    
    return passed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, %r12
leaq 0x1440(%rdi), %r14
movq %r14, %rdi
callq 0x9088
movl 0x4(%rax), %eax
movl %eax, 0xc(%rsp)
movq %r14, 0x28(%rsp)
movq %r14, %rdi
movl %ebx, 0x10(%rsp)
movl %ebx, %esi
callq 0x9088
movl (%rax), %ebp
leaq 0x1200(%r12), %rdi
movl %ebp, %esi
callq 0x9088
leaq 0x1220(%r12), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x1460(%r12), %r14
testb %r15b, %r15b
sete %dl
leaq 0x143c(%r12), %rcx
movq %rcx, 0x38(%rsp)
movq %r12, 0x30(%rsp)
leaq 0x1480(%r12), %rbx
cmpl $0x3, %ebp
movq %rax, %r13
setne %cl
andb %dl, %cl
movzbl %cl, %eax
incl %eax
movl %eax, 0x24(%rsp)
movq $0x0, 0x18(%rsp)
pushq $0x1
popq %rax
movl %r15d, 0x14(%rsp)
movsbl %r15b, %ecx
movl %ecx, 0x20(%rsp)
movl %eax, %ebp
movq %r13, 0x40(%rsp)
cmpl 0x30(%r13), %ebp
jg 0xbb35
movl 0x2c(%r13), %eax
leal (%rax,%rbp), %esi
decl %esi
movq 0x48(%rsp), %rdi
callq 0x9088
movq %rax, %r12
movl (%r14), %r15d
incl %r15d
cmpl $0x0, (%rax)
jne 0xb994
movl 0x4(%r12), %eax
cmpb $0x0, 0x14(%rsp)
jne 0xba12
cmpl $0x1, %eax
jle 0xba12
movq %rbp, (%rsp)
pushq $0x1
popq %r13
movl %r13d, %ebp
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
subl $0x1, %ebp
jb 0xba04
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
movq %rbx, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
movl (%r12), %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x9088
movl %r13d, (%rax)
pushq $0x1
popq %r13
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9088
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
incl %r15d
jmp 0xb9a9
movq 0x40(%rsp), %r13
movq (%rsp), %rbp
jmp 0xb954
cmpl $0x4, %eax
ja 0xb954
movl %eax, %eax
leaq 0xd61c(%rip), %rcx      # 0x19040
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl %ebp
movq %rbp, (%rsp)
movl 0x24(%rsp), %ebp
pushq $0x1
popq %r13
jmp 0xb99f
movq 0x38(%rsp), %r12
decl (%r12)
incl %ebp
jmp 0xb994
movslq 0x8(%r12), %rax
movl %r15d, 0xac(%rsp,%rax,4)
addl $0x3, %ebp
jmp 0xb954
movq %rbp, (%rsp)
movq %r14, %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9088
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x8(%r12), %eax
movq 0x18(%rsp), %rcx
movslq %ecx, %rcx
movl %eax, 0x50(%rsp,%rcx,4)
movl %r15d, 0x80(%rsp,%rcx,4)
incl %ecx
movq %rcx, 0x18(%rsp)
movq (%rsp), %rbp
addl $0x3, %ebp
jmp 0xb954
addl $0x3, %ebp
movq %rbp, (%rsp)
movq 0x28(%rsp), %r15
movq %r15, %rdi
movl 0x10(%rsp), %esi
callq 0x9088
movl 0x8(%rax), %esi
movl 0x8(%r12), %ebp
incl %ebp
decl %ebp
cmpl $0x2, %ebp
jl 0xbb0e
movq %r15, %rdi
callq 0x9088
movl 0xc(%rax), %esi
testl %esi, %esi
jne 0xbaf3
jmp 0xba09
testl %esi, %esi
movq (%rsp), %rbp
je 0xb954
movq 0x30(%rsp), %rdi
movl 0x20(%rsp), %edx
callq 0xb898
testl %eax, %eax
je 0xb954
jmp 0xbc12
xorl %r15d, %r15d
movq 0x18(%rsp), %r12
testl %r12d, %r12d
cmovlel %r15d, %r12d
cmpq %r15, %r12
je 0xbb6e
movslq 0x50(%rsp,%r15,4), %rax
movl 0xac(%rsp,%rax,4), %ebp
movl 0x80(%rsp,%r15,4), %esi
subl %esi, %ebp
movq %r14, %rdi
callq 0x9088
movl %ebp, (%rax)
incq %r15
jmp 0xbb44
movq 0x28(%rsp), %r13
movq %r13, %rdi
movl 0x10(%rsp), %r15d
movl %r15d, %esi
callq 0x9088
cmpq $0x0, 0x18(%rax)
je 0xbc10
movq %r13, %rdi
movl %r15d, %esi
callq 0x9088
movl 0x20(%rax), %ebp
movl (%r14), %r12d
movq %r14, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
movl %r15d, %esi
leal 0x1(%r12), %r15d
addl %ebp, %r12d
movq %r13, %rdi
callq 0x9088
movq 0x18(%rax), %rcx
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x8eaa
cmpb $0x0, 0x14(%rsp)
je 0xbc24
xorl %r14d, %r14d
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x8b0f
testl %eax, %eax
jne 0xbc12
testl %ebp, %ebp
cmovgl %ebp, %r14d
subl $0x1, %r14d
jb 0xbc10
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9088
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
incl %r15d
jmp 0xbbf4
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
cmpl %ebp, %r13d
jge 0xbbdb
leal (%r15,%r13), %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x9088
cmpl $0x0, (%rax)
jne 0xbc5c
incl %r12d
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
pushq $0x1
popq %rcx
callq 0x8496
testl %eax, %eax
jne 0xbc12
incl %ebp
incl %r13d
incl %r13d
jmp 0xbc27