// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::OurReader::decodeNumber(Json::OurReader::Token&, Json::Value&)
bool OurReader::decodeNumber(Token& token, Value& decoded) {
  // Attempts to parse the number as an integer. If the number is
  // larger than the maximum supported value of an integer then
  // we decode the number as a double.
  Location current = token.start_;
  bool isNegative = *current == '-';
  if (isNegative)
    ++current;
  // TODO: Help the compiler do the div and mod at compile time or get rid of them.
  Value::LargestUInt maxIntegerValue =
      isNegative ? Value::LargestUInt(-Value::minLargestInt)
                 : Value::maxLargestUInt;
  Value::LargestUInt threshold = maxIntegerValue / 10;
  Value::LargestUInt value = 0;
  while (current < token.end_) {
    Char c = *current++;
    if (c < '0' || c > '9')
      return decodeDouble(token, decoded);
    Value::UInt digit(static_cast<Value::UInt>(c - '0'));
    if (value >= threshold) {
      // We've hit or exceeded the max value divided by 10 (rounded down). If
      // a) we've only just touched the limit, b) this is the last digit, and
      // c) it's small enough to fit in that rounding delta, we're okay.
      // Otherwise treat this number as a double to avoid overflow.
      if (value > threshold || current != token.end_ ||
          digit > maxIntegerValue % 10) {
        return decodeDouble(token, decoded);
      }
    }
    value = value * 10 + digit;
  }
  if (isNegative)
    decoded = -Value::LargestInt(value);
  else if (value <= Value::LargestUInt(Value::maxInt))
    decoded = Value::LargestInt(value);
  else
    decoded = value;
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r8
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movq 0x8(%rsi), %rax
movb (%rax), %cl
xorl %ebx, %ebx
xorl %r12d, %r12d
movb %cl, 0x7(%rsp)
cmpb $0x2d, %cl
sete %bl
setne %r12b
negq %r12
btsq $0x3f, %r12
addq %rax, %rbx
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
movq %r12, %rax
mulq %rcx
movq %rdx, %r13
shrq $0x3, %r13
leaq (,%r13,2), %rax
leaq (%rax,%rax,4), %rax
subq %rax, %r12
xorl %ebp, %ebp
movq %r8, %r15
movq 0x10(%r14), %rcx
cmpq %rcx, %rbx
jae 0x7e884
movzbl (%rbx), %edx
incq %rbx
leal -0x3a(%rdx), %esi
cmpb $-0xb, %sil
ja 0x7e854
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r8, %rdx
callq 0x7e9d6
movq %r15, %r8
xorl %ecx, %ecx
jmp 0x7e87b
addl $-0x30, %edx
movl %edx, %edx
cmpq %r13, %rbp
jb 0x7e86a
ja 0x7e83d
cmpq %rcx, %rbx
jne 0x7e83d
cmpq %rdx, %r12
jb 0x7e83d
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
leaq (%rdx,%rcx,2), %rbp
movb $0x1, %cl
testb %cl, %cl
jne 0x7e825
jmp 0x7e981
cmpb $0x2d, 0x7(%rsp)
jne 0x7e89d
movl $0xfffffe00, %edx       # imm = 0xFFFFFE00
leaq 0x60(%rsp), %rdi
andl 0x8(%rdi), %edx
negq %rbp
jmp 0x7e8b3
movl $0xfffffe00, %edx       # imm = 0xFFFFFE00
cmpq $0x7fffffff, %rbp       # imm = 0x7FFFFFFF
ja 0x7e8fa
leaq 0x38(%rsp), %rdi
andl 0x8(%rdi), %edx
leal 0x1(%rdx), %eax
movw %ax, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movq $0x0, 0x20(%rdi)
movq %rbp, (%rdi)
movzwl 0x8(%r8), %eax
movzbl %al, %ecx
movl %eax, %esi
andl $0xff00, %esi           # imm = 0xFF00
incl %esi
movw %si, 0x8(%r8)
orl %edx, %ecx
movw %cx, 0x8(%rdi)
movq (%r8), %rdx
movq %rbp, (%r8)
movq %rdx, (%rdi)
andl $0xfe01, %esi           # imm = 0xFE01
jmp 0x7e948
leaq 0x10(%rsp), %rdi
andl 0x8(%rdi), %edx
leal 0x2(%rdx), %eax
movw %ax, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movq $0x0, 0x20(%rdi)
movq %rbp, (%rdi)
movzwl 0x8(%r8), %eax
movzbl %al, %ecx
movl %eax, %esi
andl $0xff00, %esi           # imm = 0xFF00
orl $0x2, %esi
movw %si, 0x8(%r8)
orl %edx, %ecx
movw %cx, 0x8(%rdi)
movq (%r8), %rdx
movq %rbp, (%r8)
movq %rdx, (%rdi)
andl $0xfe02, %esi           # imm = 0xFE02
movw %si, 0x8(%r8)
andl $0x100, %eax            # imm = 0x100
orl %eax, %ecx
movw %cx, 0x8(%rdi)
movq 0x10(%r8), %rax
movq 0x10(%rdi), %rcx
movq %rcx, 0x10(%r8)
movq %rax, 0x10(%rdi)
movups 0x18(%rdi), %xmm0
movups 0x18(%r8), %xmm1
movups %xmm0, 0x18(%r8)
movups %xmm1, 0x18(%rdi)
callq 0x82500
movb $0x1, %al
andb $0x1, %al
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop