// File: /workspace/github_cpp_makefile_star2_O1/alfanick[P]rest-cpp/src/rest/json.hpp
// Function: nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, long, double, std::allocator>::lexer::to_unicode(unsigned long, unsigned long)
static string_t to_unicode(const std::size_t codepoint1,
                                   const std::size_t codepoint2 = 0)
        {
            string_t result;

            // calculate the codepoint from the given code points
            std::size_t codepoint = codepoint1;

            // check if codepoint1 is a high surrogate
            if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
            {
                // check if codepoint2 is a low surrogate
                if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
                {
                    codepoint =
                        // high surrogate occupies the most significant 22 bits
                        (codepoint1 << 10)
                        // low surrogate occupies the least significant 15 bits
                        + codepoint2
                        // there is still the 0xD800, 0xDC00 and 0x10000 noise
                        // in the result so we have to subtract with:
                        // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
                        - 0x35FDC00;
                }
                else
                {
                    throw std::invalid_argument("missing or wrong low surrogate");
                }
            }

            if (codepoint < 0x80)
            {
                // 1-byte characters: 0xxxxxxx (ASCII)
                result.append(1, static_cast<typename string_t::value_type>(codepoint));
            }
            else if (codepoint <= 0x7ff)
            {
                // 2-byte characters: 110xxxxx 10xxxxxx
                result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
            }
            else if (codepoint <= 0xffff)
            {
                // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
                result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
            }
            else if (codepoint <= 0x10ffff)
            {
                // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
                result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
                result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
            }
            else
            {
                throw std::out_of_range("code points above 0x10FFFF are invalid");
            }

            return result;
        }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x10(%rdi), %r12
movq %r12, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
movq %rsi, %rax
andq $-0x400, %rax           # imm = 0xFC00
cmpq $0xd800, %rax           # imm = 0xD800
jne 0x26dc9
movq %rdx, %rax
andq $-0x400, %rax           # imm = 0xFC00
cmpq $0xdc00, %rax           # imm = 0xDC00
jne 0x26ee4
shlq $0xa, %r14
leaq -0x35fdc00(%rdx,%r14), %r14
cmpq $0x7f, %r14
ja 0x26dd6
xorl %esi, %esi
jmp 0x26ec2
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0x26e01
movl %r14d, %eax
shrl $0x6, %eax
orb $-0x40, %al
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x232a0
jmp 0x26eb6
cmpq $0xffff, %r14           # imm = 0xFFFF
ja 0x26e4a
movl %r14d, %eax
shrl $0xc, %eax
orb $-0x20, %al
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x232a0
movl %r14d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movq 0x8(%rbx), %rsi
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x232a0
jmp 0x26eb6
cmpq $0x10ffff, %r14         # imm = 0x10FFFF
ja 0x26f16
movl %r14d, %eax
shrl $0x12, %eax
orb $-0x10, %al
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x232a0
movl %r14d, %eax
shrl $0xc, %eax
andb $0x3f, %al
orb $-0x80, %al
movq 0x8(%rbx), %rsi
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x232a0
movl %r14d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movq 0x8(%rbx), %rsi
movsbl %al, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x232a0
andb $0x3f, %r14b
orb $-0x80, %r14b
movq 0x8(%rbx), %rsi
movsbl %r14b, %r8d
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x232a0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x217b0
movq %rax, %r14
leaq 0x1777b(%rip), %rsi     # 0x3e673
movq %rax, %rdi
callq 0x23390
movq 0x27031(%rip), %rdx     # 0x4df38
movq 0x2707a(%rip), %rsi     # 0x4df88
movq %r14, %rdi
callq 0x230a0
movl $0x10, %edi
callq 0x217b0
movq %rax, %r14
leaq 0x17768(%rip), %rsi     # 0x3e692
movq %rax, %rdi
callq 0x211a0
movq 0x26f87(%rip), %rdx     # 0x4dec0
movq 0x27020(%rip), %rsi     # 0x4df60
jmp 0x26f0e
jmp 0x26f44
movq %rax, %r15
movq %r14, %rdi
callq 0x21c50
jmp 0x26f54
movq %rax, %r15
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x26f61
callq 0x22130
movq %r15, %rdi
callq 0x23170
nop