// File: /workspace/github_c_makefile_star2_O3/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 0x19254
testl %eax, %eax
je 0x16a3e
cmpl $0x2, %eax
je 0x167dd
cmpl $0x1, %eax
jne 0x16a22
leaq 0xefd4(%rip), %rbx      # 0x25760
cvtsi2sdl 0x288(%rbx), %xmm1
movsd 0x486c(%rip), %xmm0     # 0x1b008
movl $0x1, %edi
callq 0x1930e
cvttsd2si %xmm0, %esi
movl %esi, 0x1f0(%rbx)
cmpl $0x0, 0x18(%rbx)
jne 0x16a3e
movl $0x288, %edi            # imm = 0x288
addq 0xb81a(%rip), %rdi      # 0x21fe0
callq 0x91d8
movq (%rax), %rax
leaq 0xeacb(%rip), %rcx      # 0x252a0
movq %rax, (%rcx)
jmp 0x16a3e
movl $0x1, %edi
callq 0x1929e
movq %rax, %rbx
movl $0x2, %edi
callq 0x1929e
movq %rax, %r14
testq %rbx, %rbx
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
movl $0x1a, %edi
jne 0x1682b
movq 0x10(%rbx), %rax
movl $0x24, %edi
cmpl $0x6, 0xc0(%rax)
jne 0x1682b
movq 0x10(%r14), %rax
cmpl $0x6, 0xc0(%rax)
je 0x16842
leaq 0xef2e(%rip), %rax      # 0x25760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
callq 0xcfa3
leaq 0xef17(%rip), %rbp      # 0x25760
cmpl $0x0, 0x18(%rbp)
jne 0x16a4e
movq 0x10(%rbx), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x91d8
movq %rax, 0x10(%rsp)
movq (%rax), %r15
testq %r15, %r15
jne 0x16887
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
movl $0x1a, %edi
callq 0xcfa3
movq %r15, 0x18(%rsp)
movq 0x10(%r15), %rax
cmpl $0x5, 0xc0(%rax)
je 0x168ae
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
movl $0x24, %edi
callq 0xcfa3
cmpl $0x0, 0x18(%rbp)
jne 0x16a4e
xorl %r13d, %r13d
cmpq $0x4, %r13
jne 0x168e3
movq 0x10(%r14), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x91d8
movq (%rax), %r15
movq %r15, 0x90(%rsp)
xorl %r12d, %r12d
jmp 0x16928
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
leal 0x1(%r13), %edx
movl $0x0, (%rsp)
xorl %esi, %esi
leaq 0x40(%rsp), %rcx
leaq 0x4c(%rsp), %r8
leaq 0x48(%rsp), %r9
callq 0xee01
movq 0x40(%rsp), %rax
movq (%rax), %r15
movq %r15, 0x70(%rsp,%r13,8)
movq 0x10(%rsp), %rax
movl 0xc(%rax), %r12d
imull 0x18(%rbx), %r12d
addl 0x18(%r15), %r12d
movl %r12d, 0x50(%rsp,%r13,4)
cmpl $0x0, 0x18(%rbp)
jne 0x16a4e
movq 0x10(%r15), %rdi
movl 0xc0(%rdi), %eax
leaq 0x5454(%rip), %rcx      # 0x1bda0
cmpl (%rcx,%r13,4), %eax
jne 0x16a6e
addq $0x10, %rdi
callq 0x8c00
testl %eax, %eax
jne 0x16a8c
cmpl $0x0, 0x1c(%r15)
je 0x16986
movq 0x10(%r15), %rdi
addq $0x10, %rdi
incl %r12d
movl %r12d, %esi
callq 0x91d8
movq %rax, %r12
jmp 0x16989
xorl %r12d, %r12d
cmpl $0x1, %r13d
je 0x169c7
cmpl $0x4, %r13d
je 0x169c7
cmpl $0x0, 0x1c(%r15)
jle 0x169c7
xorl %ebp, %ebp
movq (%r12), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
callq 0x8c00
testl %eax, %eax
jne 0x16a60
incq %rbp
movslq 0x1c(%r15), %rax
addq $0x48, %r12
cmpq %rax, %rbp
jl 0x1699e
incq %r13
cmpq $0x5, %r13
leaq 0xed8b(%rip), %rbp      # 0x25760
jne 0x168bb
movq 0x10(%rsp), %rax
movslq 0xc(%rax), %rbx
movq 0x10(%r14), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x91d8
movl 0xc(%rax), %r12d
testq %rbx, %rbx
je 0x16aa3
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x91d8
movq %rax, %r13
jmp 0x16aa6
leaq 0xed37(%rip), %rax      # 0x25760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
movl $0x2d, %edi
callq 0xcfa3
leaq 0xed1b(%rip), %rax      # 0x25760
movl 0x1f0(%rax), %ecx
movl %ecx, 0x6c(%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
leaq 0xecf4(%rip), %rbp      # 0x25760
jmp 0x16a91
xorl %eax, %eax
cmpq $0x1, %r13
sete %al
cmpq $0x4, %r13
leal 0x25(,%rax,4), %eax
movl $0x29, %edi
cmovnel %eax, %edi
jmp 0x16a91
movl $0x1a, %edi
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
callq 0xcfa3
jmp 0x16a4e
xorl %r13d, %r13d
movq %rbx, %r14
shlq $0x5, %r14
movq %r14, %rdi
callq 0x81d0
testq %rax, %rax
je 0x16bc2
movq %rax, %r15
movl %r12d, 0x20(%rsp)
movq %r14, 0x30(%rsp)
testl %ebx, %ebx
movq %r13, 0x10(%rsp)
jle 0x16b63
movq 0x70(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0x80(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movl 0x50(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl 0x58(%rsp), %ecx
movl %ecx, 0x24(%rsp)
movq 0x88(%rsp), %r12
movl 0x5c(%rsp), %r14d
leaq 0x18(%r15), %r13
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %ebp, %edx
callq 0x193b2
movq %rax, -0x18(%r13)
movq 0x10(%rsp), %rax
movl (%rax,%rbp,4), %eax
movl %eax, -0x10(%r13)
movq 0x38(%rsp), %rdi
movl 0x24(%rsp), %esi
movl %ebp, %edx
callq 0x193b2
movq %rax, -0x8(%r13)
movq %r12, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x193b2
movq %rax, (%r13)
incq %rbp
addq $0x20, %r13
cmpq %rbp, %rbx
jne 0x16b12
leaq 0xebf6(%rip), %r12      # 0x25760
cmpl $0x0, 0x18(%r12)
movq %rbx, %r13
jne 0x16c0d
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x10, %rdi
movl 0x18(%rax), %esi
incl %esi
callq 0x91d8
leaq 0x2c(%rsp), %r14
movq %r15, %rdi
movl %r13d, %esi
movq %rax, %rdx
movl 0x20(%rsp), %ecx
movq %r14, %r8
callq 0x95fc
movl (%r14), %edi
testl %edi, %edi
je 0x16bd7
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
jmp 0x16c08
movq 0xb8(%rbp), %rsi
addq $-0x4, %rsi
movl $0x1, %edi
jmp 0x16a39
movq %rax, %rbx
movl $0x288, %edi            # imm = 0x288
addq 0xb3fa(%rip), %rdi      # 0x21fe0
movl $0x1, %esi
xorl %edx, %edx
callq 0x8bb3
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x16c4c
movq 0xb8(%r12), %rsi
addq $-0x4, %rsi
movl %eax, %edi
callq 0xcfa3
testl %r13d, %r13d
movq 0x30(%rsp), %r14
jle 0x16c3f
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 0x16c19
movq %r15, %rdi
callq 0x81c0
jmp 0x16a3e
leaq 0xe64d(%rip), %rax      # 0x252a0
movq %rbx, (%rax)
leaq 0x288(%r12), %rdi
movl 0x288(%r12), %esi
movl %esi, 0x1f0(%r12)
callq 0x91d8
movq %rbx, (%rax)
jmp 0x16c0d