// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/ciclib.c
// Function: cclib_transform
void cclib_transform()
{
    linkedlist *inputStringLL, *tempString;
    member *loopMember;
    window *compiledCodeWindow = NULL, *pathWindow = NULL, *inputStringWindow, *drawPathTo;
    variable *pathVariable = NULL;
    searchPath *newCodePath, *newCodePathStem = pcSearchPath;
    ccInt pathVarMemberCounter, firstPathVarMember = 0, counter, loopArg, loopCodeWord, rtrn;
    ccInt codeIndex, numArgs, dummy, memberOffset, fileNameLength = 0, sourceCodeLength = 0, opCharNumLength = 0;
    ccInt *holdPCCodePtr, *codeEntryPtr, *holdStartCodePtr, *holdEndCodePtr, *opCharNum = NULL, theOpChar;
    char *fileName = NULL, *sourceCode = NULL;
    char **lastArgs[3] = { &fileName, &sourceCode, (char **) &opCharNum };
    ccInt *lastArgLengths[3] = { &fileNameLength, &sourceCodeLength, &opCharNumLength };
    code_ref holdPCCodeRef;
    
    numArgs = numBIF_args();
    if ((numArgs < 1) || (numArgs > 6))  {  setError(wrong_argument_count_err, pcCodePtr-1);  return;  }
    
    
        // check & defragment the bytecode string
    
    inputStringWindow = getBIFstringArg(1);
    if (errCode != passed)  return;
    if (inputStringWindow->width == 0)  {  intRegister = passed;  return;  }
    
    inputStringLL = &(inputStringWindow->variable_ptr->mem.data);
    rtrn = defragmentLinkedList(inputStringLL);
    if (rtrn != passed)  {  setError(out_of_memory_err, pcCodePtr-1);  return;  }
    if (inputStringWindow->width % sizeof(ccInt) != 0)  {  setError(library_argument_err, pcCodePtr-1);  return;  }
    
    
        // get the destination function (argument 2)
    
    if (numArgs >= 2)  {
        compiledCodeWindow = getBIFmember(2);
        if (compiledCodeWindow != NULL)  {
            if (compiledCodeWindow->variable_ptr->type != composite_type)  {  setError(not_a_function_err, pcCodePtr-1);  return;  }
            if (compiledCodeWindow->width != 1)  {  setError(multiple_indices_not_allowed_err, pcCodePtr-1);  return;  }
    }   }
    
    
        // if a code path was provided, read that too
    
    if (numArgs >= 3)  {
        pathWindow = getBIFmember(3);
        if (pathWindow != NULL)    {
            pathVariable = pathWindow->variable_ptr;
            
            if (pathWindow->variable_ptr->type < composite_type)  {  setError(not_composite_err, pcCodePtr-1);  return;  }
            if (pathWindow->width != 1)  {  setError(multiple_indices_not_allowed_err, pcCodePtr-1);  return;  }
            
            newCodePathStem = NULL;
            pathVarMemberCounter = 0;
            while (1 == 1)  {
                pathVarMemberCounter++;
                rtrn = findMemberIndex(pathVariable, 0, pathVarMemberCounter, &loopMember, &dummy, &memberOffset, ccFalse);
                if (rtrn == invalid_index_err)  break;
                if (!loopMember->ifHidden)  {
                    if (loopMember->memberWindow != NULL)  {
                        firstPathVarMember = pathVarMemberCounter;
                        break;
    }   }   }   }   }
    
    
        // the last three optional arguments help to flag transform/runtime errors in the code
    
    for (loopArg = 4; loopArg <= numArgs; loopArg++)  {
    if (getBIFmember(loopArg) != NULL)  {
        window *tempStringWindow = getBIFstringArg(loopArg);
        if (errCode != passed)  return;
        
        tempString = &(tempStringWindow->variable_ptr->mem.data);
        rtrn = defragmentLinkedList(tempString);
        if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }
        
        *lastArgLengths[loopArg-4] = tempStringWindow->width;
        if (tempStringWindow->width == 0)  {
            *lastArgs[loopArg-4] = (char *) element(tempString, 0);     }
        else  {
            *lastArgs[loopArg-4] = (char *) element(tempString, tempStringWindow->offset+1);
    }}  }
    
    if (opCharNum != NULL)  {
        if (sourceCode == NULL)  {  setError(void_member_err, pcCodePtr-1);  return;  }
        if (inputStringWindow->width != opCharNumLength)  {  setError(out_of_range_err, pcCodePtr-1);  return;  }
        for (loopCodeWord = 0; loopCodeWord < opCharNumLength/sizeof(ccInt); loopCodeWord++)  {
        if ((opCharNum[loopCodeWord] < 1) || (opCharNum[loopCodeWord] > sourceCodeLength))  {
        if (sourceCodeLength > 0)  {            // even a blank script has an end-of-file token --> char #1 
            setError(out_of_range_err, pcCodePtr-1);
            return;
    }   }}}
    
    else if (sourceCode != NULL)  {  setError(void_member_err, pcCodePtr-1);  return;  }
    
    
        // store some important variables since we need to overwrite these temporarily while checking the bytecode
    
    holdPCCodePtr = pcCodePtr;
    holdStartCodePtr = startCodePtr;
    holdEndCodePtr = endCodePtr;
    holdPCCodeRef = PCCodeRef;
    
    
        // set the PC at the beginning of the bytecode, and run it in 'check' mode
    
    startCodePtr = LL_int(inputStringLL, inputStringWindow->offset+1);
    endCodePtr = startCodePtr + (ccInt) ceil(1.*inputStringWindow->width/sizeof(ccInt));
    pcCodePtr = startCodePtr;
    PCCodeRef.anchor = NULL;
    PCCodeRef.code_ptr = startCodePtr;
    
    checkBytecode();
    
    if ((errCode != passed) && (doPrintError))  {
        if (opCharNum == NULL)  theOpChar = 0;
        else  theOpChar = opCharNum[errIndex-1]-1;
        printError(fileName, fileNameLength, sourceCode, theOpChar, ccFalse);
        
        doPrintError = ccFalse;        }
    
    
        // restore the important variables
    
    PCCodeRef = holdPCCodeRef;
    pcCodePtr = holdPCCodePtr;
    startCodePtr = holdStartCodePtr;
    endCodePtr = holdEndCodePtr;
    
    if (errCode != passed)  return;
    
    
        // OK, it worked.  Make a new anchor for the code.
    
    if (newCodePathStem != NULL)  refPath(newCodePathStem);       // temporarily over-reference each new path as we create it
    if (firstPathVarMember != 0)    {
        
        pathVarMemberCounter = firstPathVarMember-1;
        while (1 == 1)  {
            pathVarMemberCounter++;
            rtrn = findMemberIndex(pathVariable, 0, pathVarMemberCounter, &loopMember, &dummy, &memberOffset, ccFalse);
            if (rtrn == invalid_index_err)  break;
            if ((!loopMember->ifHidden) && (loopMember->memberWindow != NULL))  {
                rtrn = drawPath(&newCodePath, loopMember->memberWindow, newCodePathStem, 1, PCCodeRef.PLL_index);
                if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }
                refPath(newCodePath);                               // so it doesn't get deleted by a later path in the same window
                derefPath(&newCodePathStem);
                newCodePathStem = newCodePath;
    }   }   }
    
    if (compiledCodeWindow != NULL)  drawPathTo = compiledCodeWindow;
    else  drawPathTo = PCCodeRef.anchor->jamb;
    
    rtrn = drawPath(&newCodePath, drawPathTo, newCodePathStem, 1, PCCodeRef.PLL_index);
    if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }
    refPath(newCodePath);
    derefPath(&newCodePathStem);
    
    
        // wipe up any existing codes in our function
    
    if (compiledCodeWindow != NULL)  {
        for (counter = 1; counter <= compiledCodeWindow->variable_ptr->codeList.elementNum; counter++)
            derefCodeRef((code_ref *) element(&(compiledCodeWindow->variable_ptr->codeList), counter));
        deleteElements(&(compiledCodeWindow->variable_ptr->codeList), 1, compiledCodeWindow->variable_ptr->codeList.elementNum);    }
    
    
        // add our new code to the Registry..
    
    rtrn = addCode(LL_int(inputStringLL, inputStringWindow->offset+1), &codeEntryPtr, &codeIndex,
            (ccInt) ceil(1.*inputStringWindow->width/sizeof(ccInt)), fileName, fileNameLength, sourceCode, opCharNum, sourceCodeLength);
    if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }
    
    
        // and to the code list of the function
    
    if (compiledCodeWindow != NULL)  {
        rtrn = addCodeRef(&(compiledCodeWindow->variable_ptr->codeList), newCodePath, codeEntryPtr, codeIndex);
        if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }        }
    
    derefCodeList(&codeRegister);
    
    resizeLinkedList(&codeRegister, 0, ccFalse);
    rtrn = addCodeRef(&codeRegister, newCodePath, codeEntryPtr, codeIndex);
    if (rtrn != passed)  {  setError(rtrn, pcCodePtr-1);  return;  }

    derefPath(&newCodePath);
    
    GL_Object.codeList = &codeRegister;
    codeNumber = 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0xf3e0(%rip), %r15      # 0x24760
leaq 0x50(%rsp), %rax
andl $0x0, (%rax)
leaq 0x4c(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x84(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x70(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x90(%rsp), %rdi
andq $0x0, (%rdi)
leaq 0x68(%rsp), %r8
andq $0x0, (%r8)
movq 0x170(%r15), %rbp
movq %rbp, 0x30(%rsp)
movq %rdi, 0xc0(%rsp)
movq %r8, 0xc8(%rsp)
movq %rsi, 0xd0(%rsp)
movq %rax, 0xa0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rdx, 0xb0(%rsp)
callq 0x170b2
movl %eax, %ebx
leal -0x7(%rbx), %eax
cmpl $-0x7, %eax
ja 0x15419
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x2d
popq %rdi
callq 0xc7c2
jmp 0x1542c
pushq $0x1
popq %r12
movl %r12d, %edi
callq 0x17280
cmpl $0x0, 0x18(%r15)
je 0x1543e
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x1c(%rax)
je 0x1546a
movq 0x10(%rax), %r13
addq $0x10, %r13
movq %r13, %rdi
movq %rax, %r14
callq 0x8b50
testl %eax, %eax
je 0x15471
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x1
jmp 0x15411
andl $0x0, 0x6c(%r15)
jmp 0x1542c
movq %r13, 0x60(%rsp)
testb $0x3, 0x1c(%r14)
je 0x1548c
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x2e
jmp 0x15411
movq %r14, 0x58(%rsp)
cmpl $0x2, %ebx
jb 0x154fc
pushq $0x2
popq %rdi
callq 0x170f5
movq %rax, %r14
testq %rax, %rax
je 0x154c2
movq 0x10(%r14), %rax
cmpl $0x5, 0xc0(%rax)
jne 0x155ee
cmpl $0x1, 0x1c(%r14)
jne 0x1575f
cmpl $0x2, %ebx
je 0x15507
pushq $0x3
popq %rdi
callq 0x170f5
testq %rax, %rax
je 0x15507
movq 0x10(%rax), %rdx
movq %rdx, 0x40(%rsp)
cmpl $0x4, 0xc0(%rdx)
jg 0x156f5
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x24
jmp 0x15411
movq $0x0, 0x38(%rsp)
jmp 0x1550c
movq %r14, 0x38(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x40(%rsp)
movl %ebx, %r14d
pushq $0x4
popq %rbx
cmpq %r14, %rbx
ja 0x15596
movl %ebx, %edi
callq 0x170f5
testq %rax, %rax
je 0x15591
movl %ebx, %edi
callq 0x17280
cmpl $0x0, 0x18(%r15)
jne 0x1542c
movq %rax, %r13
movq 0x10(%rax), %r12
addq $0x10, %r12
movq %r12, %rdi
callq 0x8b50
testl %eax, %eax
jne 0x1598a
movl 0x1c(%r13), %eax
movq 0x80(%rsp,%rbx,8), %rcx
movl %eax, (%rcx)
testl %eax, %eax
je 0x1557c
movl 0x18(%r13), %esi
incl %esi
jmp 0x1557e
xorl %esi, %esi
movq %r12, %rdi
callq 0x9088
movq 0xa0(%rsp,%rbx,8), %rcx
movq %rax, (%rcx)
incq %rbx
jmp 0x15524
movq 0x70(%rsp), %rax
movq 0x68(%rsp), %rcx
testq %rax, %rax
je 0x15600
testq %rcx, %rcx
je 0x15605
movq 0x58(%rsp), %rcx
movslq 0x1c(%rcx), %rcx
cmpl 0x84(%rsp), %ecx
jne 0x15617
shrq $0x2, %rcx
movl 0x4c(%rsp), %edx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x15629
movl (%rax,%rsi,4), %edi
testl %edi, %edi
jle 0x155e5
testl %edx, %edx
setg %r8b
cmpl %edx, %edi
setg %dil
testb %r8b, %dil
je 0x155e9
jmp 0x15617
testl %edx, %edx
jg 0x15617
incq %rsi
jmp 0x155c6
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x23
jmp 0x15411
testq %rcx, %rcx
je 0x15629
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x1a
jmp 0x15411
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x2
jmp 0x15411
movups 0xb8(%r15), %xmm0
movaps %xmm0, 0xe0(%rsp)
movq 0xc8(%r15), %r12
movups 0x208(%r15), %xmm0
movaps %xmm0, 0xf0(%rsp)
movups 0x218(%r15), %xmm0
movaps %xmm0, 0x100(%rsp)
movq 0x58(%rsp), %r14
movl 0x18(%r14), %esi
incl %esi
movq 0x60(%rsp), %rdi
callq 0x9088
movq %rax, %rbx
movq %rax, 0xc0(%r15)
cvtsi2sdl 0x1c(%r14), %xmm0
mulsd 0x398b(%rip), %xmm0     # 0x19018
callq 0x8070
cvttsd2si %xmm0, %eax
cltq
leaq (%rbx,%rax,4), %rax
movq %rax, 0xc8(%r15)
movq %rbx, 0xb8(%r15)
andq $0x0, 0x220(%r15)
movq %rbx, 0x218(%r15)
callq 0x13e09
movl 0x18(%r15), %eax
testl %eax, %eax
je 0x1579f
cmpb $0x0, 0x2a9(%r15)
je 0x1579f
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x15778
movslq 0x1c(%r15), %rcx
movl -0x4(%rax,%rcx,4), %ecx
decl %ecx
jmp 0x1577a
cmpl $0x1, 0x1c(%rax)
jne 0x1575f
movq %r14, 0x38(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0x78(%rsp), %r14
leaq 0x8c(%rsp), %r13
leaq 0x88(%rsp), %rbp
movq $0x0, 0x28(%rsp)
andl $0x0, (%rsp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0xe374
cmpl $0x1e, %eax
je 0x15771
movq 0x78(%rsp), %rax
cmpb $0x0, 0x40(%rax)
jne 0x1575a
cmpq $0x0, (%rax)
jne 0x1599c
incl %r12d
jmp 0x15724
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
pushq $0x1f
jmp 0x15411
xorl %ebp, %ebp
jmp 0x1551e
xorl %ecx, %ecx
movq 0x90(%rsp), %rdi
movl 0x50(%rsp), %esi
movq 0x68(%rsp), %rdx
xorl %r8d, %r8d
callq 0x17f79
movb $0x0, 0x2a9(%r15)
movl 0x18(%r15), %eax
movaps 0xf0(%rsp), %xmm0
movaps 0x100(%rsp), %xmm1
movups %xmm1, 0x218(%r15)
movups %xmm0, 0x208(%r15)
movapd 0xe0(%rsp), %xmm0
movupd %xmm0, 0xb8(%r15)
movq %r12, 0xc8(%r15)
testl %eax, %eax
jne 0x1542c
testq %rbp, %rbp
je 0x157ed
movq %rbp, %rdi
callq 0xec75
cmpl $0x0, 0x28(%rsp)
movq 0x38(%rsp), %r14
je 0x15891
leaq 0x78(%rsp), %rbx
leaq 0x8c(%rsp), %r12
leaq 0x88(%rsp), %rbp
movq 0x28(%rsp), %rdx
andl $0x0, (%rsp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %rdx, %r13
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xe374
cmpl $0x1e, %eax
je 0x15891
movq 0x78(%rsp), %rax
cmpb $0x0, 0x40(%rax)
jne 0x1588a
movq (%rax), %rsi
testq %rsi, %rsi
je 0x1588a
movq 0x30(%rsp), %rdx
movl 0x208(%r15), %r8d
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rcx
callq 0xecb1
testl %eax, %eax
jne 0x1598a
movq 0x20(%rsp), %rdi
callq 0xec75
leaq 0x30(%rsp), %rdi
callq 0xebb6
movq 0x20(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r13, %rdx
incl %edx
jmp 0x15817
movq %r14, %rsi
testq %r14, %r14
jne 0x158a4
movq 0x220(%r15), %rax
movq 0x18(%rax), %rsi
movq 0x30(%rsp), %rdx
movl 0x208(%r15), %r8d
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rbx
movl %ebx, %ecx
callq 0xecb1
testl %eax, %eax
movq 0x60(%rsp), %r13
jne 0x1598a
movq 0x20(%rsp), %rdi
callq 0xec75
leaq 0x30(%rsp), %rdi
callq 0xebb6
testq %r14, %r14
jne 0x158f8
jmp 0x1591a
movl %ebx, %esi
callq 0x9088
movq %rax, %rdi
callq 0xe533
incl %ebx
movq 0x10(%r14), %rdi
movl 0xd0(%rdi), %edx
addq $0xd0, %rdi
cmpl %edx, %ebx
jle 0x158e7
pushq $0x1
popq %rsi
callq 0x864f
movq 0x60(%rsp), %r13
movq 0x58(%rsp), %r12
movl 0x18(%r12), %esi
incl %esi
movq %r13, %rdi
callq 0x9088
movq %rax, %rbx
cvtsi2sdl 0x1c(%r12), %xmm0
mulsd 0x36d8(%rip), %xmm0     # 0x19018
callq 0x8070
cvttsd2si %xmm0, %ecx
movq 0x90(%rsp), %r8
movl 0x50(%rsp), %r9d
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rdx
movl 0x4c(%rsp), %esi
movl %esi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rax, (%rsp)
leaq 0x98(%rsp), %rsi
leaq 0x54(%rsp), %rdx
movq %rbx, %rdi
callq 0xed3f
testl %eax, %eax
je 0x159ab
movq 0xb8(%r15), %rsi
addq $-0x4, %rsi
movl %eax, %edi
jmp 0x15412
xorl %ebp, %ebp
movl %r12d, %eax
movq %rax, 0x28(%rsp)
jmp 0x1551e
testq %r14, %r14
je 0x159d8
movl $0xd0, %edi
movq 0x38(%rsp), %rax
addq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0x98(%rsp), %rdx
movl 0x54(%rsp), %ecx
callq 0xef62
testl %eax, %eax
jne 0x1598a
movl $0x98, %ebx
addq 0xb5fc(%rip), %rbx      # 0x20fe0
movq %rbx, %rdi
callq 0x133db
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x8b23
movq 0x20(%rsp), %rsi
movq 0x98(%rsp), %rdx
movl 0x54(%rsp), %ecx
movq %rbx, %rdi
callq 0xef62
testl %eax, %eax
jne 0x1598a
leaq 0x20(%rsp), %rdi
callq 0xebb6
leaq 0x98(%r15), %rax
movq %rax, 0x100(%r15)
movl $0x1, 0x1f4(%r15)
jmp 0x1542c