// File: /workspace/github_c_makefile_star2_O0/heltilda[P]cicada/cmpile.c
// Function: relinkExpression
ccInt relinkExpression(compiler_type *compiler, ccInt *loopToken, ccInt topToken, ccInt endTokenType, ccInt expectedType,
        ccInt **lastOrderedToken, ccBool **lastRtrnTypes, ccInt *lastTokenToFix)
{
    ccInt rtrn, oneTokenType = 0, *enclosedArgs;
    tokenSpecType *oneSpec;
    linkedlist OoOblock;
    
    rtrn = newLinkedList(&OoOblock, 0, sizeof(ccInt), 2., ccFalse);
    if (rtrn != passed)  return rtrn;
    
    
        // loop over all tokens in our current block
    
    while (*loopToken <= topToken)  {
        
        scriptTokenType *oneScriptToken = scriptToken(*loopToken);
        oneTokenType = oneScriptToken->tokenID;
        if (oneTokenType == endTokenType)  break;
        
        
            // decide whether we've hit the end of a sentence or sentence block
        
        oneSpec = tokenSpec(oneTokenType);
        if (oneSpec->prevToken != 0)  {
            errPosition = oneScriptToken->tokenCharNum;
            return unexpected_token_err;       }
        
        
            // jot down the token for future reordering
        
        rtrn = addElements(&OoOblock, 1, ccFalse);
        if (rtrn != passed)  return rtrn;
        *LL_int(&OoOblock, OoOblock.elementNum) = *loopToken;
        
        
            // if the token expects a nextToken, recursively reorder everything from here to nextToken.
            // Multiple nextTokens are chained together here via their nextExpression fields
        
        enclosedArgs = &(oneScriptToken->enclosedArgs);
        
        while (scriptToken(*loopToken)->nextScriptToken != 0)  {
            
            ccInt previousScriptToken = *loopToken;
            
            (*loopToken)++;
            
            rtrn = relinkExpression(compiler, loopToken, topToken, oneSpec->nextToken, oneSpec->rightArgType,
                        &enclosedArgs, &(oneScriptToken->rtrnTypes), &(oneScriptToken->adapterTokenToFix));
            if (rtrn != passed)  {
                if ((rtrn == arg_expected_err) && (errPosition == 0))  errPosition = scriptToken(*loopToken)->tokenCharNum;
                return rtrn;        }
            
            scriptToken(previousScriptToken)->nextScriptToken = *loopToken;
            
            oneTokenType = scriptToken(*loopToken)->tokenID;
            oneSpec = tokenSpec(oneTokenType);        }
        
        
            // advance to the next token
        
        (*loopToken)++;
    }
    
    
        // if there's an ending token we're expecting, we'd better have ended with it
    
    if ((endTokenType != 0) && (oneTokenType != endTokenType))  {
        errPosition = lastScriptChar;
        expectedTokenName = tokenSpec(endTokenType)->name;
        return token_expected_err;       }
    
    
        // after we've recorded all the tokens in this expression, we do the reordering
    
    rtrn = relinkBestToken(compiler, &OoOblock, 1, OoOblock.elementNum, expectedType, lastOrderedToken, lastRtrnTypes, lastTokenToFix);
    
    deleteLinkedList(&OoOblock);
    
    return rtrn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
leaq -0x68(%rbp), %rdi
xorl %ecx, %ecx
movl $0x4, %edx
movsd 0x143ad(%rip), %xmm0    # 0x22020
movl %ecx, %esi
callq 0x8460
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xdc8e
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdeee
jmp 0xdc90
movq -0x18(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jg 0xde6e
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xdccf
jmp 0xde6e
movq -0x10(%rbp), %rdi
addq $0x1200, %rdi           # imm = 0x1200
movl -0x38(%rbp), %esi
callq 0x9700
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0xdd09
movq -0x70(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x1e59b(%rip)     # 0x2c298
movl $0xa, -0x4(%rbp)
jmp 0xdeee
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xdd2d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdeee
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x78(%rbp)
movl -0x68(%rbp), %esi
leaq -0x68(%rbp), %rdi
callq 0x9700
movl -0x78(%rbp), %ecx
movl %ecx, (%rax)
movq -0x70(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x9700
cmpl $0x0, 0x14(%rax)
je 0xde5e
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x48(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x48(%rbp), %rax
movl 0x14(%rax), %r8d
movq -0x70(%rbp), %r10
addq $0x28, %r10
movq -0x70(%rbp), %rax
addq $0x30, %rax
leaq -0x40(%rbp), %r9
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xdc30
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xde05
cmpl $0xc, -0x34(%rbp)
jne 0xddfa
cmpl $0x0, 0x1e4bf(%rip)     # 0x2c298
jne 0xddfa
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movl 0x4(%rax), %eax
movl %eax, 0x1e49e(%rip)     # 0x2c298
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdeee
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movl -0x74(%rbp), %esi
callq 0x9700
movl -0x7c(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rdi
addq $0x1440, %rdi           # imm = 0x1440
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1200, %rdi           # imm = 0x1200
movl -0x38(%rbp), %esi
callq 0x9700
movq %rax, -0x48(%rbp)
jmp 0xdd53
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xdc90
cmpl $0x0, -0x20(%rbp)
je 0xdeae
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0xdeae
movl 0x1e426(%rip), %eax     # 0x2c2a8
movl %eax, 0x1e410(%rip)     # 0x2c298
movq -0x10(%rbp), %rdi
addq $0x1200, %rdi           # imm = 0x1200
movl -0x20(%rbp), %esi
callq 0x9700
movq (%rax), %rax
movq %rax, 0x1e3fb(%rip)     # 0x2c2a0
movl $0xb, -0x4(%rbp)
jmp 0xdeee
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %ecx
movl -0x24(%rbp), %r8d
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
leaq -0x68(%rbp), %rsi
movl $0x1, %edx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xe5b0
movl %eax, -0x34(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x8540
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)