// File: Falldog[P]dcinja/src/include/nlohmann/json.hpp
// Function: nlohmann::detail::dtoa_impl::format_buffer(char*, int, int, int, int)
inline char* format_buffer(char* buf, int len, int decimal_exponent,
                           int min_exp, int max_exp)
{
    JSON_ASSERT(min_exp < 0);
    JSON_ASSERT(max_exp > 0);

    const int k = len;
    const int n = len + decimal_exponent;

    // v = buf * 10^(n-k)
    // k is the length of the buffer (number of decimal digits)
    // n is the position of the decimal point relative to the start of the buffer.

    if (k <= n && n <= max_exp)
    {
        // digits[000]
        // len <= max_exp + 2

        std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
        // Make it look like a floating-point number (#362, #378)
        buf[n + 0] = '.';
        buf[n + 1] = '0';
        return buf + (static_cast<size_t>(n) + 2);
    }

    if (0 < n && n <= max_exp)
    {
        // dig.its
        // len <= max_digits10 + 1

        JSON_ASSERT(k > n);

        std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
        buf[n] = '.';
        return buf + (static_cast<size_t>(k) + 1U);
    }

    if (min_exp < n && n <= 0)
    {
        // 0.[000]digits
        // len <= 2 + (-min_exp - 1) + max_digits10

        std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
        buf[0] = '0';
        buf[1] = '.';
        std::memset(buf + 2, '0', static_cast<size_t>(-n));
        return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
    }

    if (k == 1)
    {
        // dE+123
        // len <= 1 + 5

        buf += 1;
    }
    else
    {
        // d.igitsE+123
        // len <= max_digits10 + 1 + 5

        std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
        buf[1] = '.';
        buf += 1 + static_cast<size_t>(k);
    }

    *buf++ = 'e';
    return append_exponent(buf, n - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x855d1
jmp 0x855f0
leaq 0x42bc7(%rip), %rdi     # 0xc819f
leaq 0x3d38e(%rip), %rsi     # 0xc296d
movl $0x3bd5, %edx           # imm = 0x3BD5
leaq 0x42bc0(%rip), %rcx     # 0xc81ab
callq 0xb410
cmpl $0x0, -0x20(%rbp)
jle 0x855f8
jmp 0x85617
leaq 0x42bf9(%rip), %rdi     # 0xc81f8
leaq 0x3d367(%rip), %rsi     # 0xc296d
movl $0x3bd6, %edx           # imm = 0x3BD6
leaq 0x42b99(%rip), %rcx     # 0xc81ab
callq 0xb410
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0x85690
movl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x85690
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rax
addq %rax, %rdi
movslq -0x28(%rbp), %rdx
movslq -0x24(%rbp), %rax
subq %rax, %rdx
movl $0x30, %esi
callq 0xb310
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movb $0x2e, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x30, (%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
addq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x857fa
xorl %eax, %eax
cmpl -0x28(%rbp), %eax
jge 0x85716
movl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x85716
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x856a9
jmp 0x856c8
leaq 0x42b54(%rip), %rdi     # 0xc8204
leaq 0x3d2b6(%rip), %rsi     # 0xc296d
movl $0x3bf0, %edx           # imm = 0x3BF0
leaq 0x42ae8(%rip), %rcx     # 0xc81ab
callq 0xb410
movq -0x10(%rbp), %rdi
movslq -0x28(%rbp), %rax
addq $0x1, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movslq -0x28(%rbp), %rax
addq %rax, %rsi
movslq -0x24(%rbp), %rdx
movslq -0x28(%rbp), %rax
subq %rax, %rdx
callq 0xb970
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x2e, (%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x857fa
movl -0x1c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x8578c
cmpl $0x0, -0x28(%rbp)
jg 0x8578c
movq -0x10(%rbp), %rdi
xorl %eax, %eax
subl -0x28(%rbp), %eax
cltq
addq $0x2, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0xb970
movq -0x10(%rbp), %rax
movb $0x30, (%rax)
movq -0x10(%rbp), %rax
movb $0x2e, 0x1(%rax)
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
xorl %eax, %eax
subl -0x28(%rbp), %eax
movslq %eax, %rdx
movl $0x30, %esi
callq 0xb310
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
subl -0x28(%rbp), %ecx
movslq %ecx, %rcx
addq $0x2, %rcx
movslq -0x24(%rbp), %rdx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x857fa
cmpl $0x1, -0x24(%rbp)
jne 0x857a0
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x857d5
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
movq -0x10(%rbp), %rsi
addq $0x1, %rsi
movslq -0x24(%rbp), %rdx
subq $0x1, %rdx
callq 0xb970
movq -0x10(%rbp), %rax
movb $0x2e, 0x1(%rax)
movslq -0x24(%rbp), %rax
addq $0x1, %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x65, (%rax)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
subl $0x1, %esi
callq 0x86980
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop