// File: tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::OurReader::parse(char const*, char const*, Json::Value&, bool)
bool OurReader::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_ = 0;
  bool successful = readValue();
  Token token;
  skipCommentTokens(token);
  if (features_.failIfExtra_) {
    if (token.type_ != tokenError && token.type_ != tokenEndOfStream) {
      addError("Extra non-whitespace after JSON value.", token);
      return false;
    }
  }
  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 $0xd8, %rsp
movb %r8b, %al
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
andb $0x1, %al
movb %al, 0xaf(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x18(%rsp)
testb $0x1, 0x10c(%rax)
jne 0xe4e01
movb $0x0, 0xaf(%rsp)
movq 0x18(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq %rax, 0xc0(%rdi)
movq 0xb8(%rsp), %rax
movq %rax, 0xc8(%rdi)
movb 0xaf(%rsp), %al
andb $0x1, %al
movb %al, 0x118(%rdi)
movq 0xc0(%rdi), %rax
movq %rax, 0xd0(%rdi)
movq $0x0, 0xd8(%rdi)
movq $0x0, 0xe0(%rdi)
addq $0xe8, %rdi
leaq 0x8279a(%rip), %rsi     # 0x1675ff
callq 0x129a0
movq 0x18(%rsp), %rdi
addq $0x50, %rdi
callq 0xf9870
movq 0x18(%rsp), %rdi
callq 0xf92c0
xorb $-0x1, %al
testb $0x1, %al
jne 0xe4e8a
jmp 0xe4e96
movq 0x18(%rsp), %rdi
callq 0xf92e0
jmp 0xe4e78
movq 0x18(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0xa0(%rsp), %rsi
callq 0xf92f0
movq 0x18(%rsp), %rdi
movl $0x0, 0x108(%rdi)
callq 0xe5120
movq 0x18(%rsp), %rdi
andb $0x1, %al
movb %al, 0x9f(%rsp)
leaq 0x80(%rsp), %rsi
callq 0xe5c00
movq 0x18(%rsp), %rax
testb $0x1, 0x111(%rax)
je 0xe4fb3
cmpl $0x10, 0x80(%rsp)
je 0xe4fb1
cmpl $0x0, 0x80(%rsp)
je 0xe4fb1
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x12c30
movq 0x10(%rsp), %rdx
leaq 0x855f3(%rip), %rsi     # 0x16a523
leaq 0x60(%rsp), %rdi
callq 0x22830
jmp 0xe4f3c
movq 0x18(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0xe5c50
jmp 0xe4f59
leaq 0x60(%rsp), %rdi
callq 0x12430
leaq 0x5f(%rsp), %rdi
callq 0x12760
movb $0x0, 0xd7(%rsp)
jmp 0xe5103
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0xe4fa2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x12430
leaq 0x5f(%rsp), %rdi
callq 0x12760
jmp 0xe5114
jmp 0xe4fb3
movq 0x18(%rsp), %rax
testb $0x1, 0x118(%rax)
je 0xe4ff4
movq 0x18(%rsp), %rdi
addq $0xe8, %rdi
callq 0x12ba0
testb $0x1, %al
jne 0xe4ff4
movq 0x18(%rsp), %rsi
movq 0xb0(%rsp), %rdi
addq $0xe8, %rsi
movl $0x2, %edx
callq 0xe0a10
movq 0x18(%rsp), %rax
testb $0x1, 0x10d(%rax)
je 0xe50f3
movq 0xb0(%rsp), %rdi
callq 0xe0a60
testb $0x1, %al
jne 0xe50f1
movq 0xb0(%rsp), %rdi
callq 0xe0a80
testb $0x1, %al
jne 0xe50f1
movl $0x10, 0x80(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x27(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x12c30
movq 0x8(%rsp), %rdx
leaq 0x851f2(%rip), %rsi     # 0x16a268
leaq 0x28(%rsp), %rdi
callq 0x22830
jmp 0xe5082
movq 0x18(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq 0x28(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0xe5c50
jmp 0xe509f
leaq 0x28(%rsp), %rdi
callq 0x12430
leaq 0x27(%rsp), %rdi
callq 0x12760
movb $0x0, 0xd7(%rsp)
jmp 0xe5103
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0xe50e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x12430
leaq 0x27(%rsp), %rdi
callq 0x12760
jmp 0xe5114
jmp 0xe50f3
movb 0x9f(%rsp), %al
andb $0x1, %al
movb %al, 0xd7(%rsp)
movb 0xd7(%rsp), %al
andb $0x1, %al
addq $0xd8, %rsp
retq
movq 0x50(%rsp), %rdi
callq 0x12c20
nop