// File: /workspace/github_cpp_makefile_star2_O3/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, %ebx
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
leaq 0x10(%rsp), %rdi
callq 0x10fe0
movl (%r14), %eax
movl 0x10(%r14), %ebp
cmpl %eax, %ebp
jge 0x5a95
movl %ebx, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl $0x1, %r12d
leaq 0x1fdfb(%rip), %r13     # 0x256e0
xorl %ebx, %ebx
movq 0x8(%r14), %rax
movslq %ebp, %r15
movq (%rax,%r15,8), %rsi
cmpq $-0x2, %rsi
jne 0x58fd
addl $0x2, %ebp
jmp 0x5953
movq %r13, %rdi
callq 0x1106e
cmpl $0x5, %eax
jne 0x5911
incl %ebx
xorl %r12d, %r12d
jmp 0x5953
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x1106e
cmpl $0x6, %eax
setne %al
testl %ebx, %ebx
setle %cl
andb 0xc(%rsp), %cl
orb %al, %cl
je 0x5951
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x1106e
cmpl $0x35, %eax
jne 0x5961
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x590c
decl %ebx
incl %ebp
movl (%r14), %eax
cmpl %eax, %ebp
jl 0x58e7
jmp 0x5a95
testb $0x1, 0x4(%rsp)
je 0x5975
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
jmp 0x5953
movq %r14, %rdi
movl %ebp, %esi
callq 0x7262
cmpl $0x0, 0x8(%rsp)
setne %cl
testl %eax, %eax
sete %al
testl %ebx, %ebx
jne 0x5994
orb %al, %cl
jne 0x59b5
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x1106e
movl $0x0, 0x4(%rsp)
cmpl $0x6, %eax
jne 0x590c
movslq 0x10(%r14), %rbx
movl %ebp, %r13d
subl %ebx, %r13d
setle %al
cmpl $0x1, %r12d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5a21
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %edx
leaq 0x1fd01(%rip), %rsi     # 0x256e0
leaq 0x38(%rsp), %rdi
callq 0x11e2c
movq 0x38(%rsp), %rsi
leaq 0x15d35(%rip), %rdi     # 0x1b72a
xorl %eax, %eax
callq 0x102f4
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5a17
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3320
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x5aed
movl %r13d, %r12d
shlq $0x3, %r12
movq %r12, %rdi
callq 0x3440
movq %rax, %r15
movq %rax, 0x18(%rsp)
shlq $0x3, %rbx
addq 0x8(%r14), %rbx
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3290
xorl %eax, %eax
movslq %eax, %rcx
cmpq $-0x2, (%r15,%rcx,8)
jne 0x5a79
addl $-0x3, %r13d
cmpl %r13d, %eax
jge 0x5a77
movslq %r13d, %rdx
movq 0x18(%r15,%rcx,8), %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rdx
jne 0x5a66
decl %eax
incl %eax
cmpl %r13d, %eax
jl 0x5a50
movl %r13d, 0x10(%rsp)
movl $0x0, 0x20(%rsp)
movl %r13d, 0x14(%rsp)
movl (%r14), %eax
cmpl %eax, %ebp
jge 0x5ac7
movl %ebp, 0x10(%r14)
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
movq 0x30(%rsp), %rdx
callq 0x82d3
movl %eax, %ebx
movq 0x18(%rsp), %rdi
callq 0x33c0
movq $0x0, 0x18(%rsp)
jmp 0x5aed
movq 0x18(%rsp), %rdi
callq 0x33c0
movq $0x0, 0x18(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x15c5e(%rip), %rdi     # 0x1b744
xorl %eax, %eax
callq 0x102f4
leaq 0x10(%rsp), %rdi
callq 0x10fc6
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5b31
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3320
jmp 0x5b31
jmp 0x5b2e
jmp 0x5b2e
jmp 0x5b2e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x10fc6
movq %rbx, %rdi
callq 0x3560