// File: /workspace/github_c_makefile_star2_O1/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 $0xc8, %rsp
callq 0x1926a
testl %eax, %eax
je 0x16ab7
cmpl $0x2, %eax
je 0x16828
cmpl $0x1, %eax
jne 0x16a9b
leaq 0xef89(%rip), %rbx      # 0x25760
cvtsi2sdl 0x288(%rbx), %xmm1
movsd 0x4821(%rip), %xmm0     # 0x1b008
movl $0x1, %edi
callq 0x19324
cvttsd2si %xmm0, %esi
movl %esi, 0x1f0(%rbx)
cmpl $0x0, 0x18(%rbx)
jne 0x16ab7
movl $0x288, %edi            # imm = 0x288
addq 0xb7cf(%rip), %rdi      # 0x21fe0
callq 0x911c
movq (%rax), %rax
leaq 0xea80(%rip), %rcx      # 0x252a0
movq %rax, (%rcx)
jmp 0x16ab7
movl $0x1, %edi
callq 0x192b4
movq %rax, %rbx
movl $0x2, %edi
callq 0x192b4
movq %rax, %r14
testq %rbx, %rbx
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
movl $0x1a, %edi
jne 0x16876
movq 0x10(%rbx), %rax
movl $0x24, %edi
cmpl $0x6, 0xc0(%rax)
jne 0x16876
movq 0x10(%r14), %rax
cmpl $0x6, 0xc0(%rax)
je 0x1688d
leaq 0xeee3(%rip), %rax      # 0x25760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
callq 0xd1a9
leaq 0xeecc(%rip), %r13      # 0x25760
cmpl $0x0, 0x18(%r13)
jne 0x16ac7
movq 0x10(%rbx), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x911c
movq %rax, 0x10(%rsp)
movq (%rax), %r15
testq %r15, %r15
jne 0x168d3
movq 0xb8(%r13), %rsi
addq $-0x4, %rsi
movl $0x1a, %edi
callq 0xd1a9
movq %r15, 0x18(%rsp)
movq 0x10(%r15), %rax
cmpl $0x5, 0xc0(%rax)
je 0x168fa
movq 0xb8(%r13), %rsi
addq $-0x4, %rsi
movl $0x24, %edi
callq 0xd1a9
cmpl $0x0, 0x18(%r13)
jne 0x16ac7
xorl %r15d, %r15d
cmpq $0x4, %r15
jne 0x16935
movq 0x10(%r14), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x911c
movq (%rax), %rax
movq %rax, 0x90(%rsp)
movl $0x0, 0x40(%rsp)
jmp 0x1697d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
leal 0x1(%r15), %edx
movl $0x0, (%rsp)
xorl %esi, %esi
leaq 0x60(%rsp), %rcx
leaq 0x6c(%rsp), %r8
leaq 0x68(%rsp), %r9
callq 0xf043
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x70(%rsp,%r15,8)
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
imull 0x18(%rbx), %eax
movl %eax, 0x30(%rsp,%r15,4)
movq 0x70(%rsp,%r15,8), %rbp
movl 0x30(%rsp,%r15,4), %r12d
addl 0x18(%rbp), %r12d
movl %r12d, 0x30(%rsp,%r15,4)
cmpl $0x0, 0x18(%r13)
jne 0x16ac7
movl $0x1a, %r13d
testq %rbp, %rbp
je 0x16aff
movq 0x10(%rbp), %rdi
movl 0xc0(%rdi), %eax
leaq 0x5405(%rip), %rcx      # 0x1bdc0
cmpl (%rcx,%r15,4), %eax
jne 0x16ae1
addq $0x10, %rdi
callq 0x8bb7
testl %eax, %eax
jne 0x16aff
cmpl $0x0, 0x1c(%rbp)
je 0x169f1
movq 0x10(%rbp), %rdi
addq $0x10, %rdi
incl %r12d
movl %r12d, %esi
callq 0x911c
jmp 0x169f3
xorl %eax, %eax
movq %rax, 0xa0(%rsp,%r15,8)
cmpl $0x1, %r15d
je 0x16a41
cmpl $0x4, %r15d
je 0x16a41
cmpl $0x0, 0x1c(%rbp)
jle 0x16a41
movq 0xa0(%rsp,%r15,8), %r12
xorl %r13d, %r13d
movq (%r12), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
callq 0x8bb7
testl %eax, %eax
jne 0x16ad9
incq %r13
movslq 0x1c(%rbp), %rax
addq $0x48, %r12
cmpq %rax, %r13
jl 0x16a18
incq %r15
cmpq $0x5, %r15
leaq 0xed11(%rip), %r13      # 0x25760
jne 0x16908
movq 0x10(%rsp), %rax
movslq 0xc(%rax), %rbx
movq 0x10(%r14), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x911c
movl 0xc(%rax), %ebp
testq %rbx, %rbx
je 0x16b1b
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x911c
movq %rax, %r12
jmp 0x16b1e
leaq 0xecbe(%rip), %rax      # 0x25760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
movl $0x2d, %edi
callq 0xd1a9
leaq 0xeca2(%rip), %rax      # 0x25760
movl 0x1f0(%rax), %ecx
movl %ecx, 0x6c(%rax)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r13d
jmp 0x16aff
xorl %eax, %eax
cmpq $0x1, %r15
sete %al
cmpq $0x4, %r15
leal 0x25(,%rax,4), %eax
movl $0x29, %r13d
cmovnel %eax, %r13d
leaq 0xec5a(%rip), %rax      # 0x25760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
movl %r13d, %edi
callq 0xd1a9
jmp 0x16ac7
xorl %r12d, %r12d
movq %rbx, %r14
shlq $0x5, %r14
movq %r14, %rdi
callq 0x81d0
testq %rax, %rax
je 0x16c38
movq %rax, %r15
movl %ebp, 0x20(%rsp)
movq %r14, 0x50(%rsp)
testl %ebx, %ebx
movq %r12, 0x10(%rsp)
jle 0x16bd9
movq 0x70(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0x80(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movl 0x30(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl 0x38(%rsp), %ecx
movl %ecx, 0x24(%rsp)
movq 0x88(%rsp), %r12
movl 0x3c(%rsp), %r13d
leaq 0x18(%r15), %r14
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %ebp, %edx
callq 0x193c8
movq %rax, -0x18(%r14)
movq 0x10(%rsp), %rax
movl (%rax,%rbp,4), %eax
movl %eax, -0x10(%r14)
movq 0x58(%rsp), %rdi
movl 0x24(%rsp), %esi
movl %ebp, %edx
callq 0x193c8
movq %rax, -0x8(%r14)
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x193c8
movq %rax, (%r14)
incq %rbp
addq $0x20, %r14
cmpq %rbp, %rbx
jne 0x16b89
leaq 0xeb80(%rip), %r12      # 0x25760
cmpl $0x0, 0x18(%r12)
movq %rbx, %r13
jne 0x16c83
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
movl 0x18(%rax), %esi
incl %esi
callq 0x911c
leaq 0x2c(%rsp), %r14
movq %r15, %rdi
movl %r13d, %esi
movq %rax, %rdx
movl 0x20(%rsp), %ecx
movq %r14, %r8
callq 0x9550
movl (%r14), %edi
testl %edi, %edi
je 0x16c4d
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
jmp 0x16c7e
movq 0xb8(%r13), %rsi
addq $-0x4, %rsi
movl $0x1, %edi
jmp 0x16ab2
movq %rax, %rbx
movl $0x288, %edi            # imm = 0x288
addq 0xb384(%rip), %rdi      # 0x21fe0
movl $0x1, %esi
xorl %edx, %edx
callq 0x8b6a
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x16cc2
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
movl %eax, %edi
callq 0xd1a9
testl %r13d, %r13d
movq 0x50(%rsp), %r14
jle 0x16cb5
xorl %ebx, %ebx
movq (%r15,%rbx), %rdi
callq 0x81c0
movq 0x10(%r15,%rbx), %rdi
callq 0x81c0
movq 0x18(%r15,%rbx), %rdi
callq 0x81c0
addq $0x20, %rbx
cmpq %rbx, %r14
jne 0x16c8f
movq %r15, %rdi
callq 0x81c0
jmp 0x16ab7
leaq 0xe5d7(%rip), %rax      # 0x252a0
movq %rbx, (%rax)
leaq 0x288(%r12), %rdi
movl 0x288(%r12), %esi
movl %esi, 0x1f0(%r12)
callq 0x911c
movq %rbx, (%rax)
jmp 0x16c83