// File: WojciechMula[P]utf16utf8/dependencies/utf8_v2_3_4/source/utf8/checked.h
// Function: std::back_insert_iterator<std::vector<unsigned char, std::allocator<unsigned char>>> utf8::utf16to8<__gnu_cxx::__normal_iterator<unsigned short const*, std::vector<unsigned short, std::allocator<unsigned short>>>, std::back_insert_iterator<std::vector<unsigned char, std::allocator<unsigned char>>>>(__gnu_cxx::__normal_iterator<unsigned short const*, std::vector<unsigned short, std::allocator<unsigned short>>>, __gnu_cxx::__normal_iterator<unsigned short const*, std::vector<unsigned short, std::allocator<unsigned short>>>, std::back_insert_iterator<std::vector<unsigned char, std::allocator<unsigned char>>>)
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
    {
        while (start != end) {
            uint32_t cp = utf8::internal::mask16(*start++);
            // Take care of surrogate pairs first
            if (utf8::internal::is_lead_surrogate(cp)) {
                if (start != end) {
                    uint32_t trail_surrogate = utf8::internal::mask16(*start++);
                    if (utf8::internal::is_trail_surrogate(trail_surrogate))
                        cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
                    else
                        throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
                }
                else
                    throw invalid_utf16(static_cast<uint16_t>(cp));

            }
            // Lone trail surrogate
            else if (utf8::internal::is_trail_surrogate(cp))
                throw invalid_utf16(static_cast<uint16_t>(cp));

            result = utf8::append(cp, result);
        }
        return result;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x12c90
testb $0x1, %al
jne 0x12a1d
jmp 0x12bd7
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x12cf0
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x12d30
movzwl (%rax), %edi
callq 0x12cd0
movzwl %ax, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
callq 0x12d50
testb $0x1, %al
jne 0x12a54
jmp 0x12b55
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x12c90
testb $0x1, %al
jne 0x12a6a
jmp 0x12b03
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x12cf0
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x12d30
movzwl (%rax), %edi
callq 0x12cd0
movzwl %ax, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
callq 0x12d80
testb $0x1, %al
jne 0x12a9e
jmp 0x12ab1
movl -0x24(%rbp), %eax
shll $0xa, %eax
addl -0x34(%rbp), %eax
addl $0xfca02400, %eax       # imm = 0xFCA02400
movl %eax, -0x24(%rbp)
jmp 0x12b01
movl $0x10, %edi
callq 0x20c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
movzwl -0x34(%rbp), %esi
callq 0x12db0
jmp 0x12ad0
movq -0x68(%rbp), %rdi
leaq 0xf21d(%rip), %rsi      # 0x21cf8
leaq 0x30e(%rip), %rdx       # 0x12df0
callq 0x22d0
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x2160
jmp 0x12bec
jmp 0x12b53
movl $0x10, %edi
callq 0x20c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
movzwl -0x24(%rbp), %esi
callq 0x12db0
jmp 0x12b22
movq -0x70(%rbp), %rdi
leaq 0xf1cb(%rip), %rsi      # 0x21cf8
leaq 0x2bc(%rip), %rdx       # 0x12df0
callq 0x22d0
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x2160
jmp 0x12bec
jmp 0x12bb2
movl -0x24(%rbp), %edi
callq 0x12d80
testb $0x1, %al
jne 0x12b63
jmp 0x12bb0
movl $0x10, %edi
callq 0x20c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movzwl -0x24(%rbp), %esi
callq 0x12db0
jmp 0x12b82
movq -0x78(%rbp), %rdi
leaq 0xf16b(%rip), %rsi      # 0x21cf8
leaq 0x25c(%rip), %rdx       # 0x12df0
callq 0x22d0
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x2160
jmp 0x12bec
jmp 0x12bb2
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
callq 0x12e10
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x12a07
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x22e0
nopw %cs:(%rax,%rax)
nop