// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r8
movq %rsi, %r14
movq %rdi, %r12
movq 0x8(%rsi), %rcx
movb (%rcx), %al
xorl %ebx, %ebx
xorl %esi, %esi
movb %al, 0x7(%rsp)
cmpb $0x2d, %al
sete %bl
setne %sil
negq %rsi
btsq $0x3f, %rsi
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
movq %rsi, %rax
mulq %rdx
movq %rdx, %r13
addq %rcx, %rbx
shrq $0x3, %r13
leaq (,%r13,2), %rax
leaq (%rax,%rax,4), %rax
movq %rsi, 0x8(%rsp)
subq %rax, %rsi
movq %rsi, 0x10(%rsp)
xorl %ebp, %ebp
movq %r8, %r15
movq 0x10(%r14), %rcx
cmpq %rcx, %rbx
jae 0x7b228
movzbl (%rbx), %edx
incq %rbx
leal -0x3a(%rdx), %esi
cmpb $-0xb, %sil
ja 0x7b1f6
movq %r12, %rdi
movq %r14, %rsi
movq %r8, %rdx
callq 0x7b5d8
movq %r15, %r8
xorl %ecx, %ecx
jmp 0x7b21f
addl $-0x30, %edx
movl %edx, %edx
cmpq %r13, %rbp
jb 0x7b20e
ja 0x7b1e1
cmpq %rcx, %rbx
jne 0x7b1e1
cmpq %rdx, 0x10(%rsp)
jb 0x7b1e1
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
leaq (%rdx,%rcx,2), %rbp
movb $0x1, %cl
testb %cl, %cl
jne 0x7b1c9
jmp 0x7b338
movb 0x7(%rsp), %al
cmpb $0x2d, %al
jne 0x7b28f
cmpq 0x8(%rsp), %rbp
jne 0x7b28f
movl $0xfffffe00, %edx       # imm = 0xFFFFFE00
leaq 0x90(%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)
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
movq %r9, (%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 %r9, (%r8)
jmp 0x7b2f6
movl $0xfffffe00, %edx       # imm = 0xFFFFFE00
cmpb $0x2d, %al
jne 0x7b2a5
leaq 0x68(%rsp), %rdi
andl 0x8(%rdi), %edx
negq %rbp
jmp 0x7b2ba
cmpq $0x7fffffff, %rbp       # imm = 0x7FFFFFFF
ja 0x7b34c
leaq 0x40(%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
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 $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%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
jmp 0x7b2ff
nop