// File: /workspace/github_cpp_makefile_star2_O1/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 0x11118
movl 0x10(%r14), %ebp
cmpl (%r14), %ebp
jge 0x5b1e
movl %ebx, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl $0x1, %ebx
leaq 0x1fd67(%rip), %r13     # 0x256e0
xorl %r12d, %r12d
movq 0x8(%r14), %rax
movslq %ebp, %r15
movq (%rax,%r15,8), %rsi
cmpq $-0x2, %rsi
jne 0x5992
addl $0x2, %ebp
jmp 0x59ea
movq %r13, %rdi
callq 0x111aa
cmpl $0x5, %eax
jne 0x59a6
incl %r12d
xorl %ebx, %ebx
jmp 0x59ea
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x111aa
cmpl $0x6, %eax
setne %al
testl %r12d, %r12d
setle %cl
andb 0xc(%rsp), %cl
orb %al, %cl
je 0x59e7
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x111aa
cmpl $0x35, %eax
jne 0x59f6
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x59a2
decl %r12d
incl %ebp
cmpl (%r14), %ebp
jl 0x597c
jmp 0x5b1e
testb $0x1, 0x4(%rsp)
je 0x5a09
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
jmp 0x59ea
movq %r14, %rdi
movl %ebp, %esi
callq 0x734a
cmpl $0x0, 0x8(%rsp)
setne %cl
testl %eax, %eax
sete %al
testl %r12d, %r12d
jne 0x5a29
orb %al, %cl
jne 0x5a42
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %esi
movq %r13, %rdi
callq 0x111aa
cmpl $0x6, %eax
jne 0x59a2
movslq 0x10(%r14), %r12
movl %ebp, %r13d
subl %r12d, %r13d
setle %al
cmpl $0x1, %ebx
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5aad
movq 0x8(%r14), %rax
movl (%rax,%r15,8), %edx
leaq 0x1fc75(%rip), %rsi     # 0x256e0
leaq 0x38(%rsp), %rdi
callq 0x11fa0
movq 0x38(%rsp), %rsi
leaq 0x15ca9(%rip), %rdi     # 0x1b72a
xorl %eax, %eax
callq 0x10418
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5aa3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3320
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x5b77
movl %r13d, %ebx
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x3440
movq %rax, %r15
movq %rax, 0x18(%rsp)
shlq $0x3, %r12
addq 0x8(%r14), %r12
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3290
xorl %eax, %eax
movslq %eax, %rcx
cmpq $-0x2, (%r15,%rcx,8)
jne 0x5b05
addl $-0x3, %r13d
cmpl %r13d, %eax
jge 0x5b03
movslq %r13d, %rdx
movq 0x18(%r15,%rcx,8), %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rdx
jne 0x5af2
decl %eax
incl %eax
cmpl %r13d, %eax
jl 0x5adc
movl %r13d, 0x10(%rsp)
movl $0x0, 0x20(%rsp)
movl %r13d, 0x14(%rsp)
cmpl (%r14), %ebp
jge 0x5b51
movl %ebp, 0x10(%r14)
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
movq 0x30(%rsp), %rdx
callq 0x8473
movl %eax, %ebx
movq 0x18(%rsp), %rdi
callq 0x33c0
movq $0x0, 0x18(%rsp)
jmp 0x5b77
movq 0x18(%rsp), %rdi
callq 0x33c0
movq $0x0, 0x18(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x15bd4(%rip), %rdi     # 0x1b744
xorl %eax, %eax
callq 0x10418
leaq 0x10(%rsp), %rdi
callq 0x110fe
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 0x5bbb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3320
jmp 0x5bbb
jmp 0x5bb8
jmp 0x5bb8
jmp 0x5bb8
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x110fe
movq %rbx, %rdi
callq 0x3560