// File: /workspace/github_cpp_makefile_star2_O3/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), %rax
movq 0x10(%rsi), %r10
movb (%rax), %r9b
xorl %r11d, %r11d
xorl %r8d, %r8d
cmpb $0x2d, %r9b
sete %r11b
setne %r8b
negq %r8
btsq $0x3f, %r8
addq %rax, %r11
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
movq %r8, %rax
mulq %rdx
cmpq %r10, %r11
jae 0x79e42
movabsq $-0x8000000000000000, %rbx # imm = 0x8000000000000000
shrq $0x3, %rdx
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
movq %r8, %r14
subq %rax, %r14
xorl %eax, %eax
movzbl (%r11), %r15d
leal -0x3a(%r15), %ebp
cmpb $-0xb, %bpl
jbe 0x79e5e
incq %r11
addl $-0x30, %r15d
movl %r15d, %r15d
cmpq %rdx, %rax
jb 0x79dfc
ja 0x79e5e
cmpq %r10, %r11
jne 0x79e5e
cmpq %r15, %r14
jb 0x79e5e
leaq (%rax,%rax,4), %rax
leaq (%r15,%rax,2), %rax
cmpq %r10, %r11
jb 0x79dd3
cmpb $0x2d, %r9b
jne 0x79e73
cmpq %r8, %rax
jne 0x79e73
movzwl 0x8(%rcx), %eax
movq (%rcx), %rdx
movq %rbx, (%rcx)
leaq 0x80(%rsp), %rdi
movq %rdx, (%rdi)
movl %eax, %edx
andl $0xfe00, %edx           # imm = 0xFE00
incl %edx
movw %dx, 0x8(%rcx)
andl $0x1ff, %eax            # imm = 0x1FF
movw %ax, 0x8(%rdi)
jmp 0x79eaa
xorl %eax, %eax
cmpb $0x2d, %r9b
jne 0x79e81
negq %rax
movzwl 0x8(%rcx), %edx
movq (%rcx), %rsi
movq %rax, (%rcx)
leaq 0x58(%rsp), %rdi
jmp 0x79e90
movq %rcx, %rdx
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7a134
cmpb $0x2d, %r9b
je 0x79e4a
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0x79ede
movzwl 0x8(%rcx), %edx
movq (%rcx), %rsi
movq %rax, (%rcx)
leaq 0x30(%rsp), %rdi
movq %rsi, (%rdi)
movl %edx, %eax
andl $0xfe00, %eax           # imm = 0xFE00
incl %eax
movw %ax, 0x8(%rcx)
andl $0x1ff, %edx            # imm = 0x1FF
movw %dx, 0x8(%rdi)
movq 0x10(%rcx), %rax
movq $0x0, 0x10(%rcx)
movq %rax, 0x10(%rdi)
movups 0x18(%rcx), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, 0x18(%rcx)
movups %xmm0, 0x18(%rdi)
callq 0x80736
movb $0x1, %al
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x8(%rcx), %edx
movq (%rcx), %rsi
movq %rax, (%rcx)
leaq 0x8(%rsp), %rdi
movq %rsi, (%rdi)
movl %edx, %eax
andl $0xfe00, %eax           # imm = 0xFE00
orl $0x2, %eax
jmp 0x79e9c