// File: /workspace/github_c_makefile_star2_O0/heltilda[P]cicada/ccmain.c
// Function: cicadaMain
ccInt cicadaMain(ccInt argc, char **argv)
{
    ccInt mainErrorCode = 0, startupFileNameLength, loopCompiler, rtrn;
    char *firstChar, *startupFileName;
    const char *defaultStartupFileName = "start.cicada";
    linkedlist sourceCode;
    
#ifdef CicadaTest_ON
    if (argc == 0)  TestCicada();
#endif
    
    
        // Initialize the random number generator.
    
    srand((int) time(0));
    rand();  rand();  rand();  rand();      // otherwise the first couple of random numbers are suspiciously consistent
    
    
        // initialize the compiler
    
    rtrn = newLinkedList(&allCompilers, 1, sizeof(compiler_type *), 1., ccFalse);
    if (rtrn == passed)  {
        whichCompiler = 1;
        currentCompiler = newCompiler(cicadaLanguage, cicadaLanguageNumCommands,
                        cicadaLanguageAssociativity, cicadaNumPrecedenceLevels, &rtrn);
        *(compiler_type **) element(&allCompilers, 1) = currentCompiler;         }
    
    if (rtrn != passed)  {
        printf("Error loading compiler (error code %i on command %i)\n", (int) errCode, (int) errPosition);
        return rtrn;       }
    
    
        // Set up a buffer for loading the script
    
    rtrn = newLinkedList(&sourceCode, 0, sizeof(char), 0, ccFalse);
    if (rtrn != passed)  {  printf("cicada:  %s\n", errorStrings[rtrn]);  return 1;  }
    
    
        // Open the file specified in the first argument, if given; otherwise, open start.cicada
    
    if (argc > 1)  {  printf("usage: cicada [source_file]\n");  return 1;  }
    
    if (argc == 0)  startupFileName = (char *) defaultStartupFileName;
    else  startupFileName = (char *) argv[0];
    
    startupFileNameLength = 0;
    while (startupFileName[startupFileNameLength] != 0)  startupFileNameLength++;
    
    if (loadFile(startupFileName, &sourceCode, ccTrue) != passed)  {
        printf("Error:  Could not open %s\n", startupFileName);
        return 1;      }
    
    rtrn = defragmentLinkedList(&sourceCode);
    if (rtrn != passed)  {  printf("cicada:  %s\n", errorStrings[rtrn]);  return 1;  }
    
    
        // (compile and) transform the starting script.
    
    firstChar = (char *) element(&sourceCode, 1);
    rtrn = compile(currentCompiler, firstChar);
    
    if (rtrn != passed)  {
        errCode = rtrn;
        printError(startupFileName, startupFileNameLength, firstChar, errPosition-1, ccFalse);
        return rtrn;    }
    else if (compilerWarning != passed)  {
        warningCode = compilerWarning;
        printError(startupFileName, startupFileNameLength, firstChar, errPosition-1, ccFalse);     }
    
    defragmentLinkedList(&(currentCompiler->opCharNum));
    
    
        // initialize all the global variables used by Cicada
    
    rtrn = initCicada(LL_int(&(currentCompiler->bytecode), 1), currentCompiler->bytecode.elementNum,
            startupFileName, startupFileNameLength, firstChar, LL_int(&(currentCompiler->opCharNum), 1), sourceCode.elementNum);
    if (rtrn != passed)  {  printf("Cicada error:  initialization returned \"%s\"\n", (char *) errorStrings[rtrn]);  return 1;  }
    
    
        // check the bytecode of the script (should be OK if we're using the 'default' Cicada language)
    
    startCodePtr = PCCodeRef.code_ptr;
    endCodePtr = startCodePtr + currentCompiler->bytecode.elementNum;
    
    pcCodePtr = startCodePtr;
    checkBytecode();
    
    if ((errCode != passed) || (warningCode != passed))  {
        
        printError(startupFileName, startupFileNameLength, firstChar, *LL_int(&(currentCompiler->opCharNum), errIndex)-1, ccFalse);
        
        if (errCode != passed)  return errCode;         }
    
    
        // run the script
    
    beginExecution(&PCCodeRef, ccFalse, 0, 1, 0);
    if (errCode == return_flag)  errCode = passed;
    
    
        // if there was an error in the script, print out the line that caused it (if possible)
    
    if ((errCode != passed) && (errCode != finished_signal))  {
        
        storedCodeType *errorBaseScript = storedCode(errScript.PLL_index);
        ccInt errCharNum = 0;
        
        if (errorBaseScript->opCharNum != NULL)  errCharNum = errorBaseScript->opCharNum[
                    errIndex + (ccInt) (errScript.code_ptr - errorBaseScript->bytecode) - 1] - 1;
        
        printError(errorBaseScript->fileName, -1, errorBaseScript->sourceCode, errCharNum, ccFalse);
        
        mainErrorCode = 1;         }
    
    
        // clean up after ourselves and exit
    
#ifdef CicadaTest_ON
test_MM_CountRefs();
#endif
    
    cleanUp();
    
    for (loopCompiler = 1; loopCompiler <= allCompilers.elementNum; loopCompiler++)
        freeCompiler(*(compiler_type **) element(&allCompilers, loopCompiler));
    deleteLinkedList(&allCompilers);
    
    deleteLinkedList(&sourceCode);
    
    return mainErrorCode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
leaq 0x23e8(%rip), %rax      # 0x23128
movq %rax, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x8140
movl %eax, %edi
callq 0x8160
callq 0x80b0
callq 0x80b0
callq 0x80b0
callq 0x80b0
leaq 0xb9e1(%rip), %rdi      # 0x2c750
addq $0x288, %rdi            # imm = 0x288
movl $0x1, %esi
movl $0x8, %edx
movsd 0x1280(%rip), %xmm0     # 0x22008
xorl %ecx, %ecx
callq 0x8460
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x20e0c
leaq 0xb9b1(%rip), %rax      # 0x2c750
movl $0x1, 0x1f0(%rax)
leaq 0x98c0(%rip), %rax      # 0x2a670
movl (%rax), %esi
leaq 0x98bb(%rip), %rax      # 0x2a674
movl (%rax), %ecx
leaq 0x87ee(%rip), %rdi      # 0x295b0
leaq 0x87a7(%rip), %rdx      # 0x29570
leaq -0x20(%rbp), %r8
callq 0x9c60
movq %rax, %rcx
leaq 0xb4b4(%rip), %rax      # 0x2c290
movq %rcx, (%rax)
leaq 0xb4aa(%rip), %rax      # 0x2c290
movq (%rax), %rax
movq %rax, -0x70(%rbp)
leaq 0xb95c(%rip), %rdi      # 0x2c750
addq $0x288, %rdi            # imm = 0x288
movl $0x1, %esi
callq 0x9700
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
cmpl $0x0, -0x20(%rbp)
je 0x20e3f
leaq 0xb937(%rip), %rax      # 0x2c750
movl 0x18(%rax), %esi
leaq 0xb46d(%rip), %rax      # 0x2c290
movl 0x8(%rax), %edx
leaq 0x2308(%rip), %rdi      # 0x23135
movb $0x0, %al
callq 0x8050
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x21340
leaq -0x58(%rbp), %rdi
xorl %ecx, %ecx
movl $0x1, %edx
xorps %xmm0, %xmm0
movl %ecx, %esi
callq 0x8460
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x20e86
movslq -0x20(%rbp), %rcx
leaq 0xb288(%rip), %rax      # 0x2c0f0
movq (%rax,%rcx,8), %rsi
leaq 0x22f8(%rip), %rdi      # 0x2316b
movb $0x0, %al
callq 0x8050
movl $0x1, -0x4(%rbp)
jmp 0x21340
cmpl $0x1, -0x8(%rbp)
jle 0x20ea6
leaq 0x22e5(%rip), %rdi      # 0x23178
movb $0x0, %al
callq 0x8050
movl $0x1, -0x4(%rbp)
jmp 0x21340
cmpl $0x0, -0x8(%rbp)
jne 0x20eb6
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x20ec1
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x30(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x20ee4
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x20ec8
movq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x1feb0
cmpl $0x0, %eax
je 0x20f19
movq -0x30(%rbp), %rsi
leaq 0x228f(%rip), %rdi      # 0x23195
movb $0x0, %al
callq 0x8050
movl $0x1, -0x4(%rbp)
jmp 0x21340
leaq -0x58(%rbp), %rdi
callq 0x8f70
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x20f54
movslq -0x20(%rbp), %rcx
leaq 0xb1ba(%rip), %rax      # 0x2c0f0
movq (%rax,%rcx,8), %rsi
leaq 0x222a(%rip), %rdi      # 0x2316b
movb $0x0, %al
callq 0x8050
movl $0x1, -0x4(%rbp)
jmp 0x21340
leaq -0x58(%rbp), %rdi
movl $0x1, %esi
callq 0x9700
movq %rax, -0x28(%rbp)
leaq 0xb323(%rip), %rax      # 0x2c290
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0xd490
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x20fba
movl -0x20(%rbp), %ecx
leaq 0xb7c4(%rip), %rax      # 0x2c750
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x28(%rbp), %rdx
leaq 0xb2ef(%rip), %rax      # 0x2c290
movl 0x8(%rax), %ecx
subl $0x1, %ecx
xorl %r8d, %r8d
callq 0x21350
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x21340
leaq 0xb2cf(%rip), %rax      # 0x2c290
cmpl $0x0, 0xc(%rax)
je 0x20ffb
leaq 0xb2c2(%rip), %rax      # 0x2c290
movl 0xc(%rax), %ecx
leaq 0xb778(%rip), %rax      # 0x2c750
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x28(%rbp), %rdx
leaq 0xb2a3(%rip), %rax      # 0x2c290
movl 0x8(%rax), %ecx
subl $0x1, %ecx
xorl %r8d, %r8d
callq 0x21350
jmp 0x20ffd
leaq 0xb28c(%rip), %rax      # 0x2c290
movq (%rax), %rdi
addq $0x1480, %rdi           # imm = 0x1480
callq 0x8f70
leaq 0xb276(%rip), %rax      # 0x2c290
movq (%rax), %rdi
addq $0x1460, %rdi           # imm = 0x1460
movl $0x1, %esi
callq 0x9700
movq %rax, -0x98(%rbp)
leaq 0xb254(%rip), %rax      # 0x2c290
movq (%rax), %rax
movl 0x1460(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq 0xb225(%rip), %rax      # 0x2c290
movq (%rax), %rdi
addq $0x1480, %rdi           # imm = 0x1480
movl $0x1, %esi
callq 0x9700
movq -0x98(%rbp), %rdi
movl -0x8c(%rbp), %esi
movq -0x88(%rbp), %rdx
movl -0x7c(%rbp), %ecx
movq -0x78(%rbp), %r8
movq %rax, %r9
movl -0x58(%rbp), %eax
movl %eax, (%rsp)
callq 0x217b0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x210da
movslq -0x20(%rbp), %rcx
leaq 0xb034(%rip), %rax      # 0x2c0f0
movq (%rax,%rcx,8), %rsi
leaq 0x20e9(%rip), %rdi      # 0x231b0
movb $0x0, %al
callq 0x8050
movl $0x1, -0x4(%rbp)
jmp 0x21340
leaq 0xb66f(%rip), %rax      # 0x2c750
movq 0x218(%rax), %rcx
leaq 0xb661(%rip), %rax      # 0x2c750
movq %rcx, 0xc0(%rax)
leaq 0xb653(%rip), %rax      # 0x2c750
movq 0xc0(%rax), %rcx
leaq 0xb185(%rip), %rax      # 0x2c290
movq (%rax), %rax
movslq 0x1460(%rax), %rax
shlq $0x2, %rax
addq %rax, %rcx
leaq 0xb62d(%rip), %rax      # 0x2c750
movq %rcx, 0xc8(%rax)
leaq 0xb61f(%rip), %rax      # 0x2c750
movq 0xc0(%rax), %rcx
leaq 0xb611(%rip), %rax      # 0x2c750
movq %rcx, 0xb8(%rax)
callq 0x1ad40
leaq 0xb5fe(%rip), %rax      # 0x2c750
cmpl $0x0, 0x18(%rax)
jne 0x21169
leaq 0xb5f1(%rip), %rax      # 0x2c750
cmpl $0x0, 0x20(%rax)
je 0x211ea
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq 0xb101(%rip), %rax      # 0x2c290
movq (%rax), %rdi
addq $0x1480, %rdi           # imm = 0x1480
leaq 0xb5b0(%rip), %rax      # 0x2c750
movl 0x1c(%rax), %esi
callq 0x9700
movq -0xb0(%rbp), %rdi
movl -0xa4(%rbp), %esi
movq -0xa0(%rbp), %rdx
movl (%rax), %ecx
subl $0x1, %ecx
xorl %r8d, %r8d
callq 0x21350
leaq 0xb580(%rip), %rax      # 0x2c750
cmpl $0x0, 0x18(%rax)
je 0x211e8
leaq 0xb573(%rip), %rax      # 0x2c750
movl 0x18(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x21340
jmp 0x211ea
leaq 0xb55f(%rip), %rdi      # 0x2c750
addq $0x208, %rdi            # imm = 0x208
xorl %r8d, %r8d
movl $0x1, %ecx
movl %r8d, %esi
movl %r8d, %edx
callq 0x14710
leaq 0xb53e(%rip), %rax      # 0x2c750
cmpl $0x32, 0x18(%rax)
jne 0x21226
leaq 0xb531(%rip), %rax      # 0x2c750
movl $0x0, 0x18(%rax)
leaq 0xb523(%rip), %rax      # 0x2c750
cmpl $0x0, 0x18(%rax)
je 0x212d7
leaq 0xb512(%rip), %rax      # 0x2c750
cmpl $0x33, 0x18(%rax)
je 0x212d7
leaq 0xb501(%rip), %rax      # 0x2c750
movl 0x28(%rax), %esi
leaq 0xb43f(%rip), %rdi      # 0x2c698
callq 0x9700
movq %rax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x60(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x212b1
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
leaq 0xb4cd(%rip), %rcx      # 0x2c750
movl 0x1c(%rcx), %ecx
leaq 0xb4c3(%rip), %rdx      # 0x2c750
movq 0x38(%rdx), %rdx
movq -0x60(%rbp), %rsi
movq 0x10(%rsi), %rsi
subq %rsi, %rdx
sarq $0x2, %rdx
addl %edx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rax
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x64(%rbp), %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
callq 0x21350
movl $0x1, -0x14(%rbp)
callq 0x21bc0
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0xb463(%rip), %rcx      # 0x2c750
cmpl 0x288(%rcx), %eax
jg 0x2131e
movl -0x1c(%rbp), %esi
leaq 0xb451(%rip), %rdi      # 0x2c750
addq $0x288, %rdi            # imm = 0x288
callq 0x9700
movq (%rax), %rdi
callq 0xb5b0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x212e3
leaq 0xb42b(%rip), %rdi      # 0x2c750
addq $0x288, %rdi            # imm = 0x288
callq 0x8540
leaq -0x58(%rbp), %rdi
callq 0x8540
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)