// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2e8, %rsp            # imm = 0x2E8
movq %r9, 0x70(%rsp)
movq %r8, 0x18(%rsp)
movq %rdx, %r12
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movl (%rdx), %r15d
movslq %ecx, %r13
leaq 0x1f1b3(%rip), %rbx     # 0x256e0
movq 0x28(%rbx), %rax
imulq $0xb0, %r13, %rbp
movq 0x38(%rax,%rbp), %rax
movq %rax, 0x8(%rsp)
callq 0x10f88
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1263e
leaq 0xf0(%rsp), %rdi
movq %rax, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x62f5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x69b1
movq %r13, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
movl %r15d, 0x14(%rsp)
movl 0x348(%rsp), %ebp
movl 0x338(%rsp), %ebx
movl 0x330(%rsp), %r13d
movq %r14, %rdi
callq 0x10f22
leaq 0x1f135(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x1263e
leaq 0x1466d(%rip), %rsi     # 0x1ac26
movq %rax, %rdi
callq 0x3450
testl %eax, %eax
je 0x65e4
movq %r14, %rdi
callq 0x10f22
leaq 0x1f10c(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x2c, %eax
jne 0x6670
movq %r14, %rdi
callq 0x10f22
leaq 0x1f0ed(%rip), %rbx     # 0x256e0
movq %rbx, %rdi
movl %eax, %esi
callq 0x111aa
cmpl $0x2c, %eax
movl $0x1, %eax
cmovel %eax, %ebp
movq %r14, %rdi
callq 0x10f88
movq %r14, %rdi
callq 0x10f22
movq %rbx, %rdi
movl %eax, %esi
callq 0x111aa
cmpl $0x2e, %eax
jne 0x665c
movq %r12, %r15
movq %r14, %rdi
callq 0x10f22
movq 0x28(%rbx), %rcx
imulq $0xb0, %rax, %rax
testb $0x4, 0x29(%rcx,%rax)
jne 0x6712
testl %ebp, %ebp
je 0x675b
leaq 0x14628(%rip), %rdi     # 0x1ac7f
jmp 0x69a5
testl %ebp, %ebp
je 0x674f
leaq 0x145c0(%rip), %rdi     # 0x1ac2b
jmp 0x69a5
leaq 0x1f069(%rip), %r15     # 0x256e0
movq %r15, %rdi
movl 0x14(%rsp), %esi
callq 0x111aa
cmpl $0x2e, %eax
jne 0x6735
testl %ebx, %ebx
je 0x68b4
leaq 0x1f045(%rip), %r13     # 0x256e0
movq %r13, %rdi
movl %ebx, %esi
callq 0x1263e
movq %rax, %rbx
movq %r13, %rdi
movl 0x14(%rsp), %esi
callq 0x1263e
leaq 0x142b5(%rip), %rsi     # 0x1a970
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x30d0
leaq 0x1f006(%rip), %rdi     # 0x256e0
movq %r13, %rsi
callq 0x11f96
testl %eax, %eax
jns 0x66fa
leaq 0x1eff3(%rip), %rdi     # 0x256e0
leaq 0xf0(%rsp), %rsi
callq 0x12758
movl %eax, (%r12)
leaq 0x1efdb(%rip), %rbx     # 0x256e0
movl 0x330(%rsp), %r13d
jmp 0x68bf
leaq 0xf0(%rsp), %rdi
movl $0x3a, %esi
callq 0x3180
testq %rax, %rax
je 0x6767
leaq 0x145a7(%rip), %rdi     # 0x1acd7
jmp 0x69a5
leaq 0x1efa4(%rip), %rbx     # 0x256e0
movl 0x14(%rsp), %eax
movq 0x38(%rsp), %r10
movq 0x8(%rsp), %r8
jmp 0x68fa
leaq 0x14500(%rip), %rdi     # 0x1ac56
jmp 0x69a5
leaq 0x1454a(%rip), %rdi     # 0x1acac
jmp 0x69a5
movq %r14, %rdi
callq 0x10f22
leaq 0x1ef6a(%rip), %r12     # 0x256e0
movq %r12, %rdi
movl %eax, %esi
callq 0x1263e
movq %rax, %rbx
movq %r12, %rdi
movl 0x14(%rsp), %esi
callq 0x1263e
leaq 0x141da(%rip), %rsi     # 0x1a970
leaq 0xf0(%rsp), %rdi
movq %rbx, %rdx
movq 0x350(%rsp), %rbx
movq %rax, %rcx
xorl %eax, %eax
callq 0x30d0
testq %rbx, %rbx
je 0x67c2
movq %r14, %rdi
callq 0x10f22
movl %eax, (%rbx)
leaq 0x1ef17(%rip), %rbx     # 0x256e0
leaq 0xf0(%rsp), %rsi
movq %rbx, %rdi
callq 0x11f96
movl %eax, %r8d
testl %eax, %eax
jns 0x67f7
leaq 0x1eef9(%rip), %rdi     # 0x256e0
leaq 0xf0(%rsp), %rsi
callq 0x12758
movl %eax, %r8d
movl %r8d, (%r15)
testl %r13d, %r13d
movq 0x28(%rsp), %rdi
je 0x69ea
movslq %r8d, %rcx
movq 0x28(%rbx), %rax
imulq $0xb0, %rcx, %rcx
cmpw $0x0, 0x20(%rax,%rcx)
jne 0x68df
movl %r8d, %r15d
addq %rcx, %rax
movq $0x80, 0x28(%rax)
testl %ebp, %ebp
je 0x7247
movq $0x2080, 0x28(%rax)     # imm = 0x2080
movq %r14, %rdi
callq 0x10f88
leaq 0x1ee91(%rip), %rbx     # 0x256e0
movq %r14, %rdi
callq 0x10f22
leaq 0x1ee82(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x2a, %eax
je 0x6889
movq %r14, %rdi
callq 0x10f22
leaq 0x1ee67(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x6, %eax
jne 0x72b6
movq %r14, %rdi
callq 0x10f22
leaq 0x1ee48(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x2a, %eax
jne 0x68ac
movq %r14, %rdi
callq 0x10f88
movl %r15d, %eax
jmp 0x6740
leaq 0x1ee25(%rip), %rbx     # 0x256e0
movl 0x14(%rsp), %eax
movslq %eax, %rdx
movq 0x28(%r15), %rcx
imulq $0xb0, %rdx, %rdx
cmpw $0x0, 0x20(%rcx,%rdx)
movq 0x38(%rsp), %r10
movq 0x8(%rsp), %r8
je 0x68fa
leaq 0x1441f(%rip), %rdi     # 0x1ad05
leaq 0xf0(%rsp), %rsi
xorl %eax, %eax
callq 0x10418
jmp 0x69ac
movl 0x360(%rsp), %r9d
movl 0x340(%rsp), %edx
movl 0x328(%rsp), %edi
movslq %eax, %rsi
movq 0x28(%rbx), %rcx
imulq $0xb0, %rsi, %r15
movw $0x4, 0x20(%rcx,%r15)
movslq %r8d, %rsi
movq %rsi, 0x38(%rcx,%r15)
movq 0x58(%rcx,%r15), %rsi
movq %r10, %r8
orq $0x20000000, %r8        # imm = 0x20000000
testl %edi, %edi
cmoveq %r10, %r8
movq %r8, (%rsi)
testl %edx, %edx
je 0x694e
orb $0x40, 0x3(%rsi)
testl %r9d, %r9d
movq 0x30(%rsp), %rdi
je 0x695c
orb $0x10, 0x3(%rsi)
orl %edx, %r9d
jne 0x6968
testb $0x4, 0x29(%rcx,%rdi)
jne 0x699e
movl %ebp, 0x38(%rsp)
movq 0x18(%rsp), %r12
cmpl $0x0, (%r12)
movq 0x70(%rsp), %rcx
jns 0x6995
cmpl $0x0, (%rcx)
jg 0x6995
cmpl $0x0, 0x320(%rsp)
je 0x69c5
leaq 0x1448e(%rip), %rdi     # 0x1ae21
jmp 0x69a5
leaq 0x1443d(%rip), %rdi     # 0x1add9
jmp 0x69a5
leaq 0x1440a(%rip), %rdi     # 0x1adaf
xorl %eax, %eax
callq 0x10418
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0x14(%rsp)
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
leaq 0xf0(%rsp), %rsi
testl %r13d, %r13d
je 0x6a0e
movq 0x28(%rsp), %rdi
callq 0x139e4
jmp 0x6a1d
movq 0x358(%rsp), %rdx
leaq 0xf0(%rsp), %rsi
movl %r8d, %r15d
callq 0x13a54
movl %r15d, %r8d
testl %eax, %eax
jne 0x69ac
jmp 0x6808
leaq 0x6c(%rsp), %rdx
movq 0x28(%rsp), %rdi
callq 0x1395c
movl %eax, (%r12)
testl %eax, %eax
js 0x722d
movq 0x28(%rbx), %rcx
movl %eax, 0x34(%rcx,%r15)
movq 0x28(%rsp), %rax
addq $0x4, 0x8d40(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movl $0x0, 0xe0(%rsp)
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movl $0x0, 0x24(%rsp)
movl $0x0, 0x30(%rsp)
movq %r14, %rdi
callq 0x10f88
movq %rax, %r13
leaq 0x1ec37(%rip), %rbx     # 0x256e0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x111aa
cmpl $0x2d, %eax
jg 0x6b04
movl $0x3, %ebx
cmpl $0x6, %eax
je 0x6ba7
cmpl $0x1b, %eax
jne 0x6b1d
movq 0x8(%rsp), %rax
addl $0x64, %eax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0x10f88
leaq 0x1ebf8(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x6, %eax
je 0x6ba7
leaq 0x14373(%rip), %rdi     # 0x1ae72
jmp 0x6b9b
cmpl $0x2e, %eax
je 0x6b62
movb $0x1, %cl
cmpl $0x31, %eax
jne 0x6b1d
movl %ecx, %eax
movl %eax, 0x30(%rsp)
xorl %ebx, %ebx
jmp 0x6ba7
leaq 0x40(%rsp), %rdi
leaq 0x1ebb7(%rip), %rsi     # 0x256e0
movl %r13d, %edx
callq 0x11fa0
movq 0x40(%rsp), %rsi
leaq 0x14464(%rip), %rdi     # 0x1afa1
xorl %eax, %eax
callq 0x10418
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x6ba2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3320
jmp 0x6ba2
movslq 0x8(%rsp), %rcx
imulq $0x51eb851f, %rcx, %rax # imm = 0x51EB851F
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rax
addl %edx, %eax
imull $0x64, %eax, %eax
subl %eax, %ecx
cmpl $0xf, %ecx
jl 0x6b8e
leaq 0x14307(%rip), %rdi     # 0x1ae93
jmp 0x6b9b
cmpl %r13d, 0x18(%rbx)
jne 0x6bb4
leaq 0x14321(%rip), %rdi     # 0x1aebc
xorl %eax, %eax
callq 0x10418
movl $0x1, %ebx
testl %ebx, %ebx
je 0x6a97
jmp 0x7155
movslq %r13d, %rbp
movq 0x28(%rbx), %rdx
movslq %ecx, %r12
movq 0x58(%rdx,%r15), %rax
movq %rbp, (%rax,%r12,8)
movq 0x70(%rdx,%r15), %rsi
movl $0x0, (%rsi,%r12,4)
leaq 0x3f(%r12), %rsi
testq %r12, %r12
cmovnsq %r12, %rsi
sarq $0x6, %rsi
shlq $0x3, %rsi
addq 0x88(%rdx,%r15), %rsi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
leaq 0x3f(%r8), %rdx
andq %r12, %rdx
xorl %edi, %edi
cmpq %r8, %rdx
setbe %dil
movq $-0x2, %rdx
rolq %cl, %rdx
andq %rdx, -0x8(%rsi,%rdi,8)
testb $0x1, 0x30(%rsp)
je 0x6c26
orb $0x20, 0x3(%rax,%r12,8)
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x31a0
movb $0x0, 0x1(%rax,%rbx)
movq %rbx, %rdi
callq 0x31a0
movb %r13b, 0x80(%rsp,%rax)
movq %r14, %rdi
callq 0x62f5
movl $0x1, %ebx
xorl %ecx, %ecx
testl %eax, %eax
je 0x6c70
movq 0x18(%rsp), %r12
testb %cl, %cl
jne 0x6b16
jmp 0x6ba7
movq %rbp, 0x60(%rsp)
movl $0x0, 0x20(%rsp)
movq %r14, %rdi
callq 0x10f22
leaq 0x1ea54(%rip), %rdi     # 0x256e0
movq %rdi, %rbp
movl %eax, %esi
callq 0x1263e
movq %rax, %rdi
leaq 0x165f8(%rip), %rsi     # 0x1d298
callq 0x3450
movl $0x0, %edi
testl %eax, %eax
je 0x6d5e
movq %rdi, 0x78(%rsp)
movq 0x28(%rbp), %rax
imulq $0xb0, 0x60(%rsp), %rbp
testb $0x2, 0x2a(%rax,%rbp)
je 0x6ce0
movq 0x58(%rax,%r15), %rax
orq $0x40000000, (%rax,%r12,8) # imm = 0x40000000
movl $0x1, 0x20(%rsp)
movq %r14, %rdi
callq 0x10f22
leaq 0x1e9f1(%rip), %r12     # 0x256e0
movq %r12, %rdi
movl %eax, %esi
callq 0x111aa
testl %eax, %eax
je 0x6dfd
movq %r14, %rdi
callq 0x10f22
movq %r12, %rdi
movl %eax, %esi
callq 0x111aa
cmpl $0x0, 0x330(%rsp)
movq 0x18(%rsp), %r12
je 0x6d2f
cmpl $0x1, %eax
jne 0x6d2f
movq %r14, %rdi
callq 0x10f88
movq %r14, %rdi
movl 0x14(%rsp), %esi
movq 0x8(%rsp), %rbp
movl %ebp, %edx
callq 0x6332
testl %eax, %eax
je 0x6e40
movl $0x1, %ebx
xorl %ecx, %ecx
movl $0x1, 0x24(%rsp)
jmp 0x6c63
movq %r14, %rdi
callq 0x10f88
movq %rbp, %rdi
movl %r13d, %esi
callq 0x1263e
leaq 0x1664e(%rip), %rdi     # 0x1d3c6
movq %rax, %rsi
callq 0x3450
movb $0x1, %r8b
testl %eax, %eax
je 0x6e5a
movq %rbp, %rdi
movl %r13d, %esi
callq 0x1263e
leaq 0x1476d(%rip), %rdi     # 0x1b50a
movq %rax, %rsi
callq 0x3450
testl %eax, %eax
je 0x6f59
movq %rbp, %rdi
movl %r13d, %esi
callq 0x1263e
leaq 0x14128(%rip), %rdi     # 0x1aee7
movq %rax, %rsi
callq 0x3450
testl %eax, %eax
je 0x7067
movq %rbp, %rdi
movl %r13d, %esi
callq 0x1263e
leaq 0x1441d(%rip), %rdi     # 0x1b1fe
movq %rax, %rsi
callq 0x3450
xorl %r8d, %r8d
testl %eax, %eax
sete %r8b
movl %r8d, %edi
shll $0x2, %edi
jmp 0x706f
movl 0x330(%rsp), %eax
orl 0x24(%rsp), %eax
je 0x6e64
movq %r14, %rdi
callq 0x10f88
movq %r14, %rdi
movl 0x14(%rsp), %esi
movq 0x8(%rsp), %rdx
callq 0x6332
testl %eax, %eax
jne 0x714e
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x18(%rsp), %r12
jmp 0x6e51
incl %ebp
movq %rbp, 0x8(%rsp)
movl $0x1, 0x24(%rsp)
xorl %ebp, %ebp
movl 0x20(%rsp), %edx
jmp 0x6f93
movl $0x1, %edi
jmp 0x706f
leaq 0x1e875(%rip), %r12     # 0x256e0
movq 0x28(%r12), %rax
testb $0x4, 0x29(%rax,%rbp)
sete %cl
movl 0x20(%rsp), %eax
movl %eax, %ebp
orb %al, %cl
movl %ecx, 0x60(%rsp)
je 0x6f63
movq %r14, %rdi
callq 0x10f88
movslq %eax, %rdx
movq 0x28(%r12), %rcx
imulq $0xb0, %rdx, %rdx
movw $0x2, 0x20(%rcx,%rdx)
movw $0x0, 0x50(%rcx,%rdx)
testl %ebp, %ebp
movl $0x3, %esi
movl $0x101, %edi            # imm = 0x101
cmovneq %rdi, %rsi
xorl %edi, %edi
movq 0x78(%rsp), %r10
testl %r10d, %r10d
sete %dil
movq %rdi, 0x48(%rcx,%rdx)
movzwl (%r12), %edi
cmovew %r13w, %di
movl $0x4, %r8d
cmovel %r8d, %r10d
movq %rsi, %r8
movl $0x1, %r9d
cmoveq %r9, %r8
testl %ebp, %ebp
cmovneq %rsi, %r8
leaq (%rcx,%rdx), %rsi
movw %di, 0x30(%rcx,%rdx)
movq %r10, 0x38(%rcx,%rdx)
movq 0x70(%rsp), %rdi
movl (%rdi), %edi
incl %edi
movw %di, 0x40(%rcx,%rdx)
orq %r8, 0x28(%rcx,%rdx)
testb $0x1, 0x30(%rsp)
movl %ebp, %edx
je 0x6f2b
orq $0x10040, 0x28(%rsi)    # imm = 0x10040
movq 0x28(%rsp), %rcx
movl 0x8d40(%rcx), %ecx
movq 0x8(%rsp), %rdi
leal 0x4(,%rdi,4), %r8d
incl %edi
subl %r8d, %ecx
movl %ecx, 0x34(%rsi)
movl %edi, %ecx
movq %rcx, 0x8(%rsp)
movq 0x18(%rsp), %r12
jmp 0x6f7b
movl $0x4, %edi
jmp 0x706c
leaq 0x13fc5(%rip), %rdi     # 0x1af2f
xorl %eax, %eax
callq 0x10418
movl %r13d, %eax
movq 0x18(%rsp), %r12
movl %ebp, %edx
movl 0x60(%rsp), %ebp
movl $0x0, 0x24(%rsp)
movl %eax, %r13d
testb %bpl, %bpl
je 0x7060
movq %r14, %rdi
movl %r13d, %esi
callq 0x6459
testl %eax, %eax
js 0x7060
je 0x6ffd
leaq 0x1e731(%rip), %rax     # 0x256e0
movq 0x28(%rax), %rax
movq 0x8(%rsp), %rcx
decl %ecx
movslq %ecx, %rcx
imulq $0x51eb851f, %rcx, %rdx # imm = 0x51EB851F
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x25, %rdx
addl %esi, %edx
imull $0x64, %edx, %edx
subl %edx, %ecx
movslq %ecx, %rcx
movq 0x58(%rax,%r15), %rdx
orq $0x10000000, (%rdx,%rcx,8) # imm = 0x10000000
testb %bpl, %bpl
je 0x6ffd
movslq %r13d, %rcx
imulq $0xb0, %rcx, %rcx
orl $0x40002, 0x28(%rax,%rcx) # imm = 0x40002
movq %r14, %rdi
callq 0x10f88
movq %rax, %r13
leaq 0x1e6d1(%rip), %rdi     # 0x256e0
movl %r13d, %esi
callq 0x111aa
xorl %ecx, %ecx
cmpl $0x2a, %eax
je 0x7109
cmpl $0x6, %eax
je 0x70ff
leaq 0x40(%rsp), %rdi
leaq 0x1e6a9(%rip), %rsi     # 0x256e0
movl %r13d, %edx
cmpl $0x1, %eax
jne 0x711a
callq 0x11fa0
movq 0x40(%rsp), %rsi
leaq 0x13f00(%rip), %rdi     # 0x1af54
xorl %eax, %eax
callq 0x10418
jmp 0x7132
xorl %ecx, %ecx
jmp 0x6c63
movl $0x2, %edi
movb $0x1, %r8b
testb %r8b, %r8b
movq 0x60(%rsp), %r9
leaq 0x1e662(%rip), %rdx     # 0x256e0
je 0x7094
movslq (%rdx), %rax
movq 0x28(%rdx), %rcx
movq 0x58(%rcx,%r15), %rcx
movq %rax, (%rcx,%r12,8)
xorl %esi, %esi
jmp 0x70aa
movq 0x28(%rdx), %rax
movq 0x58(%rax,%r15), %rax
orq $0x40000000, (%rax,%r12,8) # imm = 0x40000000
movl $0x1, %esi
movq 0x28(%rdx), %rax
imulq $0xb0, %r9, %rcx
movq 0x28(%rax,%rcx), %rax
movl %eax, %ecx
shrl $0xc, %ecx
andl $0x1, %ecx
orb %cl, %r8b
je 0x70e5
movl %esi, 0x20(%rsp)
btl $0x11, %eax
leaq 0x1e60a(%rip), %rbp     # 0x256e0
jae 0x6cb2
leaq 0x13e35(%rip), %rdi     # 0x1af18
jmp 0x70ec
leaq 0x13e01(%rip), %rdi     # 0x1aeed
xorl %eax, %eax
callq 0x10418
xorl %ecx, %ecx
movl $0x1, %ebx
jmp 0x6c5e
movl $0x3, %ebx
jmp 0x6c63
movb $0x1, %cl
movl $0x0, 0x30(%rsp)
xorl %ebx, %ebx
jmp 0x6c63
callq 0x11fa0
movq 0x40(%rsp), %rsi
leaq 0x13e5c(%rip), %rdi     # 0x1af87
xorl %eax, %eax
callq 0x10418
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x714e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3320
xorl %ecx, %ecx
jmp 0x6c5e
cmpl $0x3, %ebx
jne 0x69ac
movq 0x8(%rsp), %rsi
decl %esi
leaq 0x1e574(%rip), %rax     # 0x256e0
movq 0x28(%rax), %rax
movw %si, 0x40(%rax,%r15)
movslq 0x6c(%rsp), %rcx
testq %rcx, %rcx
js 0x718d
movq 0x28(%rsp), %rdx
movw %si, 0x7d98(%rdx,%rcx,2)
movq %r14, %r13
addq %r15, %rax
cmpl $0x0, 0x38(%rsp)
je 0x719e
orb $0x20, 0x29(%rax)
cmpl $0x0, 0x330(%rsp)
movq 0x28(%rsp), %r14
je 0x728f
orb $0x4, 0x28(%rax)
cmpl $0x0, 0x338(%rsp)
je 0x71ed
movswl 0x40(%rax), %edx
leaq 0x13df1(%rip), %rsi     # 0x1afbb
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30d0
movq 0x50(%r14), %rax
movslq (%r12), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x3570
movq %r13, %rdi
callq 0x10f22
cmpl $0x0, 0x338(%rsp)
jne 0x7207
movq %r13, %rdi
callq 0x10f88
leaq 0x1e4d2(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
movl %eax, %ebx
cmpl $0x28, %eax
jne 0x72eb
movl $0xffffffff, (%r12)     # imm = 0xFFFFFFFF
jmp 0x72f9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $-0x2, %eax
je 0x69b1
leaq 0x13c08(%rip), %rdi     # 0x1ae4a
jmp 0x69a5
movq %r14, %rdi
callq 0x10f88
movq %r14, %rdi
callq 0x10f88
leaq 0x1e482(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x1263e
leaq 0x1602c(%rip), %rsi     # 0x1d298
movq %rax, %rdi
callq 0x3450
testl %eax, %eax
leaq 0x1e463(%rip), %rbx     # 0x256e0
je 0x684f
leaq 0x13a9c(%rip), %rdi     # 0x1ad26
jmp 0x69a5
movq %r13, %rdi
callq 0x10f22
leaq 0x1e442(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x17, %eax
je 0x7307
leaq 0x13d45(%rip), %rdi     # 0x1aff6
jmp 0x69a5
movq %r14, %rdi
callq 0x10f88
leaq 0x1e41b(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x1263e
leaq 0x15fc5(%rip), %rsi     # 0x1d298
movq %rax, %rdi
callq 0x3450
testl %eax, %eax
je 0x730e
leaq 0x13a96(%rip), %rdi     # 0x1ad7c
jmp 0x69a5
leaq 0x13ccd(%rip), %rdi     # 0x1afbf
xorl %eax, %eax
callq 0x10418
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x28, %ebx
jne 0x69b1
xorl %ecx, %ecx
jmp 0x69b1
leaq 0x13a3c(%rip), %rdi     # 0x1ad51
jmp 0x69a5
jmp 0x731e
jmp 0x731e
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x733d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3560