// File: 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
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0xc8(%rbp)
movb %sil, %al
movq %rdi, %rsi
movq %rsi, -0xc0(%rbp)
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x319a0
testb $0x1, %al
jne 0x2b055
movb -0x11(%rbp), %dl
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movslq %eax, %rcx
leaq 0xcb841(%rip), %rax     # 0xf67e0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x319e0
testb $0x1, %al
jne 0x2afbd
jmp 0x2afc7
xorl %eax, %eax
movl %eax, -0xd4(%rbp)
jmp 0x2afe6
movsd -0x10(%rbp), %xmm1
xorps %xmm0, %xmm0
movl $0x2, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
movl %eax, -0xd4(%rbp)
movq -0xd0(%rbp), %rax
movl -0xd4(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe8(%rbp)
leaq -0x1d(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x9d30
movq -0xc8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
callq 0x9a30
jmp 0x2b02d
leaq -0x1d(%rbp), %rdi
callq 0x97e0
jmp 0x2b386
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1d(%rbp), %rdi
callq 0x97e0
jmp 0x2b396
movb $0x0, -0x2d(%rbp)
leaq -0x2e(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x9d30
movq -0xc8(%rbp), %rdi
movq -0xf0(%rbp), %rcx
movl $0x24, %esi
xorl %edx, %edx
callq 0x9500
jmp 0x2b085
leaq -0x2e(%rbp), %rdi
callq 0x97e0
jmp 0x2b090
movq -0xc8(%rbp), %rdi
callq 0x9660
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x31a00
movq -0xc8(%rbp), %rdi
movq %rax, -0x100(%rbp)
callq 0x9540
movq %rax, -0xf8(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x2b0d9
leaq 0x91c4f(%rip), %rax     # 0xbcd1f
movq %rax, -0x108(%rbp)
jmp 0x2b0e9
leaq 0x91c44(%rip), %rax     # 0xbcd24
movq %rax, -0x108(%rbp)
jmp 0x2b0e9
movq -0xf8(%rbp), %rsi
movq -0x100(%rbp), %rdi
movq -0x108(%rbp), %rdx
movl -0x18(%rbp), %ecx
movsd -0x10(%rbp), %xmm0
movb $0x1, %al
callq 0x9bc0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x2b118
jmp 0x2b151
leaq 0x91c0a(%rip), %rdi     # 0xbcd29
leaq 0x918cd(%rip), %rsi     # 0xbc9f3
movl $0x96, %edx
leaq 0x91c00(%rip), %rcx     # 0xbcd32
callq 0x94e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x97e0
jmp 0x2b396
movq -0xc8(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x110(%rbp)
callq 0x9540
movq %rax, %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
jb 0x2b1b6
movq -0xc8(%rbp), %rdi
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x9a40
jmp 0x2b194
jmp 0x2b08e
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x9480
jmp 0x2b396
movq -0xc8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x9a40
jmp 0x2b1c8
jmp 0x2b1ca
movq -0xc8(%rbp), %rdi
callq 0x9660
movq -0xc8(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x9420
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x31a20
movq %rax, -0x118(%rbp)
jmp 0x2b200
movq -0x118(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x185e0
movq -0xc8(%rbp), %rdi
callq 0x9420
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x185e0
movq -0xc8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x9190
movq %rax, -0x120(%rbp)
jmp 0x2b252
movq -0x120(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x2b321
movq -0xc8(%rbp), %rdi
callq 0x9660
movq -0xc8(%rbp), %rdi
movq %rax, -0x98(%rbp)
callq 0x9420
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x31a80
movq %rax, -0x128(%rbp)
jmp 0x2b2a9
movq -0x128(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x185e0
movq -0xc8(%rbp), %rdi
callq 0x9420
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x185e0
movq -0xc8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0xa8(%rbp), %rdx
callq 0x9190
movq %rax, -0x130(%rbp)
jmp 0x2b313
movq -0x130(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xc8(%rbp), %rdi
movl $0x2e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x99c0
cmpq $-0x1, %rax
jne 0x2b36e
movq -0xc8(%rbp), %rdi
movl $0x65, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x99c0
cmpq $-0x1, %rax
jne 0x2b36e
movq -0xc8(%rbp), %rdi
leaq 0x9e84c(%rip), %rsi     # 0xc9bb1
callq 0x9740
jmp 0x2b36c
jmp 0x2b36e
movb $0x1, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0x2b384
movq -0xc8(%rbp), %rdi
callq 0x9480
jmp 0x2b386
movq -0xc0(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x9d20
nop