// File: rofl0r[P]ascc/cs_parser.cpp
// Function: do_variable_ax(int, long*, ccCompiledScript*, int, int, bool)
int do_variable_ax(int slilen,long*syml,ccCompiledScript*scrip,int writing, int mustBeWritable, bool negateLiteral = false) {
  // read the various types of values into AX
  int ee;

  if (!writing)
    set_ax_scope(scrip, syml[0]);

  // separate out the variable path, into a variablePath
  // for the bit between each dot
  VariableSymlist variablePath[MAX_VARIABLE_PATH];

  int variablePathSize = extractPathIntoParts(variablePath, slilen, syml);
  if (variablePathSize == -1)
    return -1;

  int currentByteOffset = 0;
  // remember the type of the first variable in the list (since
  // that determines whether this is global/local)
  int firstVariableType, firstVariableSym = -1;
  bool isArrayOffset = false;
  bool isPointer = false;
  bool isDynamicArray = false;

  for (ee = 0; ee < variablePathSize; ee++) {
    VariableSymlist *thisClause = &variablePath[ee];

    int variableSym = thisClause->syml[0];
    int variableSymType = sym.get_type(variableSym);
    if (firstVariableSym < 0) {
      firstVariableSym = variableSym;
      firstVariableType = variableSymType;
    }

    // each clause in the chain can be marked as Accessed
    sym.entries[variableSym].flags |= SFLG_ACCESSED;

    bool getAddressOnlyIntoAX = false;
    bool doMemoryAccessNow = false;
    bool isLastClause = (ee == variablePathSize - 1);
    bool cannotAssign = false;
    bool isProperty = false;
    bool accessActualPointer = false;

    // the memory access only wants to write if this is the
    // end of the path, not an intermediate pathing property
    bool writingThisTime = isLastClause && writing;

    // offset to add to CX after array index is calculated for struct member in dynarray
    int array_struct_offset_add = 0;

    if (sym.entries[variableSym].flags & SFLG_PROPERTY) { }
    else if (sym.entries[variableSym].flags & SFLG_IMPORTED) { }
    else if (isDynamicArray && variableSymType == SYM_STRUCTMEMBER) {
      array_struct_offset_add = sym.entries[variableSym].soffs;
    }
    else if ((variableSymType == SYM_GLOBALVAR) || (variableSymType == SYM_LOCALVAR) ||
        (variableSymType == SYM_STRUCTMEMBER) || (variableSymType == SYM_STRING)) {
      // since the member has a fixed offset into the structure, don't
      // write out any code to calculate the offset - instead, modify
      // the hard offset value which will be written to MAR
      currentByteOffset += sym.entries[variableSym].soffs;
    }

    if (variableSymType == SYM_FUNCTION) {
      // member function. all that's wanted is the owning object's
      // address
      getAddressOnlyIntoAX = true;
      doMemoryAccessNow = true;

      if (!isLastClause) {
        cc_error("Function().Member not supported");
        return -1;
      }
    }
    else if (sym.entries[variableSym].flags & SFLG_PROPERTY) {
      // since a property is effectively a function call, load
      // the object's address
      getAddressOnlyIntoAX = true;
      doMemoryAccessNow = true;
      isProperty = true;

      if ((sym.entries[variableSym].flags & SFLG_ARRAY) &&
          ((thisClause->len <= 1) ||
           (sym.get_type(thisClause->syml[1]) != SYM_OPENBRACKET))) {
        // normally, the whole array can be used as a pointer.
        // this is not the case with an property array, so catch
        // it here and give an error
        cc_error("Expected array index after '%s'", sym.get_friendly_name(variableSym).c_str());
        return -1;
      }

      if (parseArrayIndexOffsets(scrip, thisClause, writing != 0, &isArrayOffset))
        return -1;

      if (mustBeWritable) {
        // cannot use ++ or -- with property, because the memory
        // access shortcut won't work
        // Therefore, tell the caller to do it properly
        // and call us again to write the value
        readonly_cannot_cause_error = 1;
      }
      else if (writing) {

        if ((writingThisTime) && (sym.entries[variableSym].flags & SFLG_READONLY)) {
          cc_error("property '%s' is read-only", sym.get_friendly_name(variableSym).c_str());
          return -1;
        }

        // Property Set -- move the new value into BX, so
        // that the object address can be retrieved into AX
        scrip->write_cmd2(SCMD_REGTOREG, SREG_AX, SREG_BX);
      }

    }
    else if (sym.entries[variableSym].flags & SFLG_POINTER) {
      bool isArrayOfPointers = false;

      if (sym.entries[variableSym].flags & SFLG_ARRAY) {
        // array of pointers

        if ((thisClause->len <= 1) ||
           (sym.get_type(thisClause->syml[1]) != SYM_OPENBRACKET)) {
          // normally, the whole array can be used as a pointer.
          // this is not the case with an pointer array, so catch
          // it here and give an error
          if (sym.entries[variableSym].flags & SFLG_DYNAMICARRAY)
          {
            isDynamicArray = true;
          }
          else
          {
            cc_error("Expected array index after '%s'", sym.get_friendly_name(variableSym).c_str());
            return -1;
          }
        }
        else
        {
          // put array index into DX
          if (parseArrayIndexOffsets(scrip, thisClause, writing != 0, &isArrayOffset))
            return -1;

          isArrayOfPointers = true;
        }
      }

      // if they are just saying "ptr" (or doing a "ptr.Func" call)
      // then move the address being pointed to into AX
      // (member function call passes in "ptr.")
      if (isLastClause)
        getAddressOnlyIntoAX = true;

      // Push the pointer address onto the stack, where it can be
      // retrieved by do_variable_memory_access later on
      if (sym.entries[variableSym].flags & SFLG_THISPTR) {
        if (isPointer) {
          // already a pointer on the stack
          cc_error("Nested this pointers??");
          return -1;
        }

        // for the "this" pointer, just use the Object Pointer
        scrip->push_reg(SREG_OP);
      }
      else {
        // currentByteOffset has been set at the start of this loop
        // so it is safe to use

        if (isPointer) {
          // already a pointer on the stack
          scrip->pop_reg(SREG_MAR);
          scrip->write_cmd(SCMD_CHECKNULL);
          if (currentByteOffset > 0)
            scrip->write_cmd2(SCMD_ADD, SREG_MAR, currentByteOffset);
        }
        else if (firstVariableType == SYM_LOCALVAR) {
          load_stack_variable(scrip, scrip->cur_sp - currentByteOffset);
        }
        else if (firstVariableType == SYM_GLOBALVAR) {

          if (sym.entries[firstVariableSym].flags & SFLG_IMPORTED) {
            scrip->write_cmd2(SCMD_LITTOREG, SREG_MAR, sym.entries[firstVariableSym].soffs);
            scrip->fixup_previous(FIXUP_IMPORT);
            if (currentByteOffset)
              scrip->write_cmd2(SCMD_ADD, SREG_MAR, currentByteOffset);
          }
          else {
            scrip->write_cmd2(SCMD_LITTOREG, SREG_MAR, currentByteOffset);
            scrip->fixup_previous(FIXUP_GLOBALDATA);
          }
        }
        else {
          cc_error("Invalid type for pointer");
          return -1;
        }

        // if an array, the array indexer was put into DX
        if (isArrayOfPointers)
        {
          scrip->write_cmd2(SCMD_MUL, SREG_DX, 4);

          if (sym.entries[variableSym].flags & SFLG_DYNAMICARRAY)
          {
            // pointer to an array -- dereference the pointer
            scrip->write_cmd1(SCMD_MEMREADPTR, SREG_MAR);
            scrip->write_cmd(SCMD_CHECKNULL);
            scrip->write_cmd1(SCMD_DYNAMICBOUNDS, SREG_DX);
          }

          scrip->write_cmd2(SCMD_ADDREG, SREG_MAR, SREG_DX);
        }

        // push the pointer's address
        scrip->push_reg(SREG_MAR);
        getAddressOnlyIntoAX = true;
        accessActualPointer = true;
        doMemoryAccessNow = true;
      }
      currentByteOffset = 0;

      // Pointer
      isPointer = true;
    }
    else {

      if (sym.entries[variableSym].flags & SFLG_DYNAMICARRAY)
      {
        isDynamicArray = true;
      }

      if (parseArrayIndexOffsets(scrip, thisClause, writing != 0, &isArrayOffset))
        return -1;

    }

    // if one of the struct members in the path is read-only, don't allow it
    if (((writing) || (mustBeWritable)) && (readonly_cannot_cause_error == 0)) {
      // allow writing to read-only pointers if it's actually
      // a property being accessed
      if ((sym.entries[variableSym].flags & SFLG_POINTER) && (!isLastClause)) { }
      else if (sym.entries[variableSym].flags & SFLG_READONLY) {
        cc_error("variable '%s' is read-only", sym.get_friendly_name(variableSym).c_str());
        return -1;
      }
      else if (sym.entries[variableSym].flags & SFLG_WRITEPROTECTED) {
        // write-protected variables can only be written by
        // the this ptr
        if ((ee > 0) && (sym.entries[variablePath[ee - 1].syml[0]].flags & SFLG_THISPTR)) { }
        else {
          cc_error("variable '%s' is write-protected", sym.get_friendly_name(variableSym).c_str());
          return -1;
        }

      }
    }


    if (sym.entries[variableSym].flags & SFLG_ARRAY) {
      // array without index specified -- get address
      if ((thisClause->len == 1) ||
          (sym.get_type(thisClause->syml[1]) != SYM_OPENBRACKET)) {

        if ((sym.entries[variableSym].flags & SFLG_DYNAMICARRAY) == 0
           && sym.entries[variableSym].arrsize != 0)
        {
          getAddressOnlyIntoAX = true;
          cannotAssign = true;
        }
      }

    }

    if (sym.entries[variableSym].flags & SFLG_POINTER) { }
    else if (sym.entries[sym.entries[variableSym].vartype].flags & SFLG_STRUCTTYPE) {
      // struct variable without member access
      if (isLastClause)
      {
        if ((sym.entries[variableSym].flags & SFLG_DYNAMICARRAY) == 0)
        {
          getAddressOnlyIntoAX = true;
          cannotAssign = true;
        }
      }
    }

    if ((writing) && (cannotAssign)) {
      // an entire array or struct cannot be assigned to
      cc_error("cannot assign to '%s'", sym.get_friendly_name(variableSym).c_str());
      return -1;
    }

    if ((doMemoryAccessNow) || (isLastClause)) {

      int cachedAxValType = scrip->ax_val_type;

      // if a pointer in use, then its address was pushed on the
      // stack, so restore it here
      if (isPointer)
        scrip->pop_reg(SREG_MAR);

      // in a writing operation, but not doing it just yet -- push
      // AX to save the value to write
      if ((writing) && (!writingThisTime))
        scrip->push_reg(SREG_AX);

      if (do_variable_memory_access(scrip, variableSym, variableSymType,
                                    isProperty, writingThisTime, mustBeWritable,
                                    getAddressOnlyIntoAX, isArrayOffset,
                                    currentByteOffset, isPointer,
                                    accessActualPointer,
                                    firstVariableSym, firstVariableType,
                                    isDynamicArray, negateLiteral, array_struct_offset_add))
        return -1;

      // reset stuff
      currentByteOffset = 0;
      array_struct_offset_add = 0;
      isArrayOffset = false;
      isPointer = false;
      isDynamicArray = false;
      //firstVariableSym = -1;
      firstVariableType = SYM_GLOBALVAR;

      if (!isLastClause) {
        if ((isProperty) || (getAddressOnlyIntoAX)) {
          // pathing, eg. lstItems.OwningGUI.ID
          // we just read a pointer address, so re-push it for use
          // next time round
          if (writing) {
            scrip->ax_val_type = cachedAxValType;
            // the value to write was pushed onto the stack,
            // pop it back into BX
            scrip->pop_reg(SREG_BX);
            // meanwhile push the pointer
            // that was just read into AX onto the stack in its place
            scrip->push_reg(SREG_AX);
            // and then copy the value back into AX
            scrip->write_cmd2(SCMD_REGTOREG, SREG_BX, SREG_AX);
          }
          else
            scrip->push_reg(SREG_AX);

          isPointer = true;
        }
        else {
          cc_error("Invalid pathing: unexpected '%s'", sym.get_friendly_name(variablePath[ee + 1].syml[0]).c_str());
          return -1;
        }

      }

      // proceed round loop to next clause
    }


  }

  // free the VariablePaths
  for (ee = 0; ee < variablePathSize; ee++)
    variablePath[ee].destroy();

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movb %r9b, %al
movl %edi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movl %ecx, -0x44(%rbp)
movl %r8d, -0x48(%rbp)
andb $0x1, %al
movb %al, -0x49(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0xe8c6
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl %eax, %esi
callq 0xb610
leaq -0xf0(%rbp), %rdi
movl -0x30(%rbp), %esi
movq -0x38(%rbp), %rdx
callq 0xb7d0
movl %eax, -0xf4(%rbp)
cmpl $-0x1, -0xf4(%rbp)
jne 0xe8f4
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movl $0x0, -0xf8(%rbp)
movl $0xffffffff, -0x100(%rbp) # imm = 0xFFFFFFFF
movb $0x0, -0x101(%rbp)
movb $0x0, -0x102(%rbp)
movb $0x0, -0x103(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0xf4(%rbp), %eax
jge 0xf875
movslq -0x50(%rbp), %rcx
leaq -0xf0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movl %eax, -0x114(%rbp)
movl -0x114(%rbp), %esi
leaq 0x33f03(%rip), %rdi     # 0x42870
callq 0x1e1e0
movl %eax, -0x118(%rbp)
cmpl $0x0, -0x100(%rbp)
jge 0xe999
movl -0x114(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x118(%rbp), %eax
movl %eax, -0xfc(%rbp)
movslq -0x114(%rbp), %rsi
leaq 0x33ec9(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rcx
orq $0x8, %rcx
movq %rcx, 0x28(%rax)
movb $0x0, -0x119(%rbp)
movb $0x0, -0x11a(%rbp)
movl -0x50(%rbp), %eax
movl -0xf4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movb %al, -0x11b(%rbp)
movb $0x0, -0x11c(%rbp)
movb $0x0, -0x11d(%rbp)
movb $0x0, -0x11e(%rbp)
xorl %eax, %eax
testb $0x1, -0x11b(%rbp)
movb %al, -0x229(%rbp)
je 0xea16
cmpl $0x0, -0x44(%rbp)
setne %al
movb %al, -0x229(%rbp)
movb -0x229(%rbp), %al
andb $0x1, %al
movb %al, -0x11f(%rbp)
movl $0x0, -0x124(%rbp)
movslq -0x114(%rbp), %rsi
leaq 0x33e34(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x200, %rax            # imm = 0x200
cmpq $0x0, %rax
je 0xea5a
jmp 0xeb08
movslq -0x114(%rbp), %rsi
leaq 0x33e08(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0xea84
jmp 0xeb06
testb $0x1, -0x103(%rbp)
je 0xeab8
cmpl $0xa, -0x118(%rbp)
jne 0xeab8
movslq -0x114(%rbp), %rsi
leaq 0x33dcc(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movl 0x34(%rax), %eax
movl %eax, -0x124(%rbp)
jmp 0xeb04
cmpl $0x1, -0x118(%rbp)
je 0xeadc
cmpl $0x2, -0x118(%rbp)
je 0xeadc
cmpl $0xa, -0x118(%rbp)
je 0xeadc
cmpl $0x12, -0x118(%rbp)
jne 0xeb02
movslq -0x114(%rbp), %rsi
leaq 0x33d86(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movl 0x34(%rax), %eax
addl -0xf8(%rbp), %eax
movl %eax, -0xf8(%rbp)
jmp 0xeb04
jmp 0xeb06
jmp 0xeb08
cmpl $0x4, -0x118(%rbp)
jne 0xeb47
movb $0x1, -0x119(%rbp)
movb $0x1, -0x11a(%rbp)
testb $0x1, -0x11b(%rbp)
jne 0xeb42
leaq 0x2382b(%rip), %rdi     # 0x3235a
movb $0x0, %al
callq 0x1bac0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
jmp 0xf1ef
movslq -0x114(%rbp), %rsi
leaq 0x33d1b(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x200, %rax            # imm = 0x200
cmpq $0x0, %rax
je 0xed74
movb $0x1, -0x119(%rbp)
movb $0x1, -0x11a(%rbp)
movb $0x1, -0x11d(%rbp)
movslq -0x114(%rbp), %rsi
leaq 0x33cdb(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xec58
movq -0x110(%rbp), %rax
cmpl $0x1, (%rax)
jle 0xebde
movq -0x110(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
leaq 0x33c9c(%rip), %rdi     # 0x42870
callq 0x1e1e0
cmpl $0x7, %eax
je 0xec58
movl -0x114(%rbp), %edx
leaq 0x33c85(%rip), %rsi     # 0x42870
leaq -0x148(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x1f080
movq -0x238(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x23766(%rip), %rdi     # 0x3237a
xorl %eax, %eax
callq 0x1bac0
jmp 0xec1d
leaq -0x148(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
movq -0x40(%rbp), %rdi
movq -0x110(%rbp), %rsi
cmpl $0x0, -0x44(%rbp)
setne %al
movzbl %al, %edx
andl $0x1, %edx
leaq -0x101(%rbp), %rcx
callq 0xd920
cmpl $0x0, %eax
je 0xec8d
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
cmpl $0x0, -0x48(%rbp)
je 0xeca2
movl $0x1, 0x33ba7(%rip)     # 0x42844
jmp 0xed6f
cmpl $0x0, -0x44(%rbp)
je 0xed6d
testb $0x1, -0x11f(%rbp)
je 0xed58
movslq -0x114(%rbp), %rsi
leaq 0x33ba9(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0xed58
movl -0x114(%rbp), %edx
leaq 0x33b85(%rip), %rsi     # 0x42870
leaq -0x178(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x1f080
movq -0x240(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x23686(%rip), %rdi     # 0x3239a
xorl %eax, %eax
callq 0x1bac0
jmp 0xed1d
leaq -0x178(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
movq -0x40(%rbp), %rdi
movl $0x3, %edx
movl $0x4, %ecx
movl %edx, %esi
callq 0x25240
jmp 0xed6f
jmp 0xf1ed
movslq -0x114(%rbp), %rsi
leaq 0x33aee(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x100, %rax            # imm = 0x100
cmpq $0x0, %rax
je 0xf186
movb $0x0, -0x179(%rbp)
movslq -0x114(%rbp), %rsi
leaq 0x33abc(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xeeeb
movq -0x110(%rbp), %rax
cmpl $0x1, (%rax)
jle 0xee01
movq -0x110(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
leaq 0x33a7d(%rip), %rdi     # 0x42870
callq 0x1e1e0
cmpl $0x7, %eax
je 0xeead
movslq -0x114(%rbp), %rsi
leaq 0x33a61(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0xee31
movb $0x1, -0x103(%rbp)
jmp 0xeeab
movl -0x114(%rbp), %edx
leaq 0x33a32(%rip), %rsi     # 0x42870
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x1f080
movq -0x248(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x23513(%rip), %rdi     # 0x3237a
xorl %eax, %eax
callq 0x1bac0
jmp 0xee70
leaq -0x1a0(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
jmp 0xeee9
movq -0x40(%rbp), %rdi
movq -0x110(%rbp), %rsi
cmpl $0x0, -0x44(%rbp)
setne %al
movzbl %al, %edx
andl $0x1, %edx
leaq -0x101(%rbp), %rcx
callq 0xd920
cmpl $0x0, %eax
je 0xeee2
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movb $0x1, -0x179(%rbp)
jmp 0xeeeb
testb $0x1, -0x11b(%rbp)
je 0xeefb
movb $0x1, -0x119(%rbp)
movslq -0x114(%rbp), %rsi
leaq 0x33967(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x800, %rax            # imm = 0x800
cmpq $0x0, %rax
je 0xef58
testb $0x1, -0x102(%rbp)
je 0xef45
leaq 0x23483(%rip), %rdi     # 0x323b5
movb $0x0, %al
callq 0x1bac0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq -0x40(%rbp), %rdi
movl $0x6, %esi
callq 0x252f0
jmp 0xf173
testb $0x1, -0x102(%rbp)
je 0xefa4
movq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x25330
movq -0x40(%rbp), %rdi
movl $0x34, %esi
callq 0x25140
cmpl $0x0, -0xf8(%rbp)
jle 0xef9f
movq -0x40(%rbp), %rdi
movl -0xf8(%rbp), %ecx
movl $0x1, %esi
movl $0x2, %edx
callq 0x25240
jmp 0xf0b8
cmpl $0x2, -0xfc(%rbp)
jne 0xefd2
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8d40(%rax), %rax
movslq -0xf8(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x72c0
jmp 0xf0b6
cmpl $0x1, -0xfc(%rbp)
jne 0xf09a
movslq -0x100(%rbp), %rsi
leaq 0x33883(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0xf071
movq -0x40(%rbp), %rax
movq %rax, -0x250(%rbp)
movslq -0x100(%rbp), %rsi
leaq 0x33853(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq -0x250(%rbp), %rdi
movl 0x34(%rax), %ecx
movl $0x6, %esi
movl $0x2, %edx
callq 0x25240
movq -0x40(%rbp), %rdi
movl $0x4, %esi
callq 0x25820
cmpl $0x0, -0xf8(%rbp)
je 0xf06f
movq -0x40(%rbp), %rdi
movl -0xf8(%rbp), %ecx
movl $0x1, %esi
movl $0x2, %edx
callq 0x25240
jmp 0xf098
movq -0x40(%rbp), %rdi
movl -0xf8(%rbp), %ecx
movl $0x6, %esi
movl $0x2, %edx
callq 0x25240
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x25820
jmp 0xf0b4
leaq 0x2332b(%rip), %rdi     # 0x323cc
movb $0x0, %al
callq 0x1bac0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
jmp 0xf0b6
jmp 0xf0b8
testb $0x1, -0x179(%rbp)
je 0xf150
movq -0x40(%rbp), %rdi
movl $0x20, %esi
movl $0x7, %edx
movl $0x4, %ecx
callq 0x25240
movslq -0x114(%rbp), %rsi
leaq 0x33785(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0xf138
movq -0x40(%rbp), %rdi
movl $0x30, %esi
movl $0x2, %edx
callq 0x25200
movq -0x40(%rbp), %rdi
movl $0x34, %esi
callq 0x25140
movq -0x40(%rbp), %rdi
movl $0x47, %esi
movl $0x7, %edx
callq 0x25200
movq -0x40(%rbp), %rdi
movl $0xb, %esi
movl $0x2, %edx
movl $0x7, %ecx
callq 0x25240
movq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x252f0
movb $0x1, -0x119(%rbp)
movb $0x1, -0x11e(%rbp)
movb $0x1, -0x11a(%rbp)
movl $0x0, -0xf8(%rbp)
movb $0x1, -0x102(%rbp)
jmp 0xf1eb
movslq -0x114(%rbp), %rsi
leaq 0x336dc(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0xf1b4
movb $0x1, -0x103(%rbp)
movq -0x40(%rbp), %rdi
movq -0x110(%rbp), %rsi
cmpl $0x0, -0x44(%rbp)
setne %al
movzbl %al, %edx
andl $0x1, %edx
leaq -0x101(%rbp), %rcx
callq 0xd920
cmpl $0x0, %eax
je 0xf1e9
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
jmp 0xf1eb
jmp 0xf1ed
jmp 0xf1ef
cmpl $0x0, -0x44(%rbp)
jne 0xf1ff
cmpl $0x0, -0x48(%rbp)
je 0xf3d3
cmpl $0x0, 0x3363e(%rip)     # 0x42844
jne 0xf3d3
movslq -0x114(%rbp), %rsi
leaq 0x33656(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x100, %rax            # imm = 0x100
cmpq $0x0, %rax
je 0xf241
testb $0x1, -0x11b(%rbp)
jne 0xf241
jmp 0xf3d1
movslq -0x114(%rbp), %rsi
leaq 0x33621(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40, %rax
cmpq $0x0, %rax
je 0xf2e0
movl -0x114(%rbp), %edx
leaq 0x335fd(%rip), %rsi     # 0x42870
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x1f080
movq -0x258(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x23149(%rip), %rdi     # 0x323e5
xorl %eax, %eax
callq 0x1bac0
jmp 0xf2a5
leaq -0x1c0(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
movslq -0x114(%rbp), %rsi
leaq 0x33582(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x8000, %rax           # imm = 0x8000
cmpq $0x0, %rax
je 0xf3cd
cmpl $0x0, -0x50(%rbp)
jle 0xf351
movl -0x50(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0xf0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq (%rax), %rsi
leaq 0x3353a(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x800, %rax            # imm = 0x800
cmpq $0x0, %rax
je 0xf351
jmp 0xf3cb
movl -0x114(%rbp), %edx
leaq 0x33512(%rip), %rsi     # 0x42870
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x1f080
movq -0x260(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x23079(%rip), %rdi     # 0x32400
xorl %eax, %eax
callq 0x1bac0
jmp 0xf390
leaq -0x1e0(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
jmp 0xf3cd
jmp 0xf3cf
jmp 0xf3d1
jmp 0xf3d3
movslq -0x114(%rbp), %rsi
leaq 0x3348f(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xf481
movq -0x110(%rbp), %rax
cmpl $0x1, (%rax)
je 0xf42a
movq -0x110(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
leaq 0x33450(%rip), %rdi     # 0x42870
callq 0x1e1e0
cmpl $0x7, %eax
je 0xf47f
movslq -0x114(%rbp), %rsi
leaq 0x33438(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
jne 0xf47d
movslq -0x114(%rbp), %rsi
leaq 0x33411(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
cmpq $0x0, 0x48(%rax)
je 0xf47d
movb $0x1, -0x119(%rbp)
movb $0x1, -0x11c(%rbp)
jmp 0xf47f
jmp 0xf481
movslq -0x114(%rbp), %rsi
leaq 0x333e1(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x100, %rax            # imm = 0x100
cmpq $0x0, %rax
je 0xf4ad
jmp 0xf52d
movslq -0x114(%rbp), %rsi
leaq 0x333b5(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movswq 0x30(%rax), %rsi
leaq 0x333a0(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x400, %rax            # imm = 0x400
cmpq $0x0, %rax
je 0xf52b
testb $0x1, -0x11b(%rbp)
je 0xf529
movslq -0x114(%rbp), %rsi
leaq 0x33370(%rip), %rdi     # 0x42870
addq $0x28, %rdi
callq 0x17e60
movq 0x28(%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
jne 0xf527
movb $0x1, -0x119(%rbp)
movb $0x1, -0x11c(%rbp)
jmp 0xf529
jmp 0xf52b
jmp 0xf52d
cmpl $0x0, -0x44(%rbp)
je 0xf5ba
testb $0x1, -0x11c(%rbp)
je 0xf5ba
movl -0x114(%rbp), %edx
leaq 0x33323(%rip), %rsi     # 0x42870
leaq -0x200(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x1f080
movq -0x268(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x22eab(%rip), %rdi     # 0x32421
xorl %eax, %eax
callq 0x1bac0
jmp 0xf57f
leaq -0x200(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
testb $0x1, -0x11a(%rbp)
jne 0xf5d0
testb $0x1, -0x11b(%rbp)
je 0xf865
movq -0x40(%rbp), %rax
movl 0x8d4c(%rax), %eax
movl %eax, -0x204(%rbp)
testb $0x1, -0x102(%rbp)
je 0xf5f7
movq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x25330
cmpl $0x0, -0x44(%rbp)
je 0xf614
testb $0x1, -0x11f(%rbp)
jne 0xf614
movq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x252f0
movq -0x40(%rbp), %rdi
movl -0x114(%rbp), %esi
movl -0x118(%rbp), %edx
movb -0x11d(%rbp), %cl
movb -0x11f(%rbp), %al
andb $0x1, %al
movzbl %al, %r8d
movl -0x48(%rbp), %r9d
movb -0x119(%rbp), %al
movb %al, -0x270(%rbp)
movb -0x101(%rbp), %al
movb %al, -0x26f(%rbp)
movl -0xf8(%rbp), %r13d
movb -0x102(%rbp), %r12b
movb -0x11e(%rbp), %r15b
movl -0x100(%rbp), %r14d
movl -0xfc(%rbp), %ebx
movb -0x103(%rbp), %r11b
movb -0x49(%rbp), %r10b
movl -0x124(%rbp), %eax
movl %eax, -0x26c(%rbp)
movb -0x270(%rbp), %al
andb $0x1, %cl
andb $0x1, %al
movb %al, -0x26e(%rbp)
movb -0x26f(%rbp), %al
andb $0x1, %al
movb %al, -0x26d(%rbp)
movb -0x26e(%rbp), %al
andb $0x1, %r12b
andb $0x1, %r15b
andb $0x1, %r11b
andb $0x1, %r10b
movzbl %cl, %ecx
movzbl %al, %eax
movl %eax, (%rsp)
movb -0x26d(%rbp), %al
movzbl %al, %eax
movl %eax, 0x8(%rsp)
movl -0x26c(%rbp), %eax
movl %r13d, 0x10(%rsp)
movzbl %r12b, %r12d
movl %r12d, 0x18(%rsp)
movzbl %r15b, %r15d
movl %r15d, 0x20(%rsp)
movl %r14d, 0x28(%rsp)
movl %ebx, 0x30(%rsp)
movzbl %r11b, %r11d
movl %r11d, 0x38(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x40(%rsp)
movl %eax, 0x48(%rsp)
callq 0xe030
cmpl $0x0, %eax
je 0xf728
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movl $0x0, -0xf8(%rbp)
movl $0x0, -0x124(%rbp)
movb $0x0, -0x101(%rbp)
movb $0x0, -0x102(%rbp)
movb $0x0, -0x103(%rbp)
movl $0x1, -0xfc(%rbp)
testb $0x1, -0x11b(%rbp)
jne 0xf863
testb $0x1, -0x11d(%rbp)
jne 0xf77a
testb $0x1, -0x119(%rbp)
je 0xf7dd
cmpl $0x0, -0x44(%rbp)
je 0xf7c3
movl -0x204(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8d4c(%rax)
movq -0x40(%rbp), %rdi
movl $0x4, %esi
callq 0x25330
movq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x252f0
movq -0x40(%rbp), %rdi
movl $0x3, %ecx
movl $0x4, %edx
movl %ecx, %esi
callq 0x25240
jmp 0xf7d1
movq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x252f0
movb $0x1, -0x102(%rbp)
jmp 0xf861
movslq -0x50(%rbp), %rax
shlq $0x4, %rax
leaq -0xf0(%rbp), %rcx
movq 0x18(%rax,%rcx), %rax
movl (%rax), %edx
leaq 0x33076(%rip), %rsi     # 0x42870
leaq -0x228(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x1f080
movq -0x278(%rbp), %rdi
callq 0x41b0
movq %rax, %rsi
leaq 0x22c14(%rip), %rdi     # 0x32437
xorl %eax, %eax
callq 0x1bac0
jmp 0xf82c
leaq -0x228(%rbp), %rdi
callq 0x4270
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x4270
jmp 0xf8c5
jmp 0xf863
jmp 0xf865
jmp 0xf867
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xe924
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0xf4(%rbp), %eax
jge 0xf8a9
movslq -0x50(%rbp), %rax
leaq -0xf0(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x182c0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xf87c
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x150(%rbp), %rdi
callq 0x4670
nopw %cs:(%rax,%rax)