// File: /workspace/github_c_makefile_star2_O0/moefh[P]hed/src/utf8.c
// Function: utf8_next
const void *utf8_next(const void *str)
{
  const uint8_t *s = str;

  if (*s == 0)
    return NULL;
  
  if ((s[0] & 0x80) == 0) {
    return s + 1;
  }
  
  if ((s[0] & 0xe0) == 0xc0) {
    if ((s[1] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x1f) << 6) | (s[1] & 0x3f);
    if (val <= 0x7f)
      return s + 1;
    return s + 2;
  }

  if ((s[0] & 0xf0) == 0xe0) {
    if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x0f) << 12) | ((s[1] & 0x3f) << 6) | (s[2] & 0x3f);
    if (val <= 0x7ff)
      return s + 1;
    return s + 3;
  }

  if ((s[0] & 0xf8) == 0xf0) {
    if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[3] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x07) << 18) | ((s[1] & 0x3f) << 12) | ((s[2] & 0x3f) << 6) | (s[3] & 0x3f);
    if (val <= 0xffff || val > 0x10ffff)
      return s + 1;
    return s + 4;
  }

  return s + 1;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq -0x10(%rsp), %rax
movq %rax, -0x18(%rsp)
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4b3a
movq $0x0, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x4b5f
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x4be8
movq -0x18(%rsp), %rax
movzbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x4b9b
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0x1f, %eax
shll $0x6, %eax
movq -0x18(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rsp)
cmpl $0x7f, -0x1c(%rsp)
ja 0x4bd5
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x4c9e
movq -0x18(%rsp), %rax
movzbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x4c2a
movq -0x18(%rsp), %rax
movzbl 0x2(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x4c3d
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0xf, %eax
shll $0xc, %eax
movq -0x18(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x18(%rsp), %rcx
movzbl 0x2(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x20(%rsp)
cmpl $0x7ff, -0x20(%rsp)     # imm = 0x7FF
ja 0x4c8b
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
addq $0x3, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x4d7e
movq -0x18(%rsp), %rax
movzbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x4cf5
movq -0x18(%rsp), %rax
movzbl 0x2(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x4cf5
movq -0x18(%rsp), %rax
movzbl 0x3(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x4d08
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
shll $0x12, %eax
movq -0x18(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
shll $0xc, %ecx
orl %ecx, %eax
movq -0x18(%rsp), %rcx
movzbl 0x2(%rcx), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x18(%rsp), %rcx
movzbl 0x3(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x24(%rsp)
cmpl $0xffff, -0x24(%rsp)    # imm = 0xFFFF
jbe 0x4d5e
cmpl $0x10ffff, -0x24(%rsp)  # imm = 0x10FFFF
jbe 0x4d6e
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x8(%rsp)
jmp 0x4d8c
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rsp)
movq -0x8(%rsp), %rax
retq
nopw %cs:(%rax,%rax)