// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/ciclib.c
// Function: cclib_setCompiler
void cclib_setCompiler()
{
    ccInt numArgs = numBIF_args(), rtrn;
    
    
        // if we're just trying to switch compilers, allow that
    
    if (numArgs == 1)  {
        whichCompiler = (ccInt) getBIFnumArg(1, 1., (ccFloat) allCompilers.elementNum);  
        if (errCode == passed)  {
            currentCompiler = *(compiler_type **) element(&allCompilers, whichCompiler);
    }   }
    
    
        // if we pass two arguments, that means that we're defining a new compiler
    
    else if (numArgs == 2)  {
        window *argWindows[5], *arg1Window = getBIFmember(1), *arg2Window = getBIFmember(2), *arg1CompositeWindow;
        member *argMembers[5], *oneArgMember, *arg1Member;
        compiler_type *tempCompiler = NULL;
        commandTokenType *cmdTokens;
        ccInt numCommands, numOoOs, loopArg, loopCommand, *precedences, argMemberNumber, entryOffset, windowOffsets[5];
        ccInt expectedType[5] = {  string_type, int_type, string_type, string_type, int_type  };
        
        if (arg1Window == NULL)  setError(void_member_err, pcCodePtr-1);
        else if (arg2Window == NULL)  setError(void_member_err, pcCodePtr-1);
        else if (arg1Window->variable_ptr->type != array_type)  setError(not_composite_err, pcCodePtr-1);
        else if (arg2Window->variable_ptr->type != array_type)  setError(not_composite_err, pcCodePtr-1);
        if (errCode != passed)  return;
        
        arg1Member = LL_member(arg1Window->variable_ptr, 1);
        arg1CompositeWindow = arg1Member->memberWindow;

        if (arg1CompositeWindow == NULL)  setError(void_member_err, pcCodePtr-1);
        if (arg1CompositeWindow->variable_ptr->type != composite_type)  setError(not_composite_err, pcCodePtr-1);
        if (errCode != passed)  return;
        
        for (loopArg = 0; loopArg < 5; loopArg++)  {
            if (loopArg < 4)  {
                findMemberIndex(arg1CompositeWindow->variable_ptr, 0, loopArg+1, &oneArgMember, &argMemberNumber, &entryOffset, ccFalse);
                argWindows[loopArg] = oneArgMember->memberWindow;
                windowOffsets[loopArg] = arg1Window->offset * arg1Member->indices;      }
            else  {
                argWindows[loopArg] = LL_member(arg2Window->variable_ptr, 1)->memberWindow;
                windowOffsets[loopArg] = 0;         }
            windowOffsets[loopArg] += argWindows[loopArg]->offset;
            
            if (errCode != passed)  return;
            if (argWindows[loopArg] == NULL)  {  setError(void_member_err, pcCodePtr-1);  return;  }
            if (argWindows[loopArg]->variable_ptr->type != expectedType[loopArg])  {
                if (expectedType[loopArg] == string_type)  setError(string_expected_err, pcCodePtr-1);
                else  setError(not_a_number_err, pcCodePtr-1);
                return;     }
            
            if (defragmentLinkedList(&(argWindows[loopArg]->variable_ptr->mem.data)) != passed)  {
                setError(void_member_err, pcCodePtr-1);
                return;         }
            if (argWindows[loopArg]->width == 0)  argMembers[loopArg] = NULL;
            else  argMembers[loopArg] = LL_member(argWindows[loopArg]->variable_ptr, windowOffsets[loopArg]+1);
            
            if (expectedType[loopArg] == string_type)  {
            for (loopCommand = 0; loopCommand < argWindows[loopArg]->width; loopCommand++)  {
                if (defragmentLinkedList(&(argMembers[loopArg][loopCommand].memberWindow->variable_ptr->mem.data)) != passed)  {
                    setError(out_of_memory_err, pcCodePtr-1);
                    return;
        }   }}  }
        
        numCommands = arg1Member->indices;
        numOoOs = LL_member(arg2Window->variable_ptr, 1)->indices;
        if (numCommands == 0)  precedences = NULL;
        else  precedences = LL_int(&(argWindows[1]->variable_ptr->mem.data), 1);
        
        cmdTokens = (commandTokenType *) malloc(numCommands*sizeof(commandTokenType));
        
        if (cmdTokens == NULL)  setError(out_of_memory_err, pcCodePtr-1);  
        else  {
            for (loopCommand = 0; loopCommand < numCommands; loopCommand++)  {
                cmdTokens[loopCommand].cmdString =
                        (const char *) getCompilerString(argWindows[0], windowOffsets[0], loopCommand);
                cmdTokens[loopCommand].precedence = precedences[loopCommand];
                cmdTokens[loopCommand].rtrnTypeString =
                        (const char *) getCompilerString(argWindows[2], windowOffsets[2], loopCommand);
                cmdTokens[loopCommand].translation =
                        (const char *) getCompilerString(argWindows[3], windowOffsets[3], loopCommand);    }
            
            if (errCode == passed)  {
                tempCompiler = newCompiler(cmdTokens, numCommands,
                            LL_int(&(argWindows[4]->variable_ptr->mem.data), argWindows[4]->offset+1), numOoOs, &rtrn);
                if (rtrn != passed)  setError(rtrn, pcCodePtr-1);
                
                else  {
                    rtrn = addElements(&allCompilers, 1, ccFalse);
                    if (rtrn != passed)  setError(rtrn, pcCodePtr-1);
                    else  {
                        currentCompiler = tempCompiler;
                        whichCompiler = allCompilers.elementNum;
                        *(compiler_type **) element(&allCompilers, whichCompiler) = tempCompiler;
            }   }   }
            
            for (loopCommand = 0; loopCommand < numCommands; loopCommand++)  {
                free((void *) cmdTokens[loopCommand].cmdString);
                free((void *) cmdTokens[loopCommand].rtrnTypeString);
                free((void *) cmdTokens[loopCommand].translation);        }
            free((void *) cmdTokens);
    }   }
    
        // zero args is allowed -- that means the user is just requesting the current compiler number
    
    else if (numArgs != 0)  setError(wrong_argument_count_err, pcCodePtr-1);
    
    intRegister = whichCompiler;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
callq 0x170b2
testl %eax, %eax
je 0x14a78
cmpl $0x2, %eax
je 0x14a33
cmpl $0x1, %eax
jne 0x14a5e
leaq 0xfd75(%rip), %rbx      # 0x24760
cvtsi2sdl 0x288(%rbx), %xmm1
pushq $0x1
popq %rdi
movsd 0x460a(%rip), %xmm0     # 0x19008
callq 0x1715f
cvttsd2si %xmm0, %esi
movl %esi, 0x1f0(%rbx)
cmpl $0x0, 0x18(%rbx)
jne 0x14a78
movl $0x288, %edi            # imm = 0x288
addq 0xc5c1(%rip), %rdi      # 0x20fe0
callq 0x9088
movq (%rax), %rax
leaq 0xf872(%rip), %rcx      # 0x242a0
movq %rax, (%rcx)
jmp 0x14a78
pushq $0x1
popq %rdi
callq 0x170f5
movq %rax, %rbx
pushq $0x2
popq %rdi
callq 0x170f5
movq %rax, %r14
testq %rbx, %rbx
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
je 0x14a9a
pushq $0x1a
popq %rdi
jmp 0x14ab7
leaq 0xfcfb(%rip), %rax      # 0x24760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
pushq $0x2d
popq %rdi
callq 0xc7c2
leaq 0xfce1(%rip), %rax      # 0x24760
movl 0x1f0(%rax), %ecx
movl %ecx, 0x6c(%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rbx), %rax
pushq $0x24
popq %rdi
cmpl $0x6, 0xc0(%rax)
jne 0x14ab7
movq 0x10(%r14), %rax
cmpl $0x6, 0xc0(%rax)
je 0x14ace
leaq 0xfca2(%rip), %rax      # 0x24760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
callq 0xc7c2
leaq 0xfc8b(%rip), %rbp      # 0x24760
cmpl $0x0, 0x18(%rbp)
jne 0x14a88
movq 0x10(%rbx), %rdi
addq $0x10, %rdi
pushq $0x1
popq %rsi
callq 0x9088
movq %rax, 0x8(%rsp)
movq (%rax), %r15
testq %r15, %r15
jne 0x14b0b
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
pushq $0x1a
popq %rdi
callq 0xc7c2
movq %r15, 0x10(%rsp)
movq 0x10(%r15), %rax
cmpl $0x5, 0xc0(%rax)
je 0x14b30
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
pushq $0x24
popq %rdi
callq 0xc7c2
cmpl $0x0, 0x18(%rbp)
jne 0x14a88
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x14b92
cmpq $0x5, %r12
je 0x14c94
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
leal 0x1(%r12), %edx
andl $0x0, (%rsp)
xorl %esi, %esi
leaq 0x40(%rsp), %rcx
leaq 0x4c(%rsp), %r8
leaq 0x48(%rsp), %r9
callq 0xe374
movq 0x40(%rsp), %rax
movq (%rax), %r15
movq %r15, 0x70(%rsp,%r12,8)
movq 0x8(%rsp), %rax
movl 0xc(%rax), %r13d
imull 0x18(%rbx), %r13d
jmp 0x14bb0
movq 0x10(%r14), %rdi
addq $0x10, %rdi
pushq $0x1
popq %rsi
callq 0x9088
movq (%rax), %r15
movq %r15, 0x90(%rsp)
xorl %r13d, %r13d
addl 0x18(%r15), %r13d
movl %r13d, 0x50(%rsp,%r12,4)
cmpl $0x0, 0x18(%rbp)
jne 0x14a88
movq 0x10(%r15), %rdi
movl 0xc0(%rdi), %eax
leaq 0x518c(%rip), %rcx      # 0x19d60
cmpl (%rcx,%r12,4), %eax
jne 0x14c73
addq $0x10, %rdi
callq 0x8b50
testl %eax, %eax
jne 0x14c8f
cmpl $0x0, 0x1c(%r15)
je 0x14c0e
movq 0x10(%r15), %rdi
addq $0x10, %rdi
incl %r13d
movl %r13d, %esi
callq 0x9088
movq %rax, %r13
jmp 0x14c11
xorl %r13d, %r13d
cmpl $0x1, %r12d
je 0x14c1d
cmpl $0x4, %r12d
jne 0x14c2c
incq %r12
leaq 0xfb39(%rip), %rbp      # 0x24760
jmp 0x14b3d
pushq $-0x1
popq %rbp
movslq 0x1c(%r15), %rax
incq %rbp
cmpq %rax, %rbp
jge 0x14c1d
movq (%r13), %rax
addq $0x48, %r13
movq 0x10(%rax), %rdi
addq $0x10, %rdi
callq 0x8b50
testl %eax, %eax
je 0x14c2f
pushq $0x1
popq %rdi
leaq 0xfb02(%rip), %rbp      # 0x24760
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
callq 0xc7c2
jmp 0x14a88
xorl %eax, %eax
cmpq $0x1, %r12
sete %al
cmpq $0x4, %r12
leal 0x25(,%rax,4), %eax
pushq $0x29
popq %rdi
cmovnel %eax, %edi
jmp 0x14c5e
pushq $0x1a
popq %rdi
jmp 0x14c5e
movq 0x8(%rsp), %rax
movslq 0xc(%rax), %r12
movq 0x10(%r14), %rdi
addq $0x10, %rdi
pushq $0x1
popq %rsi
callq 0x9088
movl 0xc(%rax), %r14d
testq %r12, %r12
je 0x14cd2
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
pushq $0x1
popq %rsi
callq 0x9088
movq %rax, 0x10(%rsp)
jmp 0x14cdb
movq $0x0, 0x10(%rsp)
movq %r12, %rdi
shlq $0x5, %rdi
callq 0x81d0
testq %rax, %rax
je 0x14e00
movq %rax, %rbx
movl %r14d, 0x1c(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x58(%rsp), %r15d
movq 0x88(%rsp), %r14
movl 0x5c(%rsp), %ebp
xorl %r13d, %r13d
testl %r12d, %r12d
movl $0x0, %eax
movq %r12, 0x28(%rsp)
cmovgl %r12d, %eax
movq %rax, 0x8(%rsp)
movq %rbx, %r12
addq $0x18, %r12
cmpq %r13, 0x8(%rsp)
je 0x14da2
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %esi
movl %r13d, %edx
callq 0x171f8
movq %rax, -0x18(%r12)
movq 0x10(%rsp), %rax
movl (%rax,%r13,4), %eax
movl %eax, -0x10(%r12)
movq 0x30(%rsp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x171f8
movq %rax, -0x8(%r12)
movq %r14, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x171f8
movq %rax, (%r12)
incq %r13
addq $0x20, %r12
jmp 0x14d48
leaq 0xf9b7(%rip), %r12      # 0x24760
cmpl $0x0, 0x18(%r12)
jne 0x14e46
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
movl 0x18(%rax), %esi
incl %esi
callq 0x9088
leaq 0x24(%rsp), %r15
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
movl 0x1c(%rsp), %ecx
movq %r15, %r8
callq 0x9310
movl (%r15), %edi
testl %edi, %edi
je 0x14e12
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
jmp 0x14e41
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
pushq $0x1
jmp 0x14a72
movq %rax, %r14
movl $0x288, %edi            # imm = 0x288
addq 0xc1bf(%rip), %rdi      # 0x20fe0
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x8b0f
movl %eax, 0x24(%rsp)
testl %eax, %eax
je 0x14e87
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
movl %eax, %edi
callq 0xc7c2
movq 0x8(%rsp), %r15
shlq $0x5, %r15
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x14e7a
movq (%rbx,%r14), %rdi
callq 0x81c0
movq 0x10(%rbx,%r14), %rdi
callq 0x81c0
movq 0x18(%rbx,%r14), %rdi
callq 0x81c0
addq $0x20, %r14
jmp 0x14e52
movq %rbx, %rdi
callq 0x81c0
jmp 0x14a78
leaq 0xf412(%rip), %rax      # 0x242a0
movq %r14, (%rax)
leaq 0x288(%r12), %rdi
movl 0x288(%r12), %esi
movl %esi, 0x1f0(%r12)
callq 0x9088
movq %r14, (%rax)
jmp 0x14e46