// File: /workspace/github_cpp_makefile_star2_O3/maplechori[P]stata-reader-writer/State.cpp
// Function: OpenVarTypes::process(Context&)
bool OpenVarTypes::process(Context &ctx)
{
  char *ctxbuf = (char *)ctx.advance();
  int curr = 0;
  StataVariablesImpl<double> *sta_double;
  StataVariablesImpl<float> *sta_float;
  StataVariablesImpl<long> *sta_long;
  StataVariablesImpl<short> *sta_integer;
  StataVariablesImpl<int8_t> *sta_byte;
  StataVariablesImpl<string> *sta_char;

  if (ctx.hdr.fileByteorder == LSF)
  {

    while (*ctxbuf != '<')
    {
      int stataType = GetLSF<unsigned int>(ctxbuf, 2);

      switch (stataType)
      {
      case ST_STRL:
        cout << "STRL" << endl;

        // handle STRLs
        break;
      case ST_DOUBLE:
        sta_double = new StataVariablesImpl<double>();
        sta_double->type = stataType;
        ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_double));
        break;
      case ST_FLOAT:
        sta_float = new StataVariablesImpl<float>();
        sta_float->type = stataType;
        ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_float));
        break;
      case ST_LONG:
        sta_long = new StataVariablesImpl<long>();
        sta_long->type = stataType;
        ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_long));
        break;
      case ST_INT:
        sta_integer = new StataVariablesImpl<short>();
        sta_integer->type = stataType;
        ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_integer));
        break;
      case ST_BYTE:
        sta_byte = new StataVariablesImpl<int8_t>();
        sta_byte->type = stataType;
        ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_byte));
        break;
      default:
        if (stataType > 0 && stataType <= 2045)
        {
          sta_char = new StataVariablesImpl<string>();
          sta_char->type = stataType;
          ctx.vList.push_back(boost::shared_ptr<StataVariables>(sta_char));
        }
        else
          cout << "UNKNOWN TYPE " << hex << stataType << endl;
        break;
      }

      ctxbuf += 2;
      curr++;
    }
  }
  else
  {
    // not implemented yet
  }

  ctx.advance();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rsi, %rdi
callq 0xb856
movq %rbx, -0x40(%rbp)
cmpl $0x0, 0x64(%rbx)
jne 0xc4c2
movq %rax, %r14
movb (%rax), %al
cmpb $0x3c, %al
je 0xc4c2
movq -0x40(%rbp), %rcx
leaq 0xc0(%rcx), %r13
addq $0x2, %r14
leaq 0x5649(%rip), %r12      # 0x11718
xorl %ebx, %ebx
movzbl %al, %eax
movzbl -0x1(%r14), %r15d
shll $0x8, %r15d
leal (%r15,%rax), %ecx
addl $0xffff000a, %ecx       # imm = 0xFFFF000A
cmpl $0x4, %ecx
ja 0xc17c
leaq 0x5395(%rip), %rdx      # 0x1148c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x98, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xc785(%rip), %rcx      # 0x188d8
movq %rcx, (%rax)
movl $0xfff6, 0x28(%rax)     # imm = 0xFFF6
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd594
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
jmp 0xc433
orl %eax, %r15d
cmpl $0x8000, %r15d          # imm = 0x8000
jne 0xc1a7
movl $0x4, %edx
movq 0xce2c(%rip), %r15      # 0x18fc0
movq %r15, %rdi
movq %r12, %rsi
callq 0x73b0
movq (%r15), %rax
jmp 0xc48f
movl %r15d, %eax
decl %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0xc43e
movl $0xb0, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xca36(%rip), %rcx      # 0x18c40
movq %rcx, (%rax)
leaq 0xa0(%rax), %rcx
movq %rcx, 0x90(%rax)
movq %rbx, 0x98(%rax)
movb %bl, 0xa0(%rax)
movl %r15d, 0x28(%rax)
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd77e
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
jmp 0xc433
movl $0x98, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xc8fa(%rip), %rcx      # 0x18b98
movq %rcx, (%rax)
movl $0xfffa, 0x28(%rax)     # imm = 0xFFFA
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd71c
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
jmp 0xc433
movl $0x98, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xc72e(%rip), %rcx      # 0x18a48
movq %rcx, (%rax)
movl $0xfff8, 0x28(%rax)     # imm = 0xFFF8
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd658
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
jmp 0xc433
movl $0x98, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xc75a(%rip), %rcx      # 0x18af0
movq %rcx, (%rax)
movl $0xfff9, 0x28(%rax)     # imm = 0xFFF9
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd6ba
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
jmp 0xc433
movl $0x98, %edi
callq 0x7330
leaq 0x18(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movb %bl, 0x18(%rax)
leaq 0x40(%rax), %rcx
movq %rcx, 0x30(%rax)
movq %rbx, 0x38(%rax)
movb %bl, 0x40(%rax)
leaq 0x60(%rax), %rcx
movq %rcx, 0x50(%rax)
movq %rbx, 0x58(%rax)
movb %bl, 0x60(%rax)
leaq 0x80(%rax), %rcx
movq %rcx, 0x70(%rax)
movq %rbx, 0x78(%rax)
movb %bl, 0x80(%rax)
leaq 0xc591(%rip), %rcx      # 0x189a0
movq %rcx, (%rax)
movl $0xfff7, 0x28(%rax)     # imm = 0xFFF7
leaq -0x38(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd5f6
movq %r13, %rdi
movq %r15, %rsi
callq 0xe102
leaq -0x30(%rbp), %rdi
callq 0x8d94
jmp 0xc4b3
movl $0xd, %edx
movq %r13, %r12
movq 0xcb73(%rip), %r13      # 0x18fc0
movq %r13, %rdi
leaq 0x52c6(%rip), %rsi      # 0x1171d
callq 0x73b0
movq (%r13), %rax
movq -0x18(%rax), %rax
movl 0x18(%r13,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r13,%rax)
movq %r13, %rdi
movq %r12, %r13
leaq 0x5297(%rip), %r12      # 0x11718
movl %r15d, %esi
callq 0x7580
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x7300
movsbl %al, %esi
movq %r15, %rdi
callq 0x7050
movq %rax, %rdi
callq 0x7230
movb (%r14), %al
addq $0x2, %r14
cmpb $0x3c, %al
jne 0xc0d1
movq -0x40(%rbp), %rdi
callq 0xb856
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc4e6
jmp 0xc4e6
jmp 0xc4e6
jmp 0xc4e6
jmp 0xc4e6
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x8d94
movq %rbx, %rdi
callq 0x75b0