// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Json/json_writer.cpp
// Function: Json::(anonymous namespace)::valueToString[abi:cxx11](double, bool, unsigned int, Json::PrecisionType)
JSONCPP_STRING valueToString(double value,
                             bool useSpecialFloats,
                             unsigned int precision,
                             PrecisionType precisionType) {
  // Print into the buffer. We need not request the alternative representation
  // that always has a decimal point because JSON doesn't distinguish the
  // concepts of reals and integers.
  if (!isfinite(value)) {
    static const char* const reps[2][3] = { { "NaN", "-Infinity", "Infinity" },
                                            { "null", "-1e+9999", "1e+9999" } };
    return reps[useSpecialFloats ? 0 : 1]
               [isnan(value) ? 0 : (value < 0) ? 1 : 2];
  }

  JSONCPP_STRING buffer(size_t(36), '\0');
  while (true) {
    int len = snprintf(
        &*buffer.begin(), buffer.size(),
        (precisionType == PrecisionType::significantDigits) ? "%.*g" : "%.*f",
        precision, value);
    assert(len >= 0);
    size_t wouldPrint = static_cast<size_t>(len);
    if (wouldPrint >= buffer.size()) {
      buffer.resize(wouldPrint + 1);
      continue;
    }
    buffer.resize(wouldPrint);
    break;
  }

  buffer.erase(fixNumericLocale(buffer.begin(), buffer.end()), buffer.end());

  // strip the zero padding from the right
  if (precisionType == PrecisionType::decimalPlaces) {
    buffer.erase(fixZerosInTheEnd(buffer.begin(), buffer.end()), buffer.end());
  }

  // try to ensure we preserve the fact that this was given to us as a double on
  // input
  if (buffer.find('.') == buffer.npos && buffer.find('e') == buffer.npos) {
    buffer += ".0";
  }
  return buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %r14d
movq %rdi, %rbx
movq %xmm0, %rax
btrq $0x3f, %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
cmpq %rcx, %rax
jl 0x16015
xorb $0x1, %sil
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
movzbl %sil, %ecx
incl %eax
imulq $0x18, %rcx, %rcx
leaq 0x6f55c(%rip), %rdx     # 0x85550
addq %rcx, %rdx
xorl %ecx, %ecx
ucomisd %xmm0, %xmm0
cmovnpl %eax, %ecx
movq (%rdx,%rcx,8), %rsi
leaq -0x21(%rbp), %rdx
movq %rbx, %rdi
callq 0x8260
jmp 0x16101
movl %edx, %r15d
movq %xmm0, -0x30(%rbp)
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
pushq $0x24
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x8710
testl %r14d, %r14d
leaq 0x4a5c2(%rip), %rax     # 0x605fd
leaq 0x4a5c0(%rip), %r12     # 0x60602
cmoveq %rax, %r12
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %r12, %rdx
movl %r15d, %ecx
movq -0x30(%rbp), %xmm0
movb $0x1, %al
callq 0x8a00
testl %eax, %eax
js 0x16111
movl %eax, %esi
cmpq %rsi, 0x8(%rbx)
ja 0x1607c
incq %rsi
movq %rbx, %rdi
callq 0x8880
jmp 0x16046
movq %rbx, %rdi
callq 0x8880
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
addq %rdi, %rsi
callq 0x19418
movq (%rbx), %rdx
addq 0x8(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8150
cmpl $0x1, %r14d
jne 0x160cc
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
addq %rdi, %rsi
callq 0x19433
movq (%rbx), %rdx
addq 0x8(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8150
pushq $0x2e
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x8820
cmpq $-0x1, %rax
jne 0x16101
pushq $0x65
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x8820
cmpq $-0x1, %rax
jne 0x16101
leaq 0x56d1d(%rip), %rsi     # 0x6ce16
movq %rbx, %rdi
callq 0x8c20
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a4ef(%rip), %rdi     # 0x60607
leaq 0x4a1b2(%rip), %rsi     # 0x602d1
leaq 0x4a4ea(%rip), %rcx     # 0x60610
movl $0x96, %edx
callq 0x8420
jmp 0x16138
jmp 0x16138
jmp 0x16138
jmp 0x16138
movq %rax, %r14
movq %rbx, %rdi
callq 0x82c0
movq %r14, %rdi
callq 0x8b30