// File: SYZYGYfpga[P]brain-tools/include/json.hpp
// 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]));
                        // invalid characters will be detected by throw_if_invalid_utf8
                        assert (bytes != std::string::npos);

                        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 0x3200
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x95e2
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x32f0
movsbl (%rax), %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x5c, %eax
ja 0x9506
movq -0x38(%rbp), %rax
leaq 0xac7d(%rip), %rcx      # 0x14158
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x95cf
movq -0x18(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x18(%rbp)
jmp 0x95cf
testb $0x1, -0x9(%rbp)
je 0x95cd
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x32f0
movsbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x9543
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x32f0
movsbl (%rax), %eax
cmpl $0x7f, %eax
jne 0x95cd
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x32f0
movzbl (%rax), %edi
callq 0x9600
movq %rax, -0x40(%rbp)
jmp 0x955e
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
je 0x956f
jmp 0x958e
leaq 0xb713(%rip), %rdi      # 0x14c89
leaq 0xb5cc(%rip), %rsi      # 0x14b49
movl $0x18f8, %edx           # imm = 0x18F8
leaq 0xb848(%rip), %rcx      # 0x14dd1
callq 0x31d0
cmpq $0x3, -0x28(%rbp)
jne 0x95ac
movl $0xc, %eax
subq -0x28(%rbp), %rax
subq $0x1, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x95c1
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 0x95cf
jmp 0x95d1
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x9494
movq -0x18(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0x75b0
nopw %cs:(%rax,%rax)
nop