// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
leaq 0x10(%rdi), %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rsi, %rax
andq $-0x400, %rax           # imm = 0xFC00
movb $0x0, 0x10(%rdi)
cmpq $0xd800, %rax           # imm = 0xD800
jne 0x36afb
movq %rdx, %rax
andq $-0x400, %rax           # imm = 0xFC00
cmpq $0xdc00, %rax           # imm = 0xDC00
jne 0x36bad
shlq $0xa, %r14
leaq -0x35fdc00(%rdx,%r14), %r14
movl %r14d, %eax
shrl $0x12, %eax
orb $-0x10, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
movl %r14d, %eax
shrl $0xc, %eax
andb $0x3f, %al
orb $-0x80, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
movl %r14d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
andb $0x3f, %r14b
orb $-0x80, %r14b
jmp 0x36b01
cmpq $0x7f, %r14
ja 0x36b19
movsbl %r14b, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0x36b3a
movl %r14d, %eax
shrl $0x6, %eax
orb $-0x40, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
jmp 0x36af1
cmpq $0xffff, %r14           # imm = 0xFFFF
ja 0x36b76
movl %r14d, %eax
shrl $0xc, %eax
orb $-0x20, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
movl %r14d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movsbl %al, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x31f50
jmp 0x36af1
cmpq $0x10ffff, %r14         # imm = 0x10FFFF
jbe 0x36aab
pushq $0x10
popq %rdi
callq 0x30c90
movq %rax, %r14
leaq 0x13acd(%rip), %rsi     # 0x4a662
movq %rax, %rdi
callq 0x30280
movq 0x2630c(%rip), %rdx     # 0x5ceb0
movq 0x263a5(%rip), %rsi     # 0x5cf50
jmp 0x36bd5
pushq $0x10
popq %rdi
callq 0x30c90
movq %rax, %r14
leaq 0x13a84(%rip), %rsi     # 0x4a643
movq %rax, %rdi
callq 0x338b0
movq 0x2635a(%rip), %rdx     # 0x5cf28
movq 0x263ab(%rip), %rsi     # 0x5cf80
movq %r14, %rdi
callq 0x333b0
jmp 0x36bdf
movq %r14, %rdi
movq %rax, %r15
callq 0x31400
jmp 0x36bef
movq %rax, %r15
movq %rbx, %rdi
callq 0x33b38
movq %r15, %rdi
callq 0x33510
nop