// File: Falldog[P]dcinja/src/include/nlohmann/json.hpp
// Function: nlohmann::detail::dtoa_impl::grisu2_round(char*, int, unsigned long, unsigned long, unsigned long, unsigned long)
inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
                         std::uint64_t rest, std::uint64_t ten_k)
{
    JSON_ASSERT(len >= 1);
    JSON_ASSERT(dist <= delta);
    JSON_ASSERT(rest <= delta);
    JSON_ASSERT(ten_k > 0);

    //               <--------------------------- delta ---->
    //                                  <---- dist --------->
    // --------------[------------------+-------------------]--------------
    //               M-                 w                   M+
    //
    //                                  ten_k
    //                                <------>
    //                                       <---- rest ---->
    // --------------[------------------+----+--------------]--------------
    //                                  w    V
    //                                       = buf * 10^k
    //
    // ten_k represents a unit-in-the-last-place in the decimal representation
    // stored in buf.
    // Decrement buf by ten_k while this takes buf closer to w.

    // The tests are written in this order to avoid overflow in unsigned
    // integer arithmetic.

    while (rest < dist
            && delta - rest >= ten_k
            && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
    {
        JSON_ASSERT(buf[len - 1] != '0');
        buf[len - 1]--;
        rest += ten_k;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpl $0x1, -0xc(%rbp)
jl 0x86817
jmp 0x86836
leaq 0x418c6(%rip), %rdi     # 0xc80e4
leaq 0x3c148(%rip), %rsi     # 0xc296d
movl $0x3a23, %edx           # imm = 0x3A23
leaq 0x418bc(%rip), %rcx     # 0xc80ed
callq 0xb410
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x86842
jmp 0x86861
leaq 0x4191c(%rip), %rdi     # 0xc8165
leaq 0x3c11d(%rip), %rsi     # 0xc296d
movl $0x3a24, %edx           # imm = 0x3A24
leaq 0x41891(%rip), %rcx     # 0xc80ed
callq 0xb410
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x8686d
jmp 0x8688c
leaq 0x418ff(%rip), %rdi     # 0xc8173
leaq 0x3c0f2(%rip), %rsi     # 0xc296d
movl $0x3a25, %edx           # imm = 0x3A25
leaq 0x41866(%rip), %rcx     # 0xc80ed
callq 0xb410
cmpq $0x0, -0x30(%rbp)
jbe 0x86895
jmp 0x868b4
leaq 0x418e5(%rip), %rdi     # 0xc8181
leaq 0x3c0ca(%rip), %rsi     # 0xc296d
movl $0x3a26, %edx           # imm = 0x3A26
leaq 0x4183e(%rip), %rcx     # 0xc80ed
callq 0xb410
jmp 0x868b6
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq -0x18(%rbp), %rcx
movb %al, -0x31(%rbp)
jae 0x8690e
movq -0x20(%rbp), %rcx
subq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq -0x30(%rbp), %rcx
movb %al, -0x31(%rbp)
jb 0x8690e
movq -0x28(%rbp), %rcx
addq -0x30(%rbp), %rcx
movb $0x1, %al
cmpq -0x18(%rbp), %rcx
movb %al, -0x32(%rbp)
jb 0x86908
movq -0x18(%rbp), %rax
subq -0x28(%rbp), %rax
movq -0x28(%rbp), %rcx
addq -0x30(%rbp), %rcx
subq -0x18(%rbp), %rcx
cmpq %rcx, %rax
seta %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x86917
jmp 0x86975
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
je 0x8692f
jmp 0x8694e
leaq 0x41855(%rip), %rdi     # 0xc818b
leaq 0x3c030(%rip), %rsi     # 0xc296d
movl $0x3a3f, %edx           # imm = 0x3A3F
leaq 0x417a4(%rip), %rcx     # 0xc80ed
callq 0xb410
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
addb $-0x1, %dl
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x868b6
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)