// File: tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::Reader::parse(char const*, char const*, Json::Value&, bool)
bool Reader::parse(const char* beginDoc,
                   const char* endDoc,
                   Value& root,
                   bool collectComments) {
  if (!features_.allowComments_) {
    collectComments = false;
  }

  begin_ = beginDoc;
  end_ = endDoc;
  collectComments_ = collectComments;
  current_ = begin_;
  lastValueEnd_ = 0;
  lastValue_ = 0;
  commentsBefore_ = "";
  errors_.clear();
  while (!nodes_.empty())
    nodes_.pop();
  nodes_.push(&root);

  stackDepth_g = 0;  // Yes, this is bad coding, but options are limited.
  bool successful = readValue();
  Token token;
  skipCommentTokens(token);
  if (collectComments_ && !commentsBefore_.empty())
    root.setComment(commentsBefore_, commentAfter);
  if (features_.strictRoot_) {
    if (!root.isArray() && !root.isObject()) {
      // Set error location to start of doc, ideally should be first token found
      // in doc
      token.type_ = tokenError;
      token.start_ = beginDoc;
      token.end_ = endDoc;
      addError(
          "A valid JSON document must be either an array or an object value.",
          token);
      return false;
    }
  }
  return successful;
}

// Assembly:
subq $0xa8, %rsp
movb %r8b, %al
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rcx, 0x80(%rsp)
andb $0x1, %al
movb %al, 0x7f(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
testb $0x1, 0x108(%rax)
jne 0xdfefb
movb $0x0, 0x7f(%rsp)
movq 0x10(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0xc0(%rdi)
movq 0x88(%rsp), %rax
movq %rax, 0xc8(%rdi)
movb 0x7f(%rsp), %al
andb $0x1, %al
movb %al, 0x10c(%rdi)
movq 0xc0(%rdi), %rax
movq %rax, 0xd0(%rdi)
movq $0x0, 0xd8(%rdi)
movq $0x0, 0xe0(%rdi)
addq $0xe8, %rdi
leaq 0x876a3(%rip), %rsi     # 0x1675ff
callq 0x129a0
movq 0x10(%rsp), %rdi
addq $0x50, %rdi
callq 0xf9280
movq 0x10(%rsp), %rdi
callq 0xf92c0
xorb $-0x1, %al
testb $0x1, %al
jne 0xdff81
jmp 0xdff8d
movq 0x10(%rsp), %rdi
callq 0xf92e0
jmp 0xdff6f
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rsi
callq 0xf92f0
movq 0x10(%rsp), %rdi
movl $0x0, 0xd4b9c(%rip)     # 0x1b4b54
callq 0xe01e0
movq 0x10(%rsp), %rdi
andb $0x1, %al
movb %al, 0x6f(%rsp)
leaq 0x50(%rsp), %rsi
callq 0xe09c0
movq 0x10(%rsp), %rax
testb $0x1, 0x10c(%rax)
je 0xe0013
movq 0x10(%rsp), %rdi
addq $0xe8, %rdi
callq 0x12ba0
testb $0x1, %al
jne 0xe0013
movq 0x10(%rsp), %rsi
movq 0x80(%rsp), %rdi
addq $0xe8, %rsi
movl $0x2, %edx
callq 0xe0a10
movq 0x10(%rsp), %rax
testb $0x1, 0x109(%rax)
je 0xe0106
movq 0x80(%rsp), %rdi
callq 0xe0a60
testb $0x1, %al
jne 0xe0104
movq 0x80(%rsp), %rdi
callq 0xe0a80
testb $0x1, %al
jne 0xe0104
movl $0xd, 0x50(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x2f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x12c30
movq 0x8(%rsp), %rdx
leaq 0x8a1dc(%rip), %rsi     # 0x16a268
leaq 0x30(%rsp), %rdi
callq 0x22830
jmp 0xe0098
movq 0x10(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq 0x30(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe0aa0
jmp 0xe00b2
leaq 0x30(%rsp), %rdi
callq 0x12430
leaq 0x2f(%rsp), %rdi
callq 0x12760
movb $0x0, 0xa7(%rsp)
jmp 0xe0113
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
jmp 0xe00f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x12430
leaq 0x2f(%rsp), %rdi
callq 0x12760
jmp 0xe0124
jmp 0xe0106
movb 0x6f(%rsp), %al
andb $0x1, %al
movb %al, 0xa7(%rsp)
movb 0xa7(%rsp), %al
andb $0x1, %al
addq $0xa8, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x12c20
nop