// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::Reader::decodeNumber(Json::Reader::Token&, Json::Value&)
bool Reader::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::maxLargestInt) + 1
                 : 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 && value == maxIntegerValue)
    decoded = Value::minLargestInt;
  else 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 %rbx
subq $0xa8, %rsp
movq %rdx, %rcx
movq 0x8(%rsi), %r10
movq 0x10(%rsi), %r11
movb (%r10), %r9b
xorl %ebx, %ebx
xorl %r8d, %r8d
cmpb $0x2d, %r9b
sete %bl
setne %r8b
negq %r8
btsq $0x3f, %r8
pushq $0xa
popq %r14
movq %r8, %rax
xorl %edx, %edx
divq %r14
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
addq %r10, %rbx
xorl %r10d, %r10d
cmpq %r11, %rbx
jae 0x7009d
movzbl (%rbx), %r15d
leal -0x3a(%r15), %ebp
cmpb $-0xb, %bpl
jbe 0x70088
incq %rbx
addl $-0x30, %r15d
movl %r15d, %r15d
cmpq %rax, %r10
jb 0x7007f
ja 0x70088
cmpq %r11, %rbx
jne 0x70088
cmpq %r15, %rdx
jb 0x70088
imulq $0xa, %r10, %r10
addq %r15, %r10
jmp 0x70051
movq %rcx, %rdx
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x702fc
cmpb $0x2d, %r9b
jne 0x700c7
cmpq %r8, %r10
jne 0x700c7
leaq 0x80(%rsp), %rbx
movw $0x1, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
andq $0x0, 0x20(%rbx)
movq %r14, (%rbx)
jmp 0x70107
cmpb $0x2d, %r9b
jne 0x700d7
negq %r10
leaq 0x58(%rsp), %rbx
jmp 0x700e5
cmpq $0x7fffffff, %r10       # imm = 0x7FFFFFFF
ja 0x700ed
leaq 0x30(%rsp), %rbx
movw $0x1, 0x8(%rbx)
jmp 0x700f8
leaq 0x8(%rsp), %rbx
movw $0x2, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
andq $0x0, 0x20(%rbx)
movq %r10, (%rbx)
movq %rcx, %rdi
movq %rbx, %rsi
callq 0x74c68
movq %rbx, %rdi
callq 0x74cb0
movb $0x1, %al
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq