// File: /workspace/github_cpp_makefile_star2_O1/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 0xb87a
movq %rbx, -0x40(%rbp)
cmpl $0x0, 0x64(%rbx)
jne 0xc543
movq %rax, %r14
cmpb $0x3c, (%rax)
je 0xc543
movq -0x40(%rbp), %rax
leaq 0xc0(%rax), %r15
leaq 0x55d2(%rip), %r12      # 0x11718
xorl %ebx, %ebx
movq %r14, %rax
xorl %ecx, %ecx
xorl %r13d, %r13d
movzbl (%rax), %edx
shll %cl, %edx
orl %edx, %r13d
addq $0x8, %rcx
incq %rax
cmpq $0x10, %rcx
jne 0xc150
leal -0xfff6(%r13), %eax
cmpl $0x4, %eax
ja 0xc201
leaq 0x532c(%rip), %rcx      # 0x114a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %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 0xc6b8(%rip), %rcx      # 0x18890
movq %rcx, (%rax)
movl $0xfff6, 0x28(%rax)     # imm = 0xFFF6
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd5fa
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
jmp 0xc4b5
cmpl $0x8000, %r13d          # imm = 0x8000
jne 0xc22a
movl $0x4, %edx
movq 0xcdaa(%rip), %r13      # 0x18fc0
movq %r13, %rdi
movq %r12, %rsi
callq 0x73b0
movq (%r13), %rax
jmp 0xc510
leal -0x1(%r13), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0xc4c0
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 0xc9b4(%rip), %rcx      # 0x18c40
movq %rcx, (%rax)
leaq 0xa0(%rax), %rcx
movq %rcx, 0x90(%rax)
movq %rbx, 0x98(%rax)
movb %bl, 0xa0(%rax)
movl %r13d, 0x28(%rax)
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd7e4
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
jmp 0xc4b5
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 0xc878(%rip), %rcx      # 0x18b98
movq %rcx, (%rax)
movl $0xfffa, 0x28(%rax)     # imm = 0xFFFA
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd782
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
jmp 0xc4b5
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 0xc6ac(%rip), %rcx      # 0x18a48
movq %rcx, (%rax)
movl $0xfff8, 0x28(%rax)     # imm = 0xFFF8
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd6be
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
jmp 0xc4b5
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 0xc6d8(%rip), %rcx      # 0x18af0
movq %rcx, (%rax)
movl $0xfff9, 0x28(%rax)     # imm = 0xFFF9
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd720
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
jmp 0xc4b5
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 0xc50f(%rip), %rcx      # 0x189a0
movq %rcx, (%rax)
movl $0xfff7, 0x28(%rax)     # imm = 0xFFF7
leaq -0x38(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xd65c
movq %r15, %rdi
movq %r13, %rsi
callq 0xe172
leaq -0x30(%rbp), %rdi
callq 0x8dc6
jmp 0xc534
movl $0xd, %edx
movq %r15, %r12
movq 0xcaf1(%rip), %r15      # 0x18fc0
movq %r15, %rdi
leaq 0x5244(%rip), %rsi      # 0x1171d
callq 0x73b0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r15,%rax)
movq %r15, %rdi
movq %r12, %r15
leaq 0x5216(%rip), %r12      # 0x11718
movl %r13d, %esi
callq 0x7580
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x7300
movsbl %al, %esi
movq %r13, %rdi
callq 0x7050
movq %rax, %rdi
callq 0x7230
cmpb $0x3c, 0x2(%r14)
leaq 0x2(%r14), %r14
jne 0xc148
movq -0x40(%rbp), %rdi
callq 0xb87a
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc567
jmp 0xc567
jmp 0xc567
jmp 0xc567
jmp 0xc567
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x8dc6
movq %rbx, %rdi
callq 0x75b0
nop