// File: /workspace/github_cpp_makefile_star2_O1/WojciechMula[P]utf16utf8/include/reference.h
// Function: utf16_to_utf8(unsigned short const*, unsigned char*)
static inline uint8_t *utf16_to_utf8(const uint16_t *utf16, uint8_t *utf8)
{
	size_t i, j;
	uint32_t c;

	if (utf16==NULL)
		return NULL;

	if (utf8==NULL)
		utf8 = (uint8_t*)calloc(strlen_utf16_to_utf8(utf16) + 1, sizeof(uint8_t));

	for (i=0, j=0, c=1; c; i++)
	{
		c = utf16_to_unicode32(&utf16[i], &i);
		sprint_unicode(&utf8[j], c);
		j += codepoint_utf8_size(c);
	}

	return utf8;
}

// Assembly:
testq %rdi, %rdi
je 0x4b0a
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x49bb
movzwl (%rbx), %esi
testw %si, %si
je 0x49a9
xorl %edi, %edi
movl $0x3ff, %eax            # imm = 0x3FF
movq %rbx, %r8
xorl %ecx, %ecx
leal 0x2000(%rsi), %r9d
movl $0x0, %edx
cmpw $0xf800, %r9w           # imm = 0xF800
jb 0x492b
xorl %edx, %edx
cmpw $0x0, 0x2(%r8)
setne %dl
testl %edx, %edx
je 0x4946
andl %eax, %esi
shll $0xa, %esi
movzwl 0x2(%r8), %r8d
andl %eax, %r8d
leal 0x10000(%rsi,%r8), %r8d
jmp 0x494a
movzwl %si, %r8d
movl $0x1, %esi
cmpl $0x80, %r8d
jb 0x4984
movl $0x2, %esi
cmpl $0x800, %r8d            # imm = 0x800
jb 0x4984
movl $0x3, %esi
cmpl $0x10000, %r8d          # imm = 0x10000
jb 0x4984
xorl %esi, %esi
cmpl $0x110000, %r8d         # imm = 0x110000
setb %sil
shll $0x2, %esi
addq %rsi, %rdi
movl %edx, %edx
leaq (%rcx,%rdx), %rsi
leaq 0x1(%rcx,%rdx), %rcx
leaq 0x2(%rbx,%rsi,2), %r8
movzwl (%r8), %esi
testw %si, %si
jne 0x490c
incq %rdi
jmp 0x49ae
movl $0x1, %edi
movl $0x1, %esi
callq 0x20e0
movq %rax, %rsi
xorl %eax, %eax
movl $0x3ff, %ecx            # imm = 0x3FF
xorl %edx, %edx
movzwl (%rbx,%rdx,2), %edi
leal 0x2000(%rdi), %r9d
movl $0x0, %r8d
cmpw $0xf800, %r9w           # imm = 0xF800
jb 0x49ea
xorl %r8d, %r8d
cmpw $0x0, 0x2(%rbx,%rdx,2)
setne %r8b
testl %r8d, %r8d
je 0x4a05
andl %ecx, %edi
shll $0xa, %edi
movzwl 0x2(%rbx,%rdx,2), %r9d
andl %ecx, %r9d
leal 0x10000(%rdi,%r9), %edi
leaq (%rsi,%rax), %r9
cmpl $0x7f, %edi
ja 0x4a24
movb %dil, (%r9)
movl $0x1, %r11d
testl %edi, %edi
jne 0x4ab1
jmp 0x4ab6
cmpl $0x7ff, %edi            # imm = 0x7FF
ja 0x4a4e
movl %edi, %r10d
andb $0x3f, %r10b
orb $-0x80, %r10b
movb %r10b, 0x1(%r9)
movl %edi, %r10d
shrl $0x6, %r10d
orb $-0x40, %r10b
movl $0x2, %r11d
jmp 0x4aae
movl %edi, %r11d
andb $0x3f, %r11b
orb $-0x80, %r11b
movl %edi, %ebp
shrl $0x6, %ebp
andb $0x3f, %bpl
orb $-0x80, %bpl
movl %edi, %r10d
shrl $0xc, %r10d
cmpl $0xffff, %edi           # imm = 0xFFFF
ja 0x4a89
movb %r11b, 0x2(%r9)
movb %bpl, 0x1(%r9)
orb $-0x20, %r10b
movl $0x3, %r11d
jmp 0x4aae
movb %r11b, 0x3(%r9)
movb %bpl, 0x2(%r9)
andb $0x3f, %r10b
orb $-0x80, %r10b
movb %r10b, 0x1(%r9)
movl %edi, %r10d
shrl $0x12, %r10d
orb $-0x10, %r10b
movl $0x4, %r11d
movb %r10b, (%r9)
movb $0x0, (%r9,%r11)
movl $0x1, %r9d
cmpl $0x80, %edi
jb 0x4af1
movl $0x2, %r9d
cmpl $0x800, %edi            # imm = 0x800
jb 0x4af1
movl $0x3, %r9d
cmpl $0x10000, %edi          # imm = 0x10000
jb 0x4af1
xorl %r9d, %r9d
cmpl $0x110000, %edi         # imm = 0x110000
setb %r9b
shll $0x2, %r9d
movl %r8d, %r8d
addq %r9, %rax
leaq 0x1(%rdx,%r8), %rdx
testl %edi, %edi
jne 0x49c4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq