// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movb %dl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0xb4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1200, %rdi           # imm = 0x1200
movl -0xb8(%rbp), %esi
callq 0x9700
movq %rax, -0xc0(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0xc0(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jg 0xe331
movq -0x10(%rbp), %rdi
addq $0x1220, %rdi           # imm = 0x1220
movq -0xc0(%rbp), %rax
movl 0x2c(%rax), %esi
addl -0x20(%rbp), %esi
subl $0x1, %esi
callq 0x9700
movq %rax, -0xc8(%rbp)
movl $0x1, -0xd0(%rbp)
movb $0x1, -0xd1(%rbp)
movq -0x10(%rbp), %rax
movl 0x1460(%rax), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0xc8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xe23f
cmpb $0x0, -0x15(%rbp)
jne 0xdffb
movq -0xc8(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jg 0xe23d
movb $0x0, -0xd1(%rbp)
movq -0xc8(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xe03d
cmpb $0x0, -0x15(%rbp)
jne 0xe028
cmpl $0x3, -0xb8(%rbp)
je 0xe028
movl $0x2, -0xd0(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movb $0x1, -0xd1(%rbp)
jmp 0xe23b
movq -0xc8(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xe101
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
movl 0x8(%rax), %eax
movl %eax, -0xd8(%rbp)
movq -0xc8(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0xdc(%rbp)
cmpl $0x0, -0xdc(%rbp)
jle 0xe0ca
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0xd8(%rbp), %esi
callq 0x9700
movl 0xc(%rax), %eax
movl %eax, -0xd8(%rbp)
cmpl $0x0, -0xd8(%rbp)
jne 0xe0b9
jmp 0xe0ca
movl -0xdc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0xe086
cmpl $0x0, -0xd8(%rbp)
je 0xe0fc
movq -0x10(%rbp), %rdi
movl -0xd8(%rbp), %esi
movsbl -0x15(%rbp), %edx
callq 0xdf00
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe0fa
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
jmp 0xe0fc
jmp 0xe239
movq -0xc8(%rbp), %rax
cmpl $0x2, 0x4(%rax)
jne 0xe132
movl -0x1c(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x50(%rbp,%rax,4)
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x20(%rbp)
jmp 0xe237
movq -0xc8(%rbp), %rax
cmpl $0x3, 0x4(%rax)
jne 0xe1f2
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0xe17d
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe18e
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
movl -0x2c(%rbp), %eax
movl %eax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl -0x1c(%rbp), %esi
callq 0x9700
movl -0xe8(%rbp), %ecx
movl %ecx, (%rax)
movq -0xc8(%rbp), %rax
movl 0x8(%rax), %ecx
movslq -0xb4(%rbp), %rax
movl %ecx, -0xb0(%rbp,%rax,4)
movl -0x1c(%rbp), %ecx
movslq -0xb4(%rbp), %rax
movl %ecx, -0x80(%rbp,%rax,4)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x20(%rbp)
jmp 0xe235
movq -0xc8(%rbp), %rax
cmpl $0x4, 0x4(%rax)
jne 0xe233
movq -0x10(%rbp), %rax
movl 0x143c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x143c(%rax)
movq -0x10(%rbp), %rax
addq $0x143c, %rax           # imm = 0x143C
movq %rax, -0xc8(%rbp)
movb $0x1, -0xd1(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe235
jmp 0xe237
jmp 0xe239
jmp 0xe23b
jmp 0xe23d
jmp 0xe23f
cmpb $0x0, -0xd1(%rbp)
je 0xe32c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
cmpl -0xd0(%rbp), %eax
jge 0xe32a
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0xe2ab
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe2bc
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
movq -0xc8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl -0x1c(%rbp), %esi
addl -0xcc(%rbp), %esi
callq 0x9700
movl -0xf0(%rbp), %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl -0x1c(%rbp), %esi
addl -0xcc(%rbp), %esi
callq 0x9700
movl -0xec(%rbp), %ecx
movl %ecx, (%rax)
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0xe25f
jmp 0xe32c
jmp 0xdf79
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0xe390
movslq -0x24(%rbp), %rax
movl -0xb0(%rbp,%rax,4), %eax
subl $0x1, %eax
cltq
movl -0x50(%rbp,%rax,4), %eax
movslq -0x24(%rbp), %rcx
subl -0x80(%rbp,%rcx,4), %eax
movl %eax, -0xf4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movslq -0x24(%rbp), %rax
movl -0x80(%rbp,%rax,4), %esi
callq 0x9700
movl -0xf4(%rbp), %ecx
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe338
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
cmpq $0x0, 0x18(%rax)
je 0xe597
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
movl 0x20(%rax), %eax
movl %eax, -0xe4(%rbp)
movq -0x10(%rbp), %rax
movl 0x1460(%rax), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl -0xe4(%rbp), %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe406
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
movq -0x10(%rbp), %rax
addq $0x1460, %rax           # imm = 0x1460
movq %rax, -0x108(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0x1c(%rbp), %eax
addl -0xe4(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x14(%rbp), %esi
callq 0x9700
movq -0x108(%rbp), %rdi
movl -0xfc(%rbp), %esi
movl -0xf8(%rbp), %edx
movq 0x18(%rax), %rcx
callq 0x93d0
cmpb $0x0, -0x15(%rbp)
jne 0xe516
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xe4(%rbp), %eax
jge 0xe514
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl -0x1c(%rbp), %esi
addl -0xe0(%rbp), %esi
callq 0x9700
cmpl $0x0, (%rax)
jne 0xe4fe
movq -0x10(%rbp), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl -0x1c(%rbp), %esi
addl -0xe0(%rbp), %esi
addl $0x1, %esi
movl -0xe4(%rbp), %edx
movl $0x1, %ecx
callq 0x8590
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe4e0
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0xe500
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0xe475
jmp 0xe516
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl -0xe4(%rbp), %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe53f
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe59e
movl $0x1, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xe4(%rbp), %eax
jg 0xe595
movl -0x2c(%rbp), %eax
movl %eax, -0x10c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl -0x1c(%rbp), %esi
addl -0xe0(%rbp), %esi
subl $0x1, %esi
callq 0x9700
movl -0x10c(%rbp), %ecx
movl %ecx, (%rax)
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0xe549
jmp 0xe597
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw (%rax,%rax)