// File: Konano[P]UselessDatabase/./json.hpp
// Function: nlohmann::detail::dtoa_impl::grisu2(char*, int&, int&, nlohmann::detail::dtoa_impl::diyfp, nlohmann::detail::dtoa_impl::diyfp, nlohmann::detail::dtoa_impl::diyfp)
inline void grisu2(char* buf, int& len, int& decimal_exponent,
                   diyfp m_minus, diyfp v, diyfp m_plus)
{
    assert(m_plus.e == m_minus.e);
    assert(m_plus.e == v.e);

    //  --------(-----------------------+-----------------------)--------    (A)
    //          m-                      v                       m+
    //
    //  --------------------(-----------+-----------------------)--------    (B)
    //                      m-          v                       m+
    //
    // First scale v (and m- and m+) such that the exponent is in the range
    // [alpha, gamma].

    const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);

    const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k

    // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma]
    const diyfp w       = diyfp::mul(v,       c_minus_k);
    const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
    const diyfp w_plus  = diyfp::mul(m_plus,  c_minus_k);

    //  ----(---+---)---------------(---+---)---------------(---+---)----
    //          w-                      w                       w+
    //          = c*m-                  = c*v                   = c*m+
    //
    // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and
    // w+ are now off by a small amount.
    // In fact:
    //
    //      w - v * 10^k < 1 ulp
    //
    // To account for this inaccuracy, add resp. subtract 1 ulp.
    //
    //  --------+---[---------------(---+---)---------------]---+--------
    //          w-  M-                  w                   M+  w+
    //
    // Now any number in [M-, M+] (bounds included) will round to w when input,
    // regardless of how the input rounding algorithm breaks ties.
    //
    // And digit_gen generates the shortest possible such number in [M-, M+].
    // Note that this does not mean that Grisu2 always generates the shortest
    // possible number in the interval (m-, m+).
    const diyfp M_minus(w_minus.f + 1, w_minus.e);
    const diyfp M_plus (w_plus.f  - 1, w_plus.e );

    decimal_exponent = -cached.k; // = -(-k) = k

    grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq 0x20(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq 0x10(%rbp), %r9
movq %r9, -0x100(%rbp)
movq %rcx, -0x10(%rbp)
movl %r8d, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movl 0x8(%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x16a6f
jmp 0x16a8e
leaq 0x6884b(%rip), %rdi     # 0x7f2c1
leaq 0x680c4(%rip), %rsi     # 0x7eb41
movl $0x34a3, %edx           # imm = 0x34A3
leaq 0x6884e(%rip), %rcx     # 0x7f2d7
callq 0x6350
movq -0x100(%rbp), %rcx
movq -0x108(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x8(%rcx), %eax
jne 0x16aa6
jmp 0x16ac5
leaq 0x6887e(%rip), %rdi     # 0x7f32b
leaq 0x6808d(%rip), %rsi     # 0x7eb41
movl $0x34a4, %edx           # imm = 0x34A4
leaq 0x68817(%rip), %rcx     # 0x7f2d7
callq 0x6350
movq -0x108(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x16df0
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
leaq -0x48(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x16c90
movq -0x100(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x16fa0
movq -0x110(%rbp), %rsi
movl %edx, -0x60(%rbp)
movq %rax, -0x68(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x16fa0
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %rsi
movl %edx, -0x80(%rbp)
movq %rax, -0x88(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x16fa0
movl %edx, -0xa0(%rbp)
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0x78(%rbp), %rsi
addq $0x1, %rsi
movl -0x70(%rbp), %edx
leaq -0xb8(%rbp), %rdi
callq 0x16c90
movq -0x98(%rbp), %rsi
subq $0x1, %rsi
movl -0x90(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x16c90
xorl %ecx, %ecx
subl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0xb8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xd8(%rbp), %rcx
movl -0xd0(%rbp), %r8d
leaq -0xe8(%rbp), %r9
leaq -0xf8(%rbp), %rax
movq (%r9), %r10
movq %r10, (%rsp)
movq 0x8(%r9), %r9
movq %r9, 0x8(%rsp)
movq (%rax), %r9
movq %r9, 0x10(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x170d0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop