// File: lvandeve[P]base256/base256.cpp
// Function: utf8_to_unicode(std::vector<unsigned char, std::allocator<unsigned char>> const&)
std::vector<int> utf8_to_unicode(const std::vector<uint8_t>& a) {
  std::vector<int> result;
  for(int i = 0; i < a.size(); i++) {
    int b0 = a[i];
    int b1 = i + 1 < a.size() ? a[i + 1] : 255;
    int b2 = i + 2 < a.size() ? a[i + 2] : 255;
    int b3 = i + 3 < a.size() ? a[i + 3] : 255;

    if(b0 < 128) {
      result.push_back(b0);
    } else if(b0 < 194) {
      result.push_back(REPL_CHAR);
    } else if(b0 < 224) {
      if((b1 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      i++;
      result.push_back(((b0 & 31) << 6) + (b1 & 63));
    } else if(b0 < 240) {
      if((b1 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      if(b0 == 224 && b1 < 160) { result.push_back(REPL_CHAR); continue; };
      i++;
      if((b2 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      i++;
      result.push_back(((b0 & 15) << 12) + ((b1 & 63) << 6) + (b2 & 63));
    } else if(b0 < 245) {
      if((b1 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      if(b0 == 240 && b1 < 144) { result.push_back(REPL_CHAR); continue; };
      if(b0 == 244 && b1 >= 144) { result.push_back(REPL_CHAR); continue; };
      i++;
      if((b2 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      i++;
      if((b3 & 192) != 128) { result.push_back(REPL_CHAR); continue; }
      i++;
      result.push_back(((b0 & 7) << 18) + ((b1 & 63) << 12) + ((b2 & 63) << 6) + (b3 & 63));
    } else {
      result.push_back(REPL_CHAR);
    }
  }
  return result;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movb $0x0, 0x77(%rsp)
callq 0xd4a0
movl $0x0, 0x70(%rsp)
movslq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rdi
callq 0xd4b0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x68f9
movq 0x78(%rsp), %rdi
movslq 0x70(%rsp), %rsi
callq 0xd4d0
movzbl (%rax), %eax
movl %eax, 0x6c(%rsp)
movl 0x70(%rsp), %eax
addl $0x1, %eax
cltq
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rdi
callq 0xd4b0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x6530
movq 0x78(%rsp), %rdi
movl 0x70(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xd4d0
movzbl (%rax), %eax
movl %eax, 0x24(%rsp)
jmp 0x653b
movl $0xff, %eax
movl %eax, 0x24(%rsp)
jmp 0x653b
movl 0x24(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x70(%rsp), %eax
addl $0x2, %eax
cltq
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rdi
callq 0xd4b0
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x6585
movq 0x78(%rsp), %rdi
movl 0x70(%rsp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0xd4d0
movzbl (%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x6590
movl $0xff, %eax
movl %eax, 0x14(%rsp)
jmp 0x6590
movl 0x14(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x70(%rsp), %eax
addl $0x3, %eax
cltq
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rdi
callq 0xd4b0
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x65da
movq 0x78(%rsp), %rdi
movl 0x70(%rsp), %eax
addl $0x3, %eax
movslq %eax, %rsi
callq 0xd4d0
movzbl (%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x65e5
movl $0xff, %eax
movl %eax, 0x4(%rsp)
jmp 0x65e5
movl 0x4(%rsp), %eax
movl %eax, 0x60(%rsp)
cmpl $0x80, 0x6c(%rsp)
jge 0x662a
movq 0x38(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
callq 0xd4f0
jmp 0x6608
jmp 0x68e7
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
callq 0xd590
jmp 0x691c
cmpl $0xc2, 0x6c(%rsp)
jge 0x664c
movq 0x38(%rsp), %rdi
leaq 0x1a9c4(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6647
jmp 0x68e5
cmpl $0xe0, 0x6c(%rsp)
jge 0x66b5
movl 0x68(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x667e
movq 0x38(%rsp), %rdi
leaq 0x1a992(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6679
jmp 0x68e9
movq 0x38(%rsp), %rdi
movl 0x70(%rsp), %eax
incl %eax
movl %eax, 0x70(%rsp)
movl 0x6c(%rsp), %eax
andl $0x1f, %eax
shll $0x6, %eax
movl 0x68(%rsp), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, 0x50(%rsp)
leaq 0x50(%rsp), %rsi
callq 0xd560
jmp 0x66b0
jmp 0x68e3
cmpl $0xf0, 0x6c(%rsp)
jge 0x678d
movl 0x68(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x66eb
movq 0x38(%rsp), %rdi
leaq 0x1a925(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x66e6
jmp 0x68e9
cmpl $0xe0, 0x6c(%rsp)
jne 0x6717
cmpl $0xa0, 0x68(%rsp)
jge 0x6717
movq 0x38(%rsp), %rdi
leaq 0x1a8f9(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6712
jmp 0x68e9
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
movl 0x64(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x674a
movq 0x38(%rsp), %rdi
leaq 0x1a8c6(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6745
jmp 0x68e9
movq 0x38(%rsp), %rdi
movl 0x70(%rsp), %eax
incl %eax
movl %eax, 0x70(%rsp)
movl 0x6c(%rsp), %eax
andl $0xf, %eax
shll $0xc, %eax
movl 0x68(%rsp), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movl 0x64(%rsp), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, 0x4c(%rsp)
leaq 0x4c(%rsp), %rsi
callq 0xd560
jmp 0x6788
jmp 0x68e1
cmpl $0xf5, 0x6c(%rsp)
jge 0x68ca
movl 0x68(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x67c3
movq 0x38(%rsp), %rdi
leaq 0x1a84d(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x67be
jmp 0x68e9
cmpl $0xf0, 0x6c(%rsp)
jne 0x67ef
cmpl $0x90, 0x68(%rsp)
jge 0x67ef
movq 0x38(%rsp), %rdi
leaq 0x1a821(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x67ea
jmp 0x68e9
cmpl $0xf4, 0x6c(%rsp)
jne 0x681b
cmpl $0x90, 0x68(%rsp)
jl 0x681b
movq 0x38(%rsp), %rdi
leaq 0x1a7f5(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6816
jmp 0x68e9
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
movl 0x64(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x684e
movq 0x38(%rsp), %rdi
leaq 0x1a7c2(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x6849
jmp 0x68e9
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
movl 0x60(%rsp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x687e
movq 0x38(%rsp), %rdi
leaq 0x1a78f(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x687c
jmp 0x68e9
movq 0x38(%rsp), %rdi
movl 0x70(%rsp), %eax
incl %eax
movl %eax, 0x70(%rsp)
movl 0x6c(%rsp), %eax
andl $0x7, %eax
shll $0x12, %eax
movl 0x68(%rsp), %ecx
andl $0x3f, %ecx
shll $0xc, %ecx
orl %ecx, %eax
movl 0x64(%rsp), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movl 0x60(%rsp), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, 0x48(%rsp)
leaq 0x48(%rsp), %rsi
callq 0xd560
jmp 0x68c8
jmp 0x68df
movq 0x38(%rsp), %rdi
leaq 0x1a72e(%rip), %rsi     # 0x21004
callq 0xd4f0
jmp 0x68dd
jmp 0x68df
jmp 0x68e1
jmp 0x68e3
jmp 0x68e5
jmp 0x68e7
jmp 0x68e9
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x64b3
movb $0x1, 0x77(%rsp)
testb $0x1, 0x77(%rsp)
jne 0x690f
movq 0x38(%rsp), %rdi
callq 0xd590
movq 0x40(%rsp), %rax
addq $0x88, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x54e0
nopw %cs:(%rax,%rax)