// File: tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::Reader::readValue()
bool Reader::readValue() {
  // This is a non-reentrant way to support a stackLimit. Terrible!
  // But this deprecated class has a security problem: Bad input can
  // cause a seg-fault. This seems like a fair, binary-compatible way
  // to prevent the problem.
  if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
  ++stackDepth_g;

  Token token;
  skipCommentTokens(token);
  bool successful = true;

  if (collectComments_ && !commentsBefore_.empty()) {
    currentValue().setComment(commentsBefore_, commentBefore);
    commentsBefore_ = "";
  }

  switch (token.type_) {
  case tokenObjectBegin:
    successful = readObject(token);
    currentValue().setOffsetLimit(current_ - begin_);
    break;
  case tokenArrayBegin:
    successful = readArray(token);
    currentValue().setOffsetLimit(current_ - begin_);
    break;
  case tokenNumber:
    successful = decodeNumber(token);
    break;
  case tokenString:
    successful = decodeString(token);
    break;
  case tokenTrue:
    {
    Value v(true);
    currentValue().swapPayload(v);
    currentValue().setOffsetStart(token.start_ - begin_);
    currentValue().setOffsetLimit(token.end_ - begin_);
    }
    break;
  case tokenFalse:
    {
    Value v(false);
    currentValue().swapPayload(v);
    currentValue().setOffsetStart(token.start_ - begin_);
    currentValue().setOffsetLimit(token.end_ - begin_);
    }
    break;
  case tokenNull:
    {
    Value v;
    currentValue().swapPayload(v);
    currentValue().setOffsetStart(token.start_ - begin_);
    currentValue().setOffsetLimit(token.end_ - begin_);
    }
    break;
  case tokenArraySeparator:
  case tokenObjectEnd:
  case tokenArrayEnd:
    if (features_.allowDroppedNullPlaceholders_) {
      // "Un-read" the current token and mark the current value as a null
      // token.
      current_--;
      Value v;
      currentValue().swapPayload(v);
      currentValue().setOffsetStart(current_ - begin_ - 1);
      currentValue().setOffsetLimit(current_ - begin_);
      break;
    } // Else, fall through...
  default:
    currentValue().setOffsetStart(token.start_ - begin_);
    currentValue().setOffsetLimit(token.end_ - begin_);
    return addError("Syntax error: value, object or array expected.", token);
  }

  if (collectComments_) {
    lastValueEnd_ = current_;
    lastValue_ = &currentValue();
  }

  --stackDepth_g;
  return successful;
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1a8(%rsp)
movq 0x1a8(%rsp), %rax
movq %rax, 0x80(%rsp)
cmpl $0x3e8, 0xd494b(%rip)   # imm = 0x3E8
jl 0xe02b0
leaq 0x187(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x12c30
movq 0x78(%rsp), %rdx
leaq 0x8a07d(%rip), %rsi     # 0x16a2aa
leaq 0x188(%rsp), %rdi
callq 0x22830
jmp 0xe023c
leaq 0x188(%rsp), %rdi
callq 0xe0b60
jmp 0xe024b
leaq 0x188(%rsp), %rdi
callq 0x12430
leaq 0x187(%rsp), %rdi
callq 0x12760
jmp 0xe02b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0xe029e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x12430
leaq 0x187(%rsp), %rdi
callq 0x12760
jmp 0xe09ae
movq 0x80(%rsp), %rdi
movl 0xd4896(%rip), %eax     # 0x1b4b54
addl $0x1, %eax
movl %eax, 0xd488d(%rip)     # 0x1b4b54
leaq 0x158(%rsp), %rsi
callq 0xe09c0
movq 0x80(%rsp), %rax
movb $0x1, 0x157(%rsp)
testb $0x1, 0x10c(%rax)
je 0xe0346
movq 0x80(%rsp), %rdi
addq $0xe8, %rdi
callq 0x12ba0
testb $0x1, %al
jne 0xe0346
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq 0x80(%rsp), %rsi
movq %rax, %rdi
addq $0xe8, %rsi
xorl %edx, %edx
callq 0xe0a10
movq 0x80(%rsp), %rdi
addq $0xe8, %rdi
leaq 0x872be(%rip), %rsi     # 0x1675ff
callq 0x129a0
movl 0x158(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x70(%rsp)
subl $0x9, %eax
ja 0xe081c
movq 0x70(%rsp), %rax
leaq 0x894b5(%rip), %rcx     # 0x169820
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x80(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xe0bf0
movq 0x80(%rsp), %rdi
andb $0x1, %al
movb %al, 0x157(%rsp)
callq 0xe0bd0
movq %rax, %rdi
movq 0x80(%rsp), %rax
movq 0xd0(%rax), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
jmp 0xe0940
movq 0x80(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xe13b0
movq 0x80(%rsp), %rdi
andb $0x1, %al
movb %al, 0x157(%rsp)
callq 0xe0bd0
movq %rax, %rdi
movq 0x80(%rsp), %rax
movq 0xd0(%rax), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
jmp 0xe0940
movq 0x80(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xe1730
andb $0x1, %al
movb %al, 0x157(%rsp)
jmp 0xe0940
movq 0x80(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xe1880
andb $0x1, %al
movb %al, 0x157(%rsp)
jmp 0xe0940
leaq 0x128(%rsp), %rdi
movl $0x1, %esi
callq 0xed1c0
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x68(%rsp)
jmp 0xe0482
movq 0x68(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0xe1a10
jmp 0xe0496
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x60(%rsp)
jmp 0xe04aa
movq 0x60(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x160(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1b00
jmp 0xe04d0
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x58(%rsp)
jmp 0xe04e4
movq 0x58(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x168(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
jmp 0xe050a
leaq 0x128(%rsp), %rdi
callq 0xed680
jmp 0xe0940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xed680
jmp 0xe09ae
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
callq 0xed1c0
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x50(%rsp)
jmp 0xe0565
movq 0x50(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xe1a10
jmp 0xe0579
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x48(%rsp)
jmp 0xe058d
movq 0x48(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x160(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1b00
jmp 0xe05b3
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x40(%rsp)
jmp 0xe05c7
movq 0x40(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x168(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
jmp 0xe05ed
leaq 0x100(%rsp), %rdi
callq 0xed680
jmp 0xe0940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xed680
jmp 0xe09ae
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0xecc20
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x38(%rsp)
jmp 0xe0648
movq 0x38(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xe1a10
jmp 0xe065c
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x30(%rsp)
jmp 0xe0670
movq 0x30(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x160(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1b00
jmp 0xe0696
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x28(%rsp)
jmp 0xe06aa
movq 0x28(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x168(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
jmp 0xe06d0
leaq 0xd8(%rsp), %rdi
callq 0xed680
jmp 0xe0940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xed680
jmp 0xe09ae
movq 0x80(%rsp), %rax
testb $0x1, 0x10a(%rax)
je 0xe081a
movq 0x80(%rsp), %rax
movq 0xd0(%rax), %rcx
decq %rcx
movq %rcx, 0xd0(%rax)
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
callq 0xecc20
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x20(%rsp)
jmp 0xe0759
movq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe1a10
jmp 0xe076d
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x18(%rsp)
jmp 0xe0781
movq 0x18(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0xc0(%rax), %rsi
movq 0xd0(%rax), %rax
notq %rsi
addq %rax, %rsi
callq 0xe1b00
jmp 0xe07a9
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, 0x10(%rsp)
jmp 0xe07bd
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %rcx
movq 0xc0(%rcx), %rax
movq 0xd0(%rcx), %rsi
subq %rax, %rsi
callq 0xe1390
jmp 0xe07e2
leaq 0xb0(%rsp), %rdi
callq 0xed680
jmp 0xe0940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xed680
jmp 0xe09ae
jmp 0xe081c
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, %rdi
movq 0x80(%rsp), %rax
movq 0x160(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1b00
movq 0x80(%rsp), %rdi
callq 0xe0bd0
movq %rax, %rdi
movq 0x80(%rsp), %rax
movq 0x168(%rsp), %rsi
movq 0xc0(%rax), %rax
subq %rax, %rsi
callq 0xe1390
leaq 0x8f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x12c30
movq 0x8(%rsp), %rdx
leaq 0x89a36(%rip), %rsi     # 0x16a2ce
leaq 0x90(%rsp), %rdi
callq 0x22830
jmp 0xe08a7
movq 0x80(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq 0x90(%rsp), %rsi
leaq 0x158(%rsp), %rdx
callq 0xe0aa0
movb %al, 0x7(%rsp)
jmp 0xe08ce
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x1b7(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x12430
leaq 0x8f(%rsp), %rdi
callq 0x12760
jmp 0xe099d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0xe0931
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x12430
leaq 0x8f(%rsp), %rdi
callq 0x12760
jmp 0xe09ae
movq 0x80(%rsp), %rax
testb $0x1, 0x10c(%rax)
je 0xe097e
movq 0x80(%rsp), %rdi
movq 0xd0(%rdi), %rax
movq %rax, 0xd8(%rdi)
callq 0xe0bd0
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0xe0(%rax)
movl 0xd41d0(%rip), %eax     # 0x1b4b54
addl $-0x1, %eax
movl %eax, 0xd41c7(%rip)     # 0x1b4b54
movb 0x157(%rsp), %al
andb $0x1, %al
movb %al, 0x1b7(%rsp)
movb 0x1b7(%rsp), %al
andb $0x1, %al
addq $0x1b8, %rsp            # imm = 0x1B8
retq
movq 0x178(%rsp), %rdi
callq 0x12c20
nopl (%rax,%rax)