// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq %rdi, %rbx
movq %xmm0, %rax
btrq $0x3f, %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
cmpq %rcx, %rax
jl 0x18807
xorb $0x1, %sil
movzbl %sil, %eax
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
setbe %cl
incl %ecx
xorl %edx, %edx
ucomisd %xmm0, %xmm0
leaq (%rax,%rax,2), %rax
leaq 0x74bc5(%rip), %rsi     # 0x8d3b0
leaq (%rsi,%rax,8), %rax
cmovnpl %ecx, %edx
movq (%rax,%rdx,8), %rsi
leaq -0x29(%rbp), %rdx
movq %rbx, %rdi
callq 0x8260
jmp 0x18948
movl %edx, %r15d
leaq 0x10(%rbx), %rax
movq %rax, -0x40(%rbp)
movq %rax, (%rbx)
movl $0x24, %esi
movq %rbx, %rdi
xorl %edx, %edx
movq %xmm0, -0x38(%rbp)
callq 0x8750
movsd -0x38(%rbp), %xmm0
movl %r14d, -0x30(%rbp)
testl %r14d, %r14d
leaq 0x51dd1(%rip), %rax     # 0x6a60d
leaq 0x51dcf(%rip), %r12     # 0x6a612
cmoveq %rax, %r12
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %r12, %rdx
movl %r15d, %ecx
movb $0x1, %al
callq 0x8a10
testl %eax, %eax
js 0x1895a
movl %eax, %r13d
movq 0x8(%rbx), %r14
cmpq %r14, %r13
movq %r13, %rsi
sbbq $-0x1, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x81e0
cmpq %r13, %r14
movsd -0x38(%rbp), %xmm0
jbe 0x18847
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
je 0x188a9
movl -0x30(%rbp), %edx
cmpb $0x2c, (%rax)
jne 0x1889f
movb $0x2e, (%rax)
incq %rax
decq %rcx
jne 0x18897
jmp 0x188ac
movl -0x30(%rbp), %edx
movq %rax, %rcx
subq (%rbx), %rcx
movq %rcx, 0x8(%rbx)
movb $0x0, (%rax)
cmpl $0x1, %edx
jne 0x1890f
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rdx
testq %rcx, %rcx
je 0x18902
decq %rcx
movq %rdx, %rsi
cmpb $0x30, -0x1(%rdx)
jne 0x188fa
testq %rcx, %rcx
je 0x188ff
movb -0x2(%rsi), %dil
je 0x188f2
leaq -0x1(%rsi), %rdx
decq %rcx
cmpb $0x2e, %dil
jne 0x188d1
cmpb $0x2e, %dil
cmovneq %rax, %rsi
movq %rsi, %rdx
jmp 0x18902
movq %rax, %rdx
movq %rdx, %rcx
subq %rax, %rcx
movq %rcx, 0x8(%rbx)
movb $0x0, (%rdx)
movq %rbx, %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x8840
cmpq $-0x1, %rax
jne 0x18948
movq %rbx, %rdi
movl $0x65, %esi
xorl %edx, %edx
callq 0x8840
cmpq $-0x1, %rax
jne 0x18948
leaq 0x5e511(%rip), %rsi     # 0x76e51
movq %rbx, %rdi
callq 0x8c20
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x51cb6(%rip), %rdi     # 0x6a617
leaq 0x51979(%rip), %rsi     # 0x6a2e1
leaq 0x51cb1(%rip), %rcx     # 0x6a620
movl $0x96, %edx
callq 0x8420
jmp 0x1897b
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x40(%rbp), %rdi
je 0x1898c
callq 0x85d0
movq %r14, %rdi
callq 0x8b40