// File: /workspace/github_cpp_makefile_star2_O2/maplechori[P]stata-reader-writer/State.cpp
// Function: OpenInnerValueLabel::process(Context&)
bool OpenInnerValueLabel::process(Context &ctx)
{
  char *ctxbuf = (char *)ctx.advance();
  char *txtorig = NULL;
  int curr = 0, sz = 0, totalSize = 0, entries = 0, txtlen = 0, *offsets = NULL;
  StataValueLabel *svl = new StataValueLabel();

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

    switch (ctx.hdr.fileRelease)
    {

    case R119:
    case R118:

      totalSize = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;
      sz = strlen((char *)ctxbuf);
      svl->labname.assign(&ctxbuf[0], sz);
      ctxbuf += 132;
      entries = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;
      txtlen = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;

      offsets = new int[entries];

      for (int i = 0; i < entries; ctxbuf += 4, i++)
        offsets[i] = GetLSF<int32_t>(ctxbuf, 4);

      txtorig = ctxbuf + (entries * 4);

      for (int i = 0; i < entries; i++, ctxbuf += 4)
        svl->valuelabel[GetLSF<uint32_t>(ctxbuf, 4)].assign((char *)(&txtorig[offsets[i]]), strlen(&txtorig[offsets[i]]));

      ctxbuf += txtlen;
      break;

    case R117:
      totalSize = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;
      sz = strlen((char *)ctxbuf);
      svl->labname.assign(&ctxbuf[0], sz);
      ctxbuf += 36;
      entries = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;
      txtlen = GetLSF<uint32_t>(ctxbuf, 4);
      ctxbuf += 4;

      offsets = new int[entries];

      for (int i = 0; i < entries; ctxbuf += 4, i++)
        offsets[i] = GetLSF<int32_t>(ctxbuf, 4);

      txtorig = ctxbuf + (entries * 4);

      for (int i = 0; i < entries; i++, ctxbuf += 4)
        svl->valuelabel[GetLSF<uint32_t>(ctxbuf, 4)].assign((char *)(&txtorig[offsets[i]]), strlen(&txtorig[offsets[i]]));

      ctxbuf += txtlen;
      break;

    case R115:
    case R114:
    case R113:
    case R112:
      break;
    }
  }
  else
  {
  }

  if (ctxbuf[0] == '<' && ctxbuf[1] == '/' && ctxbuf[2] == 'l' && ctxbuf[6] == '<' && ctxbuf[8] != 'v')
  {
    setHasMoreLabels(true);
    ctx.advance();
    ctx.advance();
  }
  else
  {
    setHasMoreLabels(false);
    ctx.advance();
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xa876
movq %rax, %r15
pushq $0x50
popq %rdi
callq 0x7310
movq %rax, -0x30(%rbp)
movq %rax, %rdi
callq 0xa43c
cmpl $0x0, 0x64(%rbx)
jne 0xbc4e
cmpl $0x2, 0x60(%rbx)
jae 0xbad0
movq %r14, -0x48(%rbp)
movq %rbx, -0x50(%rbp)
pushq $0x4
popq %r12
movq %r15, %rdi
movl %r12d, %esi
callq 0xbd9e
leaq 0x4(%r15), %rbx
movq %rbx, %rdi
callq 0x7140
movslq %eax, %rdx
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x7420
leaq 0x88(%r15), %rdi
movl %r12d, %esi
callq 0xbd9e
movl %eax, %ebx
leaq 0x8c(%r15), %rdi
movl %r12d, %esi
callq 0xbd9e
movl %eax, -0x34(%rbp)
addq $0x90, %r15
movl %ebx, %eax
shlq $0x2, %rax
xorl %r13d, %r13d
testl %ebx, %ebx
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
movl $0x0, %r14d
cmovgl %ebx, %r14d
callq 0x7030
movq %rax, -0x40(%rbp)
cmpq %r13, %r14
je 0xbb74
movq %r15, %rdi
movl %r12d, %esi
callq 0xc1fc
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%r13,4)
addq $0x4, %r15
incq %r13
jmp 0xbaab
jne 0xbc4e
movq %r14, -0x48(%rbp)
movq %rbx, -0x50(%rbp)
pushq $0x4
popq %r12
movq %r15, %rdi
movl %r12d, %esi
callq 0xbd9e
leaq 0x4(%r15), %rbx
movq %rbx, %rdi
callq 0x7140
movslq %eax, %rdx
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x7420
leaq 0x28(%r15), %rdi
movl %r12d, %esi
callq 0xbd9e
movl %eax, %r13d
leaq 0x2c(%r15), %rdi
movl %r12d, %esi
callq 0xbd9e
movl %eax, -0x34(%rbp)
addq $0x30, %r15
movl %r13d, %eax
shlq $0x2, %rax
xorl %ebx, %ebx
testl %r13d, %r13d
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
movl $0x0, %r14d
cmovgl %r13d, %r14d
callq 0x7030
movq %rax, -0x40(%rbp)
cmpq %rbx, %r14
je 0xbbdb
movq %r15, %rdi
movl %r12d, %esi
callq 0xc1fc
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%rbx,4)
addq $0x4, %r15
incq %rbx
jmp 0xbb50
shll $0x2, %ebx
movslq %ebx, %rax
addq $0x20, -0x30(%rbp)
addq %r15, %rax
movq %rax, -0x58(%rbp)
xorl %r13d, %r13d
cmpq %r13, %r14
je 0xbc3f
movq %r15, %rdi
pushq $0x4
popq %rsi
callq 0xbd9e
movl %eax, -0x60(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xc224
movq %rax, %r12
movq -0x40(%rbp), %rax
movslq (%rax,%r13,4), %rbx
addq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x7140
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7420
incq %r13
addq $0x4, %r15
jmp 0xbb89
shll $0x2, %r13d
movslq %r13d, %rax
addq $0x20, -0x30(%rbp)
addq %r15, %rax
movq %rax, -0x58(%rbp)
xorl %r13d, %r13d
cmpq %r13, %r14
je 0xbc3f
movq %r15, %rdi
pushq $0x4
popq %rsi
callq 0xbd9e
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0xc224
movq %rax, %r12
movq -0x40(%rbp), %rax
movslq (%rax,%r13,4), %rbx
addq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x7140
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7420
incq %r13
addq $0x4, %r15
jmp 0xbbf1
movslq -0x34(%rbp), %rax
addq %rax, %r15
movq -0x50(%rbp), %rbx
movq -0x48(%rbp), %r14
cmpb $0x3c, (%r15)
jne 0xbc70
cmpb $0x2f, 0x1(%r15)
jne 0xbc70
cmpb $0x6c, 0x2(%r15)
jne 0xbc70
cmpb $0x3c, 0x6(%r15)
jne 0xbc70
cmpb $0x76, 0x8(%r15)
jne 0xbc8e
movb $0x0, 0x8(%r14)
movq %rbx, %rdi
callq 0xa876
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x8(%r14)
movq %rbx, %rdi
callq 0xa876
jmp 0xbc75
movq %rax, %rbx
pushq $0x50
popq %rsi
movq -0x30(%rbp), %rdi
callq 0x7320
movq %rbx, %rdi
callq 0x75b0