// File: /workspace/github_cpp_makefile_star2_O3/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 0xb856
movq %rax, %r12
movl $0x50, %edi
callq 0x7330
movq %rax, -0x30(%rbp)
movq %rax, %rdi
callq 0xb3e8
cmpl $0x0, 0x64(%rbx)
jne 0xd3a6
cmpl $0x2, 0x60(%rbx)
jae 0xd240
movq %r14, -0x38(%rbp)
leaq 0x4(%r12), %r13
movq %r13, %rdi
callq 0x7160
movslq %eax, %r8
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rdx
xorl %r14d, %r14d
xorl %esi, %esi
movq %r13, %rcx
callq 0x74e0
leaq 0x88(%r12), %rax
xorl %r13d, %r13d
movzbl (%rax), %edx
movl %r14d, %ecx
shll %cl, %edx
orl %edx, %r13d
addq $0x8, %r14
incq %rax
cmpq $0x20, %r14
jne 0xd114
movq %rbx, -0x40(%rbp)
leaq 0x8c(%r12), %rax
xorl %ecx, %ecx
xorl %r14d, %r14d
movzbl (%rax), %edx
shll %cl, %edx
orl %edx, %r14d
addq $0x8, %rcx
incq %rax
cmpq $0x20, %rcx
jne 0xd13d
addq $0x90, %r12
movslq %r13d, %rbx
leaq (,%rbx,4), %rax
testl %ebx, %ebx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x7030
testl %ebx, %ebx
jle 0xd398
movl %r13d, %r9d
xorl %r8d, %r8d
movq %r12, %rdx
xorl %ecx, %ecx
xorl %esi, %esi
movzbl (%rdx), %edi
shll %cl, %edi
orl %edi, %esi
addq $0x8, %rcx
incq %rdx
cmpq $0x20, %rcx
jne 0xd18b
movl %esi, (%rax,%r8,4)
addq $0x4, %r12
incq %r8
cmpq %r9, %r8
jne 0xd184
testl %r13d, %r13d
jle 0xd398
movq %rax, -0x50(%rbp)
shll $0x2, %r13d
addq %r12, %r13
addq $0x20, -0x30(%rbp)
xorl %r15d, %r15d
movq %r9, -0x48(%rbp)
movq %r12, -0x58(%rbp)
xorl %ecx, %ecx
xorl %edx, %edx
movzbl (%r12), %esi
shll %cl, %esi
orl %esi, %edx
addq $0x8, %rcx
incq %r12
cmpq $0x20, %rcx
jne 0xd1d7
movl %edx, -0x60(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xd7e0
movq %rax, %rbx
movq -0x50(%rbp), %rax
movslq (%rax,%r15,4), %r12
addq %r13, %r12
movq %r12, %rdi
callq 0x7160
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %rax, %r8
callq 0x74e0
incq %r15
movq -0x58(%rbp), %r12
addq $0x4, %r12
movq -0x48(%rbp), %r9
cmpq %r9, %r15
jne 0xd1cf
jmp 0xd398
jne 0xd3a6
movq %r14, -0x38(%rbp)
leaq 0x4(%r12), %r13
movq %r13, %rdi
callq 0x7160
movslq %eax, %r8
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rdx
xorl %r14d, %r14d
xorl %esi, %esi
movq %r13, %rcx
callq 0x74e0
leaq 0x28(%r12), %rax
xorl %r13d, %r13d
movzbl (%rax), %edx
movl %r14d, %ecx
shll %cl, %edx
orl %edx, %r13d
addq $0x8, %r14
incq %rax
cmpq $0x20, %r14
jne 0xd277
movq %rbx, -0x40(%rbp)
leaq 0x2c(%r12), %rax
xorl %ecx, %ecx
xorl %r14d, %r14d
movzbl (%rax), %edx
shll %cl, %edx
orl %edx, %r14d
addq $0x8, %rcx
incq %rax
cmpq $0x20, %rcx
jne 0xd29d
addq $0x30, %r12
movslq %r13d, %rbx
leaq (,%rbx,4), %rax
testl %ebx, %ebx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x7030
testl %ebx, %ebx
jle 0xd398
movl %r13d, %r9d
xorl %r8d, %r8d
movq %r12, %rdx
xorl %ecx, %ecx
xorl %esi, %esi
movzbl (%rdx), %edi
shll %cl, %edi
orl %edi, %esi
addq $0x8, %rcx
incq %rdx
cmpq $0x20, %rcx
jne 0xd2e8
movl %esi, (%rax,%r8,4)
addq $0x4, %r12
incq %r8
cmpq %r9, %r8
jne 0xd2e1
testl %r13d, %r13d
jle 0xd398
movq %rax, -0x50(%rbp)
shll $0x2, %r13d
addq %r12, %r13
addq $0x20, -0x30(%rbp)
xorl %r15d, %r15d
movq %r9, -0x48(%rbp)
movq %r12, -0x58(%rbp)
xorl %ecx, %ecx
xorl %edx, %edx
movzbl (%r12), %esi
shll %cl, %esi
orl %esi, %edx
addq $0x8, %rcx
incq %r12
cmpq $0x20, %rcx
jne 0xd334
movl %edx, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0xd7e0
movq %rax, %rbx
movq -0x50(%rbp), %rax
movslq (%rax,%r15,4), %r12
addq %r13, %r12
movq %r12, %rdi
callq 0x7160
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %rax, %r8
callq 0x74e0
incq %r15
movq -0x58(%rbp), %r12
addq $0x4, %r12
movq -0x48(%rbp), %r9
cmpq %r9, %r15
jne 0xd32c
movslq %r14d, %rax
addq %rax, %r12
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpb $0x3c, (%r12)
jne 0xd3cd
cmpb $0x2f, 0x1(%r12)
jne 0xd3cd
cmpb $0x6c, 0x2(%r12)
jne 0xd3cd
cmpb $0x3c, 0x6(%r12)
jne 0xd3cd
cmpb $0x76, 0x8(%r12)
jne 0xd3eb
movb $0x0, 0x8(%r14)
movq %rbx, %rdi
callq 0xb856
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 0xb856
jmp 0xd3d2
movq %rax, %rbx
movl $0x50, %esi
movq -0x30(%rbp), %rdi
callq 0x7340
movq %rbx, %rdi
callq 0x75b0
nop