// File: jkom-cloud[P]mmseg/src/util/StringUtil.hpp
// Function: bool utilSpace::utf8ToUnicode<std::__cxx11::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t>>>(char const*, unsigned long, std::__cxx11::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t>>&)
bool utf8ToUnicode(const char * const str, size_t len, Uint16Container& vec) {
  if(!str) {
    return false;
  }
  char ch1, ch2;
  uint16_t tmp;
  vec.clear();
  for(size_t i = 0; i < len;) {
    if(!(str[i] & 0x80)) { // 0xxxxxxx
      vec.push_back(str[i]);
      i++;
    } else if ((uint8_t)str[i] <= 0xdf && i + 1 < len) { // 110xxxxxx
      ch1 = (str[i] >> 2) & 0x07;
      ch2 = (str[i+1] & 0x3f) | ((str[i] & 0x03) << 6 );
      tmp = (((uint16_t(ch1) & 0x00ff ) << 8) | (uint16_t(ch2) & 0x00ff));
      vec.push_back(tmp);
      i += 2;
    } else if((uint8_t)str[i] <= 0xef && i + 2 < len) {
      ch1 = ((uint8_t)str[i] << 4) | ((str[i+1] >> 2) & 0x0f );
      ch2 = (((uint8_t)str[i+1]<<6) & 0xc0) | (str[i+2] & 0x3f);
      tmp = (((uint16_t(ch1) & 0x00ff ) << 8) | (uint16_t(ch2) & 0x00ff));
      vec.push_back(tmp);
      i += 3;
    } else {
      return false;
    }
  }
  return true;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x62f5
movb $0x0, 0x37(%rsp)
jmp 0x64f7
movq 0x18(%rsp), %rdi
callq 0x6510
movq $0x0, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0x64f2
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x635e
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
movzwl %ax, %esi
callq 0x6530
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x64ed
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xdf, %eax
jg 0x6416
movq 0x8(%rsp), %rax
addq $0x1, %rax
cmpq 0x20(%rsp), %rax
jae 0x6416
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
sarl $0x2, %eax
andl $0x7, %eax
movb %al, 0x17(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movsbl 0x1(%rax,%rcx), %eax
andl $0x3f, %eax
movq 0x28(%rsp), %rcx
movq 0x8(%rsp), %rdx
movsbl (%rcx,%rdx), %ecx
andl $0x3, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movb %al, 0x16(%rsp)
movsbl 0x17(%rsp), %eax
movzwl %ax, %eax
andl $0xff, %eax
shll $0x8, %eax
movsbl 0x16(%rsp), %ecx
movzwl %cx, %ecx
andl $0xff, %ecx
orl %ecx, %eax
movw %ax, 0x14(%rsp)
movq 0x18(%rsp), %rdi
movzwl 0x14(%rsp), %esi
callq 0x6530
movq 0x8(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x8(%rsp)
jmp 0x64eb
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xef, %eax
jg 0x64e2
movq 0x8(%rsp), %rax
addq $0x2, %rax
cmpq 0x20(%rsp), %rax
jae 0x64e2
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x4, %eax
movq 0x28(%rsp), %rcx
movq 0x8(%rsp), %rdx
movsbl 0x1(%rcx,%rdx), %ecx
sarl $0x2, %ecx
andl $0xf, %ecx
orl %ecx, %eax
movb %al, 0x17(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movzbl 0x1(%rax,%rcx), %eax
shll $0x6, %eax
andl $0xc0, %eax
movq 0x28(%rsp), %rcx
movq 0x8(%rsp), %rdx
movsbl 0x2(%rcx,%rdx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movb %al, 0x16(%rsp)
movsbl 0x17(%rsp), %eax
movzwl %ax, %eax
andl $0xff, %eax
shll $0x8, %eax
movsbl 0x16(%rsp), %ecx
movzwl %cx, %ecx
andl $0xff, %ecx
orl %ecx, %eax
movw %ax, 0x14(%rsp)
movq 0x18(%rsp), %rdi
movzwl 0x14(%rsp), %esi
callq 0x6530
movq 0x8(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x8(%rsp)
jmp 0x64e9
movb $0x0, 0x37(%rsp)
jmp 0x64f7
jmp 0x64eb
jmp 0x64ed
jmp 0x6308
movb $0x1, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)