// File: /workspace/github_cpp_makefile_star2_O2/rofl0r[P]ascc/cs_parser.cpp
// Function: evaluate_expression(ccInternalList*, ccCompiledScript*, int, bool)
int evaluate_expression(ccInternalList*targ,ccCompiledScript*scrip,int countbrackets, bool insideBracketedDeclaration) {
  ccInternalList ours;
  int j,ourlen=0,brackdepth=0;
  int hadMetaOnly = 1;
  bool lastWasNew = false;

  for (j=targ->pos; j < targ->length; j++) {
    if (targ->script[j] == SCODE_META) {
      j+=2;
      continue;
    }

    if (sym.get_type(targ->script[j]) == SYM_OPENPARENTHESIS)
      brackdepth++;
    else if (sym.get_type(targ->script[j]) == SYM_CLOSEPARENTHESIS && (brackdepth > 0 || !insideBracketedDeclaration)) {
      brackdepth--;
      continue;
    }
    else if (sym.get_type(targ->script[j]) == SYM_NEW)
    {
      lastWasNew = true;
    }
    else if (lastWasNew)
    {
      lastWasNew = false;
    }
    else if (((!isPartOfExpression(targ, j)) && (brackdepth == 0))
          || ((brackdepth == 0) && (countbrackets!=0))
          || sym.get_type(targ->script[j]) == SYM_CLOSEPARENTHESIS) {
      ourlen = j - targ->pos;
      if ((ourlen < 1) || (hadMetaOnly == 1)) {
        cc_error("PE01: Parse error at '%s'",sym.get_friendly_name(targ->script[j]).c_str());
        return -1;
        }
      ours.script = (long*)malloc(ourlen * sizeof(long));
      memcpy(ours.script,&targ->script[targ->pos],ourlen*sizeof(long));
      int k,l;
      for (k=0;k<ourlen;k++) {
        if (ours.script[k] == SCODE_META) {
          ourlen-=3;
          for (l=k; l < ourlen; l++)
            ours.script[l] = ours.script[l+3];
          k--;
        }
      }
      ours.length = ourlen;
      ours.pos = 0;
      ours.allocated = ourlen;
      break;
    }

    // had a real token, not just metadata
    hadMetaOnly = 0;
  }

  if (j >= targ->length) {
    free(ours.script);
    ours.script=NULL;
    cc_error("end of input reached in middle of expression");
    return -1;
    }
  targ->pos = j;
  int retcode=0;
  // we now have the expression in 'ours'
  retcode=parse_sub_expr(&ours.script[0],ours.length,scrip);

  free(ours.script);
  ours.script = NULL;
  return retcode;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
leaq 0x10(%rsp), %rdi
callq 0xfddc
movl 0x10(%r14), %ebp
pushq $0x1
popq %r12
xorl %ebx, %ebx
leaq 0x20112(%rip), %r13     # 0x256f0
movl $0x0, 0x4(%rsp)
movl (%r14), %eax
cmpl %eax, %ebp
jge 0x577b
movq 0x8(%r14), %rax
movslq %ebp, %r15
movq (%rax,%r15,8), %rsi
cmpq $-0x2, %rsi
jne 0x5607
addl $0x2, %ebp
jmp 0x565d
movq %r13, %rdi
callq 0xfe60
cmpl $0x5, %eax
jne 0x561b
incl %ebx
xorl %r12d, %r12d
jmp 0x565d
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0xfe60
cmpl $0x6, %eax
setne %al
testl %ebx, %ebx
setle %cl
andb 0xc(%rsp), %cl
orb %al, %cl
je 0x565b
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0xfe60
cmpl $0x35, %eax
jne 0x5661
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x5616
decl %ebx
incl %ebp
jmp 0x55e6
testb $0x1, 0x4(%rsp)
je 0x5675
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
jmp 0x565d
movq %r14, %rdi
movl %ebp, %esi
callq 0x6c5a
cmpl $0x0, 0x8(%rsp)
setne %cl
testl %eax, %eax
sete %al
testl %ebx, %ebx
jne 0x5694
orb %al, %cl
jne 0x56b5
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0xfe60
movl $0x0, 0x4(%rsp)
cmpl $0x6, %eax
jne 0x5616
movslq 0x10(%r14), %rbx
movl %ebp, %r13d
subl %ebx, %r13d
setle %al
cmpl $0x1, %r12d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x570b
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %edx
leaq 0x20011(%rip), %rsi     # 0x256f0
leaq 0x38(%rsp), %rdi
callq 0x10864
movq 0x38(%rsp), %rsi
leaq 0x14015(%rip), %rdi     # 0x1970a
xorl %eax, %eax
callq 0xf258
leaq 0x38(%rsp), %rdi
callq 0x31a0
jmp 0x57c8
movl %r13d, %r12d
shlq $0x3, %r12
movq %r12, %rdi
callq 0x3430
movq %rax, %r15
movq %rax, 0x18(%rsp)
shlq $0x3, %rbx
addq 0x8(%r14), %rbx
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3280
xorl %eax, %eax
cmpl %r13d, %eax
jge 0x5769
movslq %eax, %rcx
cmpq $-0x2, (%r15,%rcx,8)
jne 0x5765
addl $-0x3, %r13d
movslq %r13d, %rdx
cmpq %rdx, %rcx
jge 0x5763
movq 0x18(%r15,%rcx,8), %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
jmp 0x5750
decl %eax
incl %eax
jmp 0x573a
movl %r13d, 0x10(%rsp)
andl $0x0, 0x20(%rsp)
movl %r13d, 0x14(%rsp)
movl (%r14), %eax
cmpl %eax, %ebp
jge 0x57aa
movl %ebp, 0x10(%r14)
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
movq 0x30(%rsp), %rdx
callq 0x7b57
movl %eax, %ebx
movq 0x18(%rsp), %rdi
callq 0x33a0
andq $0x0, 0x18(%rsp)
jmp 0x57cb
movq 0x18(%rsp), %rdi
callq 0x33a0
andq $0x0, 0x18(%rsp)
leaq 0x13f63(%rip), %rdi     # 0x19724
xorl %eax, %eax
callq 0xf258
pushq $-0x1
popq %rbx
leaq 0x10(%rsp), %rdi
callq 0xfdd6
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x31a0
jmp 0x57fe
jmp 0x57fb
jmp 0x57fb
jmp 0x57fb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xfdd6
movq %rbx, %rdi
callq 0x3560