// File: /workspace/github_cpp_makefile_star2_O2/rofl0r[P]ascc/cs_parser.cpp
// Function: process_function_declaration(ccInternalList&, ccCompiledScript*, int*, int, int&, int&, int, int, int, int, int, int, int*, SymbolDef*, int)
int process_function_declaration(ccInternalList &targ, ccCompiledScript*scrip,
                                 int *funcsymptr, int vtwas, int &in_func,
                                 int &nested_level, int next_is_readonly,
                                 int is_const,
                                 int next_is_import, int isMemberFunction,
                                 int returnsPointer, int func_is_static,
								 int *isMemberFunctionPtr, SymbolDef *oldDefinition,
                 int returnsDynArray) {
  int numparams = 1;
  int funcsym = *funcsymptr;
  int varsize = sym.entries[vtwas].ssize;
  // skip the opening (
  targ.getnext();

  char functionName[MAX_SYM_LEN];
  strcpy(functionName, sym.get_name(funcsym));

  if (check_not_eof(targ))
    return -1;
  if (strcmp(sym.get_name(targ.peeknext()), "this") == 0 || sym.get_type(targ.peeknext()) == SYM_STATIC)
  {
    if(sym.get_type(targ.peeknext()) == SYM_STATIC)
      func_is_static = 1;
    // extender function, eg.  function GoAway(this Character *someone)
    targ.getnext();
	  if (sym.get_type(targ.peeknext()) != SYM_VARTYPE)
	  {
	    if(func_is_static)
	      cc_error("'static' must be followed by a struct name");
	    else
	      cc_error("'this' must be followed by a struct name");
	    return -1;
	  }
	  if ((sym.entries[targ.peeknext()].flags & SFLG_STRUCTTYPE) == 0)
	  {
	    if(func_is_static)
	      cc_error("'static' cannot be used with primitive types");
	    else
	      cc_error("'this' cannot be used with primitive types");
	    return -1;
	  }
	  if (strchr(functionName, ':') != NULL)
	  {
	    cc_error("extender functions cannot be part of a struct");
	    return -1;
	  }

	  sprintf(functionName, "%s::%s", sym.get_name(targ.peeknext()), sym.get_name(funcsym));
	  if (isMemberFunctionPtr != NULL)
	  {
		  *isMemberFunctionPtr = targ.peeknext();
	  }

	  funcsym = sym.find(functionName);
	  if (funcsym < 0)
	  {
		  funcsym = sym.add(functionName);
	  }
    *funcsymptr = funcsym;

	  if (next_is_import == 0) {
      if (scrip->remove_any_import(functionName, oldDefinition))
        return -1;
    }

	  if (sym.entries[funcsym].stype != 0)
	  {
	    cc_error("function '%s' is already defined", functionName);
	    return -1;
	  }
	  sym.entries[funcsym].flags = SFLG_STRUCTMEMBER;
	  if(func_is_static) {
	    sym.entries[funcsym].flags |= SFLG_STATIC;
      }

	  targ.getnext();
	  if (!func_is_static && strcmp(sym.get_name(targ.getnext()), "*") != 0)
	  {
	    cc_error("instance extender function must be pointer");
	    return -1;
	  }

	  if ((sym.get_type(targ.peeknext()) != SYM_COMMA) &&
	      (sym.get_type(targ.peeknext()) != SYM_CLOSEPARENTHESIS))
	  {
	    if(strcmp(sym.get_name(targ.getnext()), "*") == 0)
	      cc_error("static extender function cannot be pointer");
	    else
	      cc_error("parameter name cannot be defined for extender type");
	    return -1;
	  }

	  if (sym.get_type(targ.peeknext()) == SYM_COMMA)
	  {
		  targ.getnext();
	  }
  }
  else if(sym.get_type(funcsym) == SYM_VARTYPE) {
      // Attempt to prefix a vartype with the struct name
      // e.g. MyStruct::Object
      if(isMemberFunction)
      {
          sprintf(functionName, "%s::%s", sym.get_name(isMemberFunction), sym.get_name(funcsym));
          funcsym = sym.find(functionName);
          if (funcsym < 0)
              funcsym = sym.add(functionName);
          *funcsymptr = funcsym;
      }
      if (sym.entries[funcsym].stype != 0) 
      {
          cc_error("function '%s' is already defined", functionName);
          return -1;
      }
  }

  sym.entries[funcsym].stype = SYM_FUNCTION;
  sym.entries[funcsym].ssize = varsize;  // save return type size
  sym.entries[funcsym].funcparamtypes[0] = vtwas;  // return type

  if (is_const)
  {
    sym.entries[funcsym].funcparamtypes[0] |= STYPE_CONST;
  }
  if (returnsPointer)
  {
    sym.entries[funcsym].funcparamtypes[0] |= STYPE_POINTER;
  }
  if (returnsDynArray)
  {
    sym.entries[funcsym].funcparamtypes[0] |= STYPE_DYNARRAY;
  }

  if ((!returnsPointer) && (!returnsDynArray) &&
      ((sym.entries[vtwas].flags & SFLG_STRUCTTYPE) != 0))
  {
    cc_error("Cannot return entire struct from function");
    return -1;
  }
  if ((in_func >= 0) || (nested_level > 0)) {
    cc_error("Nested functions not supported (you may have forgotten a closing brace)");
    return -1;
  }
  if (next_is_readonly) {
    cc_error("readonly cannot be applied to a function");
    return -1;
  }

  int funcNum = -1;

  if (next_is_import)
    in_func = scrip->add_new_import(functionName);
  else
    in_func = scrip->add_new_function(functionName, &funcNum);

  if (in_func < 0) {
    // don't overwrite the "used import" error message
    if (in_func != -2)
      cc_error("Internal compiler error: table overflow");
    return -1;
  }
  sym.entries[funcsym].soffs = in_func;  // save code offset of function
  scrip->cur_sp += 4;  // the return address will be pushed

  int prototype = 0;
  bool next_is_const = false;
  char functype[100]="\0";
  while (1) {
    int cursym = targ.getnext();
    int next_type = sym.get_type(cursym);
    if (next_type == SYM_CLOSEPARENTHESIS) break;
    else if (next_type == SYM_VARARGS) {
      // variable number of arguments
      numparams+=100;
      cursym = targ.getnext();
      if (sym.get_type(cursym) != SYM_CLOSEPARENTHESIS) {
        cc_error("expected ')' after variable-args");
        return -1;
      }
      break;
    }
    else if (next_type == SYM_CONST) {
      next_is_const = true;
    }
    else if (next_type == SYM_VARTYPE) {
      // function parameter
      if ((numparams % 100) >= MAX_FUNCTION_PARAMETERS) {
        cc_error("too many parameters defined for function");
        return -1;
      }
      if (cursym == sym.normalVoidSym) {
        cc_error("'void' invalid type for function parameter");
        return -1;
      }
      int isPointerParam = 0, isRawPointer = 0;
      // save the parameter type (numparams starts from 1)
      sym.entries[funcsym].funcparamtypes[numparams % 100] = cursym;
      sym.entries[funcsym].funcParamDefaultValues[numparams % 100] = 0;
      sym.entries[funcsym].funcParamHasDefaultValues[numparams % 100] = false;

      if (next_is_const)
        sym.entries[funcsym].funcparamtypes[numparams % 100] |= STYPE_CONST;

      functype[strlen(functype)+1] = 0;
      functype[strlen(functype)] = (char)cursym;  // save variable type
      if (check_not_eof(targ))
        return -1;
      if (strcmp(sym.get_name(targ.peeknext()), "*") == 0) {
        // pointer
        targ.getnext();
        if(strcmp("char", sym.get_name(cursym)) == 0) isRawPointer = 1;
        else if (strcmp("int", sym.get_name(cursym)) == 0) isRawPointer = 4;
        else if (strcmp("short", sym.get_name(cursym)) == 0) isRawPointer = 2;
        else if (strcmp("long", sym.get_name(cursym)) == 0 ) isRawPointer = 4;
        if(isRawPointer) {
          /* treat the pointer value as if it was an int */
          sym.entries[funcsym].funcparamtypes[numparams % 100] = sym.normalIntSym;
        } else {
          sym.entries[funcsym].funcparamtypes[numparams % 100] |= STYPE_POINTER;
          isPointerParam = 1;
        }
        if ((sym.entries[cursym].flags & SFLG_MANAGED) == 0 && !isRawPointer) {
          // can only point to managed structs
          cc_error("Cannot declare pointer to non-managed type");
          return -1;
        }
        if (sym.entries[cursym].flags & SFLG_AUTOPTR) {
          cc_error("Invalid use of pointer");
          return -1;
        }
      }

      if (sym.entries[cursym].flags & SFLG_AUTOPTR) {
        sym.entries[funcsym].funcparamtypes[numparams % 100] |= STYPE_POINTER;
        isPointerParam = 1;
      }

      bool createdLocalVar = false;

      if (sym.get_type(targ.peeknext()) != 0) {
        // next token is not a variable name, so it must be a prototype
        prototype = 1;

        if ((sym.get_type(targ.peeknext()) == SYM_GLOBALVAR) && (next_is_import)) {
          // if the paramter name is a global var, but this is just an import declaration
          // then ignore it
          targ.getnext();
        }

        if (check_for_default_value(targ, funcsym, numparams))
          return -1;

        numparams++;
      }
      else if ((next_is_import) || (prototype)) {
        // imported function, so ignore the parameter names
        targ.getnext();

        if (check_for_default_value(targ, funcsym, numparams))
          return -1;

        numparams++;
      }
      else {
        // it's a parameter
        int vartypesym = cursym;
        if ((sym.entries[cursym].flags & SFLG_STRUCTTYPE) && (!isPointerParam)) {
          cc_error("struct cannot be passed as parameter");
          return -1;
        }
        cursym = targ.getnext();
        sym.entries[cursym].stype = SYM_LOCALVAR;
        sym.entries[cursym].extends = 0;
        sym.entries[cursym].arrsize = isRawPointer ? 0 : 1;
        sym.entries[cursym].vartype = isRawPointer ? sym.normalIntSym : vartypesym;
        sym.entries[cursym].ssize = isRawPointer ? isRawPointer : 4; //oldsize;  fix param to 4 bytes for djgpp
        sym.entries[cursym].sscope = nested_level + 1;
        sym.entries[cursym].flags |= SFLG_PARAMETER;
        if (isPointerParam)
          sym.entries[cursym].flags |= SFLG_POINTER;
        else if (isRawPointer)
          sym.entries[cursym].flags |= SFLG_ARRAY;
        if (next_is_const)
          sym.entries[cursym].flags |= SFLG_CONST | SFLG_READONLY;
        // the parameters are pushed backwards, so the top of the
        // stack has the first parameter. The +1 is because the
        // call will push the return address onto the stack as well
        sym.entries[cursym].soffs = scrip->cur_sp - (numparams+1)*4;
        createdLocalVar = true;
        numparams++;
      }

      int dynArrayStatus = check_for_dynamic_array_declaration(targ, cursym, !!isPointerParam);
      if (dynArrayStatus < 0)
      {
        return -1;
      }
      else if (dynArrayStatus > 0)
      {
        sym.entries[funcsym].funcparamtypes[(numparams - 1) % 100] |= STYPE_DYNARRAY;
        if (createdLocalVar)
        {
          sym.entries[cursym].flags |= SFLG_DYNAMICARRAY | SFLG_ARRAY;
        }
      }

      next_type = sym.get_type(cursym=targ.getnext());
      if (next_type == SYM_CLOSEPARENTHESIS) break;
      else if (next_type == SYM_GLOBALVAR) {
        cc_error("'%s' is a global var; cannot use as name for local",sym.get_friendly_name(cursym).c_str());
        return -1;
      }
      else if (next_type != SYM_COMMA) {
        cc_error("PE02: Parse error at '%s'",sym.get_friendly_name(cursym).c_str());
        return -1;
      }

      next_is_const = false;
    }
    else {
      // something odd was inside the parentheses
      cc_error("PE03: Parse error at '%s'",sym.get_friendly_name(cursym).c_str());
      return -1;
    }
  }
  // save the number of parameters
  sym.entries[funcsym].sscope = (numparams-1);
  if (funcNum >= 0)
    scrip->funcnumparams[funcNum] = sym.entries[funcsym].sscope;

  if (func_is_static)
    sym.entries[funcsym].flags |= SFLG_STATIC;

  if (next_is_import) {
    sym.entries[funcsym].flags |= SFLG_IMPORTED;

    if (isMemberFunction) {
      // for imported member functions, append the number of parameters
      // to the name of the import
      char appendage[10];
      sprintf(appendage, "^%d", sym.entries[funcsym].sscope);

      strcat(scrip->imports[in_func], appendage);
    }

    int nextvar = targ.peeknext();
    // member function expects the ; to still be there whereas
    // normal function does not
    if (!isMemberFunction)
      nextvar = targ.getnext();

    if (sym.get_type(nextvar) != SYM_SEMICOLON) {
      cc_error("';' expected (cannot define body of imported function)");
      return -1;
    }
    in_func=-1;
  }
  else if (sym.get_type(targ.peeknext()) == SYM_OPENBRACE) {
  }
  else {
    cc_error("Expected '{'");
    return -1;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %r9, 0x40(%rsp)
movq %r8, 0x48(%rsp)
movq %rdx, %r12
movq %rsi, 0x20(%rsp)
movq %rdi, %r14
movl (%rdx), %r15d
movslq %ecx, %r13
leaq 0x1f7a8(%rip), %rbx     # 0x256f0
movq 0x28(%rbx), %rax
imulq $0xb0, %r13, %rbp
movq 0x38(%rax,%rbp), %rax
movq %rax, 0x10(%rsp)
callq 0xfc84
movq %rbx, %rdi
movl %r15d, %esi
callq 0x10b48
leaq 0xe0(%rsp), %rdi
movq %rax, %rsi
callq 0x32c0
movq %r14, %rdi
callq 0x5d62
pushq $-0x1
popq %rcx
testl %eax, %eax
jne 0x63d5
movq %r12, 0x28(%rsp)
movq %r13, 0x18(%rsp)
movq %rbp, (%rsp)
movl %r15d, 0x8(%rsp)
movl 0x338(%rsp), %r13d
movl 0x328(%rsp), %ebx
movl 0x320(%rsp), %r15d
movq %r14, %rdi
callq 0xfc58
leaq 0x1f727(%rip), %rbp     # 0x256f0
movq %rbp, %rdi
movl %eax, %esi
callq 0x10b48
leaq 0x12c2c(%rip), %rsi     # 0x18c06
movq %rax, %rdi
callq 0x3450
testl %eax, %eax
je 0x6005
movq %r14, %rdi
callq 0xfc58
leaq 0x1f6fb(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x2c, %eax
jne 0x608f
movq %r14, %rdi
callq 0xfc58
leaq 0x1f6dc(%rip), %rbx     # 0x256f0
movq %rbx, %rdi
movl %eax, %esi
callq 0xfe60
cmpl $0x2c, %eax
pushq $0x1
popq %rax
cmovel %eax, %r13d
movq %r14, %rdi
callq 0xfc84
movq %r14, %rdi
callq 0xfc58
movq %rbx, %rdi
movl %eax, %esi
callq 0xfe60
cmpl $0x2e, %eax
jne 0x607a
movq %r14, %rdi
callq 0xfc58
movq 0x28(%rbx), %rcx
imulq $0xb0, %rax, %rax
testb $0x4, 0x29(%rcx,%rax)
jne 0x6133
testl %r13d, %r13d
je 0x6179
leaq 0x12bea(%rip), %rdi     # 0x18c5f
jmp 0x63cb
testl %r13d, %r13d
je 0x616d
leaq 0x12b81(%rip), %rdi     # 0x18c0b
jmp 0x63cb
leaq 0x1f65a(%rip), %rdi     # 0x256f0
movl 0x8(%rsp), %r12d
movl %r12d, %esi
callq 0xfe60
cmpl $0x2e, %eax
jne 0x6154
testl %ebx, %ebx
je 0x62d1
leaq 0x1f635(%rip), %r12     # 0x256f0
movq %r12, %rdi
movl %ebx, %esi
callq 0x10b48
movq %rax, %rbx
movq %r12, %rdi
movl 0x8(%rsp), %esi
callq 0x10b48
leaq 0x12875(%rip), %rsi     # 0x18950
leaq 0xe0(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x30c0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1085a
movl %eax, %r12d
testl %eax, %eax
jns 0x611c
leaq 0x1f5e4(%rip), %rdi     # 0x256f0
leaq 0xe0(%rsp), %rsi
callq 0x10c12
movl %eax, %r12d
movl %r15d, %ebx
movq 0x28(%rsp), %rcx
movl %r12d, (%rcx)
leaq 0x1f5c2(%rip), %rbp     # 0x256f0
jmp 0x62d9
leaq 0xe0(%rsp), %rdi
pushq $0x3a
popq %rsi
callq 0x3170
testq %rax, %rax
je 0x6185
leaq 0x12b68(%rip), %rdi     # 0x18cb7
jmp 0x63cb
movl %r15d, %ebx
movslq %r12d, %r15
movq (%rsp), %r10
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rdi
jmp 0x631f
leaq 0x12ac2(%rip), %rdi     # 0x18c36
jmp 0x63cb
leaq 0x12b0c(%rip), %rdi     # 0x18c8c
jmp 0x63cb
movq %r14, %rdi
callq 0xfc58
leaq 0x1f55c(%rip), %r12     # 0x256f0
movq %r12, %rdi
movl %eax, %esi
callq 0x10b48
movq %rax, %rbx
movq %r12, %rdi
movl 0x8(%rsp), %esi
callq 0x10b48
leaq 0x1279c(%rip), %rsi     # 0x18950
leaq 0xe0(%rsp), %rdi
movq %rbx, %rdx
movq 0x340(%rsp), %rbx
movq %rax, %rcx
xorl %eax, %eax
callq 0x30c0
testq %rbx, %rbx
je 0x61e0
movq %r14, %rdi
callq 0xfc58
movl %eax, (%rbx)
leaq 0x1f509(%rip), %r12     # 0x256f0
leaq 0xe0(%rsp), %rsi
movq %r12, %rdi
callq 0x1085a
movl %eax, %r8d
testl %eax, %eax
movq 0x28(%rsp), %rbx
jns 0x621a
leaq 0x1f4e6(%rip), %rdi     # 0x256f0
leaq 0xe0(%rsp), %rsi
callq 0x10c12
movl %eax, %r8d
movl %r8d, (%rbx)
movl %r15d, %ebx
testl %r15d, %r15d
je 0x640e
movslq %r8d, %r15
movq 0x28(%r12), %rax
imulq $0xb0, %r15, %rcx
cmpw $0x0, 0x20(%rax,%rcx)
jne 0x6304
movl %r8d, %r12d
addq %rcx, %rax
movq $0x80, 0x28(%rax)
testl %r13d, %r13d
je 0x69f2
movq $0x2080, 0x28(%rax)     # imm = 0x2080
movq %r14, %rdi
callq 0xfc84
movq %r14, %rdi
callq 0xfc58
leaq 0x1f476(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x2a, %eax
je 0x62a5
movq %r14, %rdi
callq 0xfc58
leaq 0x1f45b(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x6, %eax
jne 0x6b66
movq %r14, %rdi
callq 0xfc58
leaq 0x1f43c(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x2a, %eax
jne 0x615a
movq %r14, %rdi
callq 0xfc84
jmp 0x615a
movl %r15d, %ebx
movl 0x8(%rsp), %r12d
movslq %r12d, %r15
leaq 0x1f40d(%rip), %rcx     # 0x256f0
movq 0x28(%rcx), %rdx
imulq $0xb0, %r15, %rcx
cmpw $0x0, 0x20(%rdx,%rcx)
movq (%rsp), %r10
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rdi
je 0x631f
leaq 0x129da(%rip), %rdi     # 0x18ce5
leaq 0xe0(%rsp), %rsi
xorl %eax, %eax
callq 0xf258
jmp 0x63d2
movl 0x350(%rsp), %ecx
movl 0x330(%rsp), %edx
movl 0x318(%rsp), %esi
movq 0x28(%rbp), %r9
imulq $0xb0, %r15, %r15
movw $0x4, 0x20(%r9,%r15)
movslq %edi, %rdi
movq %rdi, 0x38(%r9,%r15)
movq %r8, %rdi
orq $0x20000000, %rdi       # imm = 0x20000000
testl %esi, %esi
cmoveq %r8, %rdi
movq %rdi, %rsi
orq $0x40000000, %rsi       # imm = 0x40000000
testl %edx, %edx
cmoveq %rdi, %rsi
movq 0x58(%r9,%r15), %rdi
movq %rsi, %r8
orq $0x10000000, %r8        # imm = 0x10000000
testl %ecx, %ecx
cmoveq %rsi, %r8
movq %r8, (%rdi)
orl %edx, %ecx
jne 0x6393
testb $0x4, 0x29(%r9,%r10)
jne 0x63c4
movq 0x48(%rsp), %rbp
cmpl $0x0, (%rbp)
movq 0x40(%rsp), %rcx
jns 0x63bb
cmpl $0x0, (%rcx)
jg 0x63bb
cmpl $0x0, 0x310(%rsp)
je 0x63e9
leaq 0x12a48(%rip), %rdi     # 0x18e01
jmp 0x63cb
leaq 0x129f7(%rip), %rdi     # 0x18db9
jmp 0x63cb
leaq 0x129c4(%rip), %rdi     # 0x18d8f
xorl %eax, %eax
callq 0xf258
pushq $-0x1
popq %rcx
movl %ecx, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, 0x8(%rsp)
orl $-0x1, 0x34(%rsp)
leaq 0xe0(%rsp), %rsi
testl %ebx, %ebx
je 0x6437
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x12178
jmp 0x6449
movq 0x348(%rsp), %rdx
leaq 0xe0(%rsp), %rsi
movq 0x20(%rsp), %rdi
movl %r8d, %r15d
callq 0x121f8
movl %r15d, %r8d
testl %eax, %eax
jne 0x63d2
jmp 0x6229
leaq 0x34(%rsp), %rdx
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x120f0
movl %eax, (%rbp)
testl %eax, %eax
js 0x69cf
movq %r14, 0x10(%rsp)
leaq 0x1f290(%rip), %rcx     # 0x256f0
movq 0x28(%rcx), %rcx
movl %eax, 0x34(%rcx,%r15)
addq $0x4, 0x8d40(%rbx)
pushq $0x1
popq %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
andl $0x0, 0xd0(%rsp)
movl $0x0, 0x28(%rsp)
movq %rax, (%rsp)
movl %r13d, 0x18(%rsp)
xorl %ecx, %ecx
movq 0x10(%rsp), %r14
leaq 0x1f225(%rip), %rbx     # 0x256f0
movl %ecx, %r12d
movq %r14, %rdi
callq 0xfc84
movq %rax, %r13
movq %rbx, %rdi
movl %r13d, %esi
callq 0xfe60
movb $0x1, %cl
cmpl $0x31, %eax
je 0x64cb
cmpl $0x6, %eax
je 0x6a2b
cmpl $0x2e, %eax
movq (%rsp), %rbx
jne 0x6990
movl %ebx, %eax
cltd
pushq $0x64
popq %rcx
idivl %ecx
cmpl $0xf, %edx
jge 0x6be5
leaq 0x1f1d7(%rip), %rax     # 0x256f0
cmpl %r13d, 0x18(%rax)
je 0x6bf1
movslq %r13d, %rcx
movq 0x28(%rax), %rax
movslq %edx, %rbx
leaq (%rax,%r15), %rdi
addq $0x88, %rdi
movq -0x30(%rdi), %rax
movq %rcx, 0x38(%rsp)
movq %rcx, (%rax,%rbx,8)
movq -0x18(%rdi), %rax
andl $0x0, (%rax,%rbx,4)
movq %rbx, %rsi
callq 0xe96e
notq %rdx
andq %rdx, (%rax)
testb $0x1, %r12b
je 0x6579
leaq 0x1f188(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rax
movq 0x58(%rax,%r15), %rax
orq $0x20000000, (%rax,%rbx,8) # imm = 0x20000000
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
callq 0x3190
movb $0x0, 0x1(%rax,%rbp)
movq %rbp, %rdi
callq 0x3190
movb %r13b, 0x70(%rsp,%rax)
movq %r14, %rdi
callq 0x5d62
testl %eax, %eax
jne 0x63d2
movq %r14, %rdi
callq 0xfc58
leaq 0x1f139(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0x10b48
cmpb $0x2a, (%rax)
movq 0x38(%rsp), %rbp
jne 0x65ce
cmpb $0x0, 0x1(%rax)
je 0x6611
leaq 0x1f11b(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rax
imulq $0xb0, %rbp, %rcx
testb $0x2, 0x2a(%rax,%rcx)
jne 0x65f6
xorl %ebp, %ebp
movl $0x0, 0xc(%rsp)
jmp 0x671b
xorl %ebp, %ebp
movq 0x58(%rax,%r15), %rax
orq $0x40000000, (%rax,%rbx,8) # imm = 0x40000000
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0x671b
movq %r14, %rdi
callq 0xfc84
leaq 0x1f0d0(%rip), %rdi     # 0x256f0
movl %r13d, %esi
callq 0x10b48
leaq 0x14da1(%rip), %rdi     # 0x1b3d0
movq %rax, %rsi
callq 0x3450
pushq $0x1
popq %rdi
testl %eax, %eax
je 0x66d2
leaq 0x1f0a7(%rip), %rdi     # 0x256f0
movl %r13d, %esi
callq 0x10b48
leaq 0x12e92(%rip), %rdi     # 0x194ea
movq %rax, %rsi
callq 0x3450
pushq $0x4
popq %rdi
testl %eax, %eax
je 0x66d2
leaq 0x1f082(%rip), %rdi     # 0x256f0
movl %r13d, %esi
callq 0x10b48
leaq 0x1284a(%rip), %rdi     # 0x18ec7
movq %rax, %rsi
callq 0x3450
pushq $0x2
popq %rdi
testl %eax, %eax
je 0x66d2
leaq 0x1f05d(%rip), %rdi     # 0x256f0
movl %r13d, %esi
callq 0x10b48
leaq 0x12b3c(%rip), %rdi     # 0x191de
movq %rax, %rsi
callq 0x3450
pushq $0x4
popq %rdi
testl %eax, %eax
je 0x66d2
leaq 0x1f038(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rax
movq 0x58(%rax,%r15), %rcx
orq $0x40000000, (%rcx,%rbx,8) # imm = 0x40000000
xorl %edi, %edi
xorl %ecx, %ecx
pushq $0x1
popq %rsi
jmp 0x66ed
leaq 0x1f017(%rip), %rax     # 0x256f0
movslq (%rax), %rcx
movq 0x28(%rax), %rax
movq 0x58(%rax,%r15), %rdx
movq %rcx, (%rdx,%rbx,8)
xorl %esi, %esi
movb $0x1, %cl
imulq $0xb0, %rbp, %rdx
movq 0x28(%rax,%rdx), %rax
testb %cl, %cl
jne 0x670b
movl %eax, %ecx
andl $0x1000, %ecx           # imm = 0x1000
je 0x6c18
movl %edi, %ebp
movl %esi, 0xc(%rsp)
btl $0x11, %eax
jb 0x6c30
movq %r14, %rdi
callq 0xfc58
leaq 0x1efc6(%rip), %rbx     # 0x256f0
movq %rbx, %rdi
movl %eax, %esi
callq 0xfe60
testl %eax, %eax
je 0x6798
movq %r14, %rdi
callq 0xfc58
movq %rbx, %rdi
movl %eax, %esi
callq 0xfe60
cmpl $0x0, 0x320(%rsp)
movq 0x20(%rsp), %r14
je 0x6768
cmpl $0x1, %eax
jne 0x6768
movq 0x10(%rsp), %rdi
callq 0xfc84
movq 0x10(%rsp), %rdi
movl 0x8(%rsp), %esi
movq (%rsp), %rbx
movl %ebx, %edx
callq 0x5d9d
testl %eax, %eax
jne 0x63d2
incl %ebx
movq %rbx, (%rsp)
xorl %ebp, %ebp
pushq $0x1
popq %rax
movl %eax, 0x28(%rsp)
movl %r13d, %ebx
jmp 0x67db
movl 0x320(%rsp), %eax
orl 0x28(%rsp), %eax
je 0x686e
movq %r14, %rdi
callq 0xfc84
movq %r14, %rdi
movl 0x8(%rsp), %esi
movq (%rsp), %rbx
movl %ebx, %edx
callq 0x5d9d
testl %eax, %eax
jne 0x63d2
incl %ebx
movq %rbx, (%rsp)
xorl %ebp, %ebp
movl %r13d, %ebx
movq 0x20(%rsp), %r14
movl 0x328(%rsp), %r12d
movl 0x18(%rsp), %r13d
movl 0xc(%rsp), %edx
movq 0x10(%rsp), %rdi
movl %ebx, %esi
callq 0x5e78
testl %eax, %eax
js 0x63d2
je 0x6840
leaq 0x1eee7(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rcx
movq (%rsp), %rax
decl %eax
cltd
pushq $0x64
popq %rsi
idivl %esi
movslq %edx, %rax
movq 0x58(%rcx,%r15), %rdx
orq $0x10000000, (%rdx,%rax,8) # imm = 0x10000000
testb %bpl, %bpl
je 0x6840
movslq %ebx, %rax
imulq $0xb0, %rax, %rax
orl $0x40002, 0x28(%rcx,%rax) # imm = 0x40002
movq 0x10(%rsp), %rdi
callq 0xfc84
movq %rax, %rbx
leaq 0x1ee9c(%rip), %rdi     # 0x256f0
movl %ebx, %esi
callq 0xfe60
cmpl $0x2a, %eax
movq 0x48(%rsp), %rbp
je 0x64bd
jmp 0x6bab
cmpl $0x0, 0xc(%rsp)
jne 0x6899
leaq 0x1ee74(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rax
imulq $0xb0, 0x38(%rsp), %rcx
movq 0x28(%rax,%rcx), %rax
andl $0x400, %eax            # imm = 0x400
jne 0x6c24
movq %r14, %rdi
callq 0xfc84
movq %rax, %rbx
movslq %ebx, %rcx
leaq 0x1ee42(%rip), %rsi     # 0x256f0
movq 0x28(%rsi), %rax
imulq $0xb0, %rcx, %rcx
movw $0x2, 0x20(%rax,%rcx)
andw $0x0, 0x50(%rax,%rcx)
xorl %edx, %edx
testl %ebp, %ebp
sete %dl
movq %rdx, 0x48(%rax,%rcx)
movzwl (%rsi), %edx
cmovew %r13w, %dx
movw %dx, 0x30(%rax,%rcx)
movl %ebp, %edx
pushq $0x4
popq %rsi
cmovel %esi, %edx
movq %rdx, 0x38(%rax,%rcx)
movq 0x40(%rsp), %rdx
movl (%rdx), %edx
incl %edx
movw %dx, 0x40(%rax,%rcx)
movq 0x28(%rax,%rcx), %rsi
movq %rsi, %r10
orq $0x1, %r10
movl 0xc(%rsp), %edx
orl %edx, %ebp
setne %dil
movl %edi, %r8d
orb %r12b, %r8b
testb $0x1, %r8b
je 0x6948
testl %edx, %edx
pushq $0x3
popq %r8
movl $0x101, %r9d            # imm = 0x101
cmovneq %r9, %r8
orq %r8, %rsi
testb %dil, %dil
cmovneq %rsi, %r10
movq %r10, %rsi
orq $0x10040, %rsi          # imm = 0x10040
testb $0x1, %r12b
cmovneq %rsi, %r10
movl 0x328(%rsp), %r12d
movl 0x18(%rsp), %r13d
addq %rcx, %rax
movq %r10, 0x28(%rax)
movq 0x20(%rsp), %r14
movl 0x8d40(%r14), %ecx
movq (%rsp), %rsi
leal 0x4(,%rsi,4), %edi
incl %esi
subl %edi, %ecx
movl %ecx, 0x34(%rax)
movb $0x1, %bpl
movl $0x0, 0x28(%rsp)
movl %esi, %eax
movq %rax, (%rsp)
jmp 0x67ec
cmpl $0x1b, %eax
jne 0x6af4
movq %r14, %rdi
callq 0xfc84
leaq 0x1ed48(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x6, %eax
jne 0x6b5a
addl $0x64, %ebx
movq 0x20(%rsp), %r14
movl 0x328(%rsp), %r12d
movl 0x18(%rsp), %r13d
jmp 0x6a41
pushq $-0x1
popq %rcx
cmpl $-0x2, %eax
je 0x63d5
leaq 0x12448(%rip), %rdi     # 0x18e2a
xorl %eax, %eax
movl %ecx, %ebx
callq 0xf258
movl %ebx, %ecx
jmp 0x63d5
movq %r14, %rdi
callq 0xfc84
movq %r14, %rdi
callq 0xfc84
leaq 0x1ece7(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0x10b48
cmpb $0x2a, (%rax)
jne 0x6a1f
cmpb $0x0, 0x1(%rax)
je 0x626b
leaq 0x122e0(%rip), %rdi     # 0x18d06
jmp 0x63cb
movq 0x20(%rsp), %r14
movl 0x328(%rsp), %r12d
movl 0x18(%rsp), %r13d
movq (%rsp), %rbx
decl %ebx
leaq 0x1eca6(%rip), %rax     # 0x256f0
movq 0x28(%rax), %rax
movw %bx, 0x40(%rax,%r15)
movslq 0x34(%rsp), %rcx
testq %rcx, %rcx
js 0x6a67
movw %bx, 0x7d98(%r14,%rcx,2)
addq %r15, %rax
testl %r13d, %r13d
je 0x6a73
orb $0x20, 0x29(%rax)
cmpl $0x0, 0x320(%rsp)
je 0x6b2b
orb $0x4, 0x28(%rax)
testl %r12d, %r12d
je 0x6ab8
movswl 0x40(%rax), %edx
leaq 0x12506(%rip), %rsi     # 0x18f9b
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c0
movq 0x50(%r14), %rax
movslq (%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x3570
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xfc58
testl %r12d, %r12d
jne 0x6ad2
movq %rbx, %rdi
callq 0xfc84
leaq 0x1ec17(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x28, %eax
jne 0x6b93
orl $-0x1, (%rbp)
xorl %ecx, %ecx
jmp 0x63d5
leaq 0x1ebf5(%rip), %rsi     # 0x256f0
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %edx
callq 0x10864
movq (%rbx), %rsi
leaq 0x1246c(%rip), %rdi     # 0x18f81
xorl %eax, %eax
callq 0xf258
leaq 0x50(%rsp), %rdi
callq 0x31a0
jmp 0x63d2
movq 0x10(%rsp), %rdi
callq 0xfc58
leaq 0x1ebb4(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
xorl %ecx, %ecx
cmpl $0x17, %eax
je 0x63d5
leaq 0x12481(%rip), %rdi     # 0x18fd6
jmp 0x63cb
leaq 0x122f1(%rip), %rdi     # 0x18e52
jmp 0x63cb
movq %r14, %rdi
callq 0xfc84
leaq 0x1eb7b(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0x10b48
cmpb $0x2a, (%rax)
jne 0x6b87
cmpb $0x0, 0x1(%rax)
je 0x6b9f
leaq 0x121ce(%rip), %rdi     # 0x18d5c
jmp 0x63cb
leaq 0x12405(%rip), %rdi     # 0x18f9f
jmp 0x63cb
leaq 0x1218b(%rip), %rdi     # 0x18d31
jmp 0x63cb
cmpl $0x6, %eax
je 0x6a3d
leaq 0x1eb35(%rip), %rsi     # 0x256f0
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl %ebx, %edx
cmpl $0x1, %eax
jne 0x6bfd
callq 0x10864
movq (%r14), %rsi
leaq 0x1235b(%rip), %rdi     # 0x18f34
xorl %eax, %eax
callq 0xf258
jmp 0x6b1c
leaq 0x12287(%rip), %rdi     # 0x18e73
jmp 0x63cb
leaq 0x122a4(%rip), %rdi     # 0x18e9c
jmp 0x63cb
callq 0x10864
movq (%r14), %rsi
leaq 0x1235b(%rip), %rdi     # 0x18f67
xorl %eax, %eax
callq 0xf258
jmp 0x6b1c
leaq 0x122ae(%rip), %rdi     # 0x18ecd
jmp 0x63cb
leaq 0x122e4(%rip), %rdi     # 0x18f0f
jmp 0x63cb
leaq 0x122c1(%rip), %rdi     # 0x18ef8
jmp 0x63cb
jmp 0x6c40
jmp 0x6c40
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x31a0
movq %rbx, %rdi
callq 0x3560