// File: king1600[P]cordpp/./include/json.h
// Function: nlohmann::detail::serializer<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>>::extra_space(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
static std::size_t extra_space(const string_t& s,
                                   const bool ensure_ascii) noexcept
    {
        std::size_t res = 0;

        for (std::size_t i = 0; i < s.size(); ++i)
        {
            switch (s[i])
            {
                // control characters that can be escaped with a backslash
                case '"':
                case '\\':
                case '\b':
                case '\f':
                case '\n':
                case '\r':
                case '\t':
                {
                    // from c (1 byte) to \x (2 bytes)
                    res += 1;
                    break;
                }

                // control characters that need \uxxxx escaping
                case 0x00:
                case 0x01:
                case 0x02:
                case 0x03:
                case 0x04:
                case 0x05:
                case 0x06:
                case 0x07:
                case 0x0b:
                case 0x0e:
                case 0x0f:
                case 0x10:
                case 0x11:
                case 0x12:
                case 0x13:
                case 0x14:
                case 0x15:
                case 0x16:
                case 0x17:
                case 0x18:
                case 0x19:
                case 0x1a:
                case 0x1b:
                case 0x1c:
                case 0x1d:
                case 0x1e:
                case 0x1f:
                {
                    // from c (1 byte) to \uxxxx (6 bytes)
                    res += 5;
                    break;
                }

                default:
                {
                    if (ensure_ascii and (s[i] & 0x80 or s[i] == 0x7F))
                    {
                        const auto bytes = bytes_following(static_cast<uint8_t>(s[i]));
                        if (bytes == std::string::npos)
                        {
                            // invalid characters are treated as is, so no
                            // additional space will be used
                            break;
                        }

                        if (bytes == 3)
                        {
                            // codepoints that need 4 bytes (i.e., 3 additional
                            // bytes) in UTF-8 need a surrogate pair when \u
                            // escaping is used: from 4 bytes to \uxxxx\uxxxx
                            // (12 bytes)
                            res += (12 - bytes - 1);
                        }
                        else
                        {
                            // from x bytes to \uxxxx (6 bytes)
                            res += (6 - bytes - 1);
                        }

                        // skip the additional bytes
                        i += bytes;
                    }
                    break;
                }
            }
        }

        return res;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0xc420
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x3007f
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xce20
movsbl (%rax), %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x5c, %eax
ja 0x2ffc6
movq -0x38(%rbp), %rax
leaq 0x60791(%rip), %rcx     # 0x9072c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x3006c
movq -0x18(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x18(%rbp)
jmp 0x3006c
testb $0x1, -0x9(%rbp)
je 0x3006a
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xce20
movsbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2ffff
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xce20
movsbl (%rax), %eax
cmpl $0x7f, %eax
jne 0x3006a
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xce20
movzbl (%rax), %edi
callq 0x300a0
movq %rax, -0x40(%rbp)
jmp 0x3001a
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
jne 0x3002b
jmp 0x3006c
cmpq $0x3, -0x28(%rbp)
jne 0x30049
movl $0xc, %eax
subq -0x28(%rbp), %rax
subq $0x1, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x3005e
movl $0x6, %eax
subq -0x28(%rbp), %rax
subq $0x1, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x3006c
jmp 0x3006e
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2ff54
movq -0x18(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0x10ef0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)