// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]base256/base256.cpp
// Function: unicode_to_utf8(std::vector<int, std::allocator<int>> const&)
std::vector<uint8_t> unicode_to_utf8(const std::vector<int>& a) {
  std::vector<uint8_t> result;
  for(int i = 0; i < a.size(); i++) {
    int code_point = a[i];
    if(code_point < 128) {
      result.push_back(code_point);
    } else if(code_point <= 2047) {
      result.push_back((code_point >> 6) + 192);
      result.push_back((code_point & 63) + 128);
    } else if(code_point <= 65535) {
      result.push_back((code_point >> 12) + 224);
      result.push_back(((code_point >> 6) & 63) + 128);
      result.push_back((code_point & 63) + 128);
    } else if(code_point <= 1114111) {
      result.push_back((code_point >> 18) + 240);
      result.push_back(((code_point >> 12) & 63) + 128);
      result.push_back(((code_point >> 6) & 63) + 128);
      result.push_back((code_point & 63) + 128);
    } else {
      // error, add replacement character
      result.push_back(239);
      result.push_back(191);
      result.push_back(189);
    }
  }
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %ebp, %ebp
leaq 0x17(%rsp), %r15
leaq 0x15(%rsp), %r13
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
jbe 0x4e87
movl (%rax,%rbp,4), %r12d
cmpl $0x7f, %r12d
jg 0x4d3a
movb %r12b, 0x17(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc6a2
jmp 0x4e7f
cmpl $0x7ff, %r12d           # imm = 0x7FF
ja 0x4d79
movl %r12d, %eax
shrl $0x6, %eax
orb $-0x40, %al
movb %al, 0x16(%rsp)
movq %rbx, %rdi
leaq 0x16(%rsp), %rsi
callq 0xc6a2
andb $0x3f, %r12b
orb $-0x80, %r12b
movb %r12b, 0x15(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc6a2
jmp 0x4e7f
cmpl $0xffff, %r12d          # imm = 0xFFFF
ja 0x4dd5
movl %r12d, %eax
shrl $0xc, %eax
orb $-0x20, %al
movb %al, 0x14(%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xc6a2
movl %r12d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x13(%rsp)
movq %rbx, %rdi
leaq 0x13(%rsp), %rsi
callq 0xc6a2
andb $0x3f, %r12b
orb $-0x80, %r12b
movb %r12b, 0x12(%rsp)
movq %rbx, %rdi
leaq 0x12(%rsp), %rsi
callq 0xc6a2
jmp 0x4e7f
cmpl $0x10ffff, %r12d        # imm = 0x10FFFF
ja 0x4e49
movl %r12d, %eax
shrl $0x12, %eax
orb $-0x10, %al
movb %al, 0x11(%rsp)
movq %rbx, %rdi
leaq 0x11(%rsp), %rsi
callq 0xc6a2
movl %r12d, %eax
shrl $0xc, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0xc6a2
movl %r12d, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0xf(%rsp)
movq %rbx, %rdi
leaq 0xf(%rsp), %rsi
callq 0xc6a2
andb $0x3f, %r12b
orb $-0x80, %r12b
movb %r12b, 0xe(%rsp)
movq %rbx, %rdi
leaq 0xe(%rsp), %rsi
callq 0xc6a2
jmp 0x4e7f
movb $-0x11, 0xd(%rsp)
movq %rbx, %rdi
leaq 0xd(%rsp), %rsi
callq 0xc6a2
movb $-0x41, 0xc(%rsp)
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0xc6a2
movb $-0x43, 0xb(%rsp)
movq %rbx, %rdi
leaq 0xb(%rsp), %rsi
callq 0xc6a2
incq %rbp
jmp 0x4d04
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
jmp 0x4eb1
movq %rax, %r14
movq %rbx, %rdi
callq 0xc694
movq %r14, %rdi
callq 0x43a0