// File: halfflat[P]tinyopt/test/googletest/googletest/src/gtest.cc
// Function: testing::internal::CodePointToUtf8[abi:cxx11](unsigned int)
std::string CodePointToUtf8(uint32_t code_point) {
  if (code_point > kMaxCodePoint4) {
    return "(Invalid Unicode 0x" + String::FormatHexUInt32(code_point) + ")";
  }

  char str[5];  // Big enough for the largest valid code point.
  if (code_point <= kMaxCodePoint1) {
    str[1] = '\0';
    str[0] = static_cast<char>(code_point);  // 0xxxxxxx
  } else if (code_point <= kMaxCodePoint2) {
    str[2] = '\0';
    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx
  } else if (code_point <= kMaxCodePoint3) {
    str[3] = '\0';
    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx
  } else {  // code_point <= kMaxCodePoint4
    str[4] = '\0';
    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx
  }
  return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x78(%rbp)
movq %rdi, %rax
movq %rax, -0x70(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x1fffff, -0xc(%rbp)   # imm = 0x1FFFFF
jbe 0x879de
movl -0xc(%rbp), %esi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x87b20
movq -0x80(%rbp), %rdx
leaq 0x46d38(%rip), %rsi     # 0xce6ad
leaq -0x30(%rbp), %rdi
callq 0xa34a0
jmp 0x87980
movq -0x78(%rbp), %rdi
leaq 0x43452(%rip), %rdx     # 0xcaddd
leaq -0x30(%rbp), %rsi
callq 0xa2b40
jmp 0x87996
leaq -0x30(%rbp), %rdi
callq 0x10fc8
leaq -0x50(%rbp), %rdi
callq 0x10fc8
jmp 0x87b09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x879d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x10fc8
leaq -0x50(%rbp), %rdi
callq 0x10fc8
jmp 0x87b16
cmpl $0x7f, -0xc(%rbp)
ja 0x879f3
movb $0x0, -0x60(%rbp)
movl -0xc(%rbp), %eax
movb %al, -0x61(%rbp)
jmp 0x87ac1
cmpl $0x7ff, -0xc(%rbp)      # imm = 0x7FF
ja 0x87a26
movb $0x0, -0x5f(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x60(%rbp)
movl -0xc(%rbp), %eax
orl $0xc0, %eax
movb %al, -0x61(%rbp)
jmp 0x87abf
cmpl $0xffff, -0xc(%rbp)     # imm = 0xFFFF
ja 0x87a6c
movb $0x0, -0x5e(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x5f(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x60(%rbp)
movl -0xc(%rbp), %eax
orl $0xe0, %eax
movb %al, -0x61(%rbp)
jmp 0x87abd
movb $0x0, -0x5d(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x5e(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x5f(%rbp)
leaq -0xc(%rbp), %rdi
movl $0x6, %esi
callq 0xa6ee0
orl $0x80, %eax
movb %al, -0x60(%rbp)
movl -0xc(%rbp), %eax
orl $0xf0, %eax
movb %al, -0x61(%rbp)
jmp 0x87abf
jmp 0x87ac1
leaq -0x62(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x10e10
movq -0x78(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq -0x61(%rbp), %rsi
callq 0x1d070
jmp 0x87ae7
leaq -0x62(%rbp), %rdi
callq 0x10810
jmp 0x87b09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x62(%rbp), %rdi
callq 0x10810
jmp 0x87b16
movq -0x70(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x10e00
nop