// File: /workspace/github_cpp_makefile_star2_O3/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 0x18197
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 0x753d5(%rip), %rsi     # 0x8d550
leaq (%rsi,%rax,8), %rax
cmovnpl %ecx, %edx
movq (%rax,%rdx,8), %rsi
leaq -0x29(%rbp), %rdx
movq %rbx, %rdi
callq 0x8260
jmp 0x182ca
movl %edx, %r15d
movq %xmm0, -0x38(%rbp)
leaq 0x10(%rbx), %r13
movq %r13, (%rbx)
movl $0x24, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x8740
testl %r14d, %r14d
leaq 0x5244e(%rip), %rax     # 0x6a60d
leaq 0x5244c(%rip), %r12     # 0x6a612
cmoveq %rax, %r12
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %r12, %rdx
movl %r15d, %ecx
movq -0x38(%rbp), %xmm0
movb $0x1, %al
callq 0x8a00
testl %eax, %eax
js 0x182d9
movl %eax, %esi
cmpq %rsi, 0x8(%rbx)
ja 0x18202
incq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x81e0
jmp 0x181ca
movq %rbx, %rdi
xorl %edx, %edx
callq 0x81e0
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
je 0x18235
leaq (%rax,%rdx), %rcx
xorl %esi, %esi
cmpb $0x2c, (%rax,%rsi)
jne 0x18228
movb $0x2e, (%rax,%rsi)
incq %rsi
cmpq %rsi, %rdx
jne 0x1821e
movq (%rbx), %rax
jmp 0x18238
movq %rax, %rcx
movq %rcx, %rdx
subq %rax, %rdx
movq %rdx, 0x8(%rbx)
movb $0x0, (%rcx)
cmpl $0x1, %r14d
jne 0x18291
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
leaq (%rax,%rsi), %rcx
testq %rsi, %rsi
je 0x18284
cmpb $0x30, -0x1(%rax,%rsi)
jne 0x18284
movq %rsi, %rdx
cmpq $0x1, %rsi
je 0x18281
decq %rcx
leaq -0x1(%rdx), %rsi
cmpb $0x2e, -0x2(%rax,%rdx)
jne 0x1825b
addq %rax, %rdx
movq %rdx, %rcx
jmp 0x18284
movq %rax, %rcx
movq %rcx, %rdx
subq %rax, %rdx
movq %rdx, 0x8(%rbx)
movb $0x0, (%rcx)
movq %rbx, %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x8830
cmpq $-0x1, %rax
jne 0x182ca
movq %rbx, %rdi
movl $0x65, %esi
xorl %edx, %edx
callq 0x8830
cmpq $-0x1, %rax
jne 0x182ca
leaq 0x5eb14(%rip), %rsi     # 0x76dd6
movq %rbx, %rdi
callq 0x8c10
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x52337(%rip), %rdi     # 0x6a617
leaq 0x51ffa(%rip), %rsi     # 0x6a2e1
leaq 0x52332(%rip), %rcx     # 0x6a620
movl $0x96, %edx
callq 0x8420
jmp 0x182fc
jmp 0x182fc
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x1830c
callq 0x85d0
movq %r14, %rdi
callq 0x8b30