// File: lotuskip[P]yuxtapa/common/utfstr.cpp
// Function: ins(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int, int)
void ins(string &s, const unsigned int c, const int n)
{
	// First interpret "n symbols" in terms of a string iterator:
	string::iterator i = s.begin();
	advance(i, s, n);
	if(c < 0x80) // single byte
		s.insert(i, static_cast<unsigned char>(c));
	else if(c < 0x800) // 2 bytes
	{
		i = s.insert(i, static_cast<unsigned char>((c >> 6) | 0xc0));
		s.insert(++i, static_cast<unsigned char>((c & 0x3f) | 0x80));
	}
	else if(c < 0x10000) // 3
	{
		i = s.insert(i, static_cast<unsigned char>((c >> 12) | 0xe0));
		i = s.insert(++i, static_cast<unsigned char>(((c >> 6) & 0x3f) | 0x80));
		s.insert(++i, static_cast<unsigned char>((c & 0x3f) | 0x80));
	}
	else // 4
	{
		i = s.insert(i, static_cast<unsigned char>((c >> 18) | 0xf0));
		i = s.insert(++i, static_cast<unsigned char>(((c >> 12) & 0x3f) | 0x80));
		i = s.insert(++i, static_cast<unsigned char>(((c >> 6) & 0x3f) | 0x80));
		s.insert(++i, static_cast<unsigned char>((c & 0x3f) | 0x80));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5400
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rsi
movl -0x10(%rbp), %eax
leaq -0x18(%rbp), %rdi
movswl %ax, %edx
callq 0x1a320
cmpl $0x80, -0xc(%rbp)
jae 0x1a535
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1ab80
movq -0xc0(%rbp), %rdi
movl -0xc(%rbp), %eax
movq -0x20(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x28(%rbp)
jmp 0x1a7f7
cmpl $0x800, -0xc(%rbp)      # imm = 0x800
jae 0x1a5cb
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1ab80
movq -0xd0(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0x6, %eax
orl $0xc0, %eax
movq -0x38(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x1ab80
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0x40(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x48(%rbp)
jmp 0x1a7f5
cmpl $0x10000, -0xc(%rbp)    # imm = 0x10000
jae 0x1a6ae
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1ab80
movq -0xe8(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0xc, %eax
orl $0xe0, %eax
movq -0x58(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x1ab80
movq -0xe0(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0x68(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x1ab80
movq -0xd8(%rbp), %rdi
movl -0xc(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0x70(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x78(%rbp)
jmp 0x1a7f3
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1ab80
movq -0x108(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0x12, %eax
orl $0xf0, %eax
movq -0x88(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x1ab80
movq -0x100(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0xc, %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0x98(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x1ab80
movq -0xf8(%rbp), %rdi
movl -0xc(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0xa8(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18110
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x1ab80
movq -0xf0(%rbp), %rdi
movl -0xc(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movq -0xb0(%rbp), %rsi
movsbl %al, %edx
callq 0x58c0
movq %rax, -0xb8(%rbp)
jmp 0x1a7f5
jmp 0x1a7f7
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq