// File: /workspace/github_c_makefile_star2_O0/michaelnmmeyer[P]gourgandine/src/lib/utf8proc.c
// Function: utf8proc_iterate
UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate(
  const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_int32_t *dst
) {
  utf8proc_uint32_t uc;
  const utf8proc_uint8_t *end;

  *dst = -1;
  if (!strlen) return 0;
  end = str + ((strlen < 0) ? 4 : strlen);
  uc = *str++;
  if (uc < 0x80) {
    *dst = uc;
    return 1;
  }
  // Must be between 0xc2 and 0xf4 inclusive to be valid
  if ((uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
  if (uc < 0xe0) {         // 2-byte sequence
     // Must have valid continuation character
     if (!utf_cont(*str)) return UTF8PROC_ERROR_INVALIDUTF8;
     *dst = ((uc & 0x1f)<<6) | (*str & 0x3f);
     return 2;
  }
  if (uc < 0xf0) {        // 3-byte sequence
     if ((str + 1 >= end) || !utf_cont(*str) || !utf_cont(str[1]))
        return UTF8PROC_ERROR_INVALIDUTF8;
     // Check for surrogate chars
     if (uc == 0xed && *str > 0x9f)
         return UTF8PROC_ERROR_INVALIDUTF8;
     uc = ((uc & 0xf)<<12) | ((*str & 0x3f)<<6) | (str[1] & 0x3f);
     if (uc < 0x800)
         return UTF8PROC_ERROR_INVALIDUTF8;
     *dst = uc;
     return 3;
  }
  // 4-byte sequence
  // Must have 3 valid continuation characters
  if ((str + 2 >= end) || !utf_cont(*str) || !utf_cont(str[1]) || !utf_cont(str[2]))
     return UTF8PROC_ERROR_INVALIDUTF8;
  // Make sure in correct range (0x10000 - 0x10ffff)
  if (uc == 0xf0) {
    if (*str < 0x90) return UTF8PROC_ERROR_INVALIDUTF8;
  } else if (uc == 0xf4) {
    if (*str > 0x8f) return UTF8PROC_ERROR_INVALIDUTF8;
  }
  *dst = ((uc & 7)<<18) | ((*str & 0x3f)<<12) | ((str[1] & 0x3f)<<6) | (str[2] & 0x3f);
  return 4;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, -0x18(%rbp)
jne 0xf86e
movq $0x0, -0x8(%rbp)
jmp 0xfae6
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0xf888
movl $0x4, %eax
movq %rax, -0x40(%rbp)
jmp 0xf890
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x80, -0x24(%rbp)
jae 0xf8d3
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq $0x1, -0x8(%rbp)
jmp 0xfae6
movl -0x24(%rbp), %eax
subl $0xc2, %eax
cmpl $0x32, %eax
jbe 0xf8ed
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
cmpl $0xe0, -0x24(%rbp)
jae 0xf93e
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0xf916
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
movl -0x24(%rbp), %ecx
andl $0x1f, %ecx
shll $0x6, %ecx
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x3f, %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq $0x2, -0x8(%rbp)
jmp 0xfae6
cmpl $0xf0, -0x24(%rbp)
jae 0xfa05
movq -0x10(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
jae 0xf980
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0xf980
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0xf98d
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
cmpl $0xed, -0x24(%rbp)
jne 0xf9b1
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x9f, %eax
jle 0xf9b1
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
movl -0x24(%rbp), %eax
andl $0xf, %eax
shll $0xc, %eax
movq -0x10(%rbp), %rcx
movzbl (%rcx), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x24(%rbp)
cmpl $0x800, -0x24(%rbp)     # imm = 0x800
jae 0xf9ef
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq $0x3, -0x8(%rbp)
jmp 0xfae6
movq -0x10(%rbp), %rax
addq $0x2, %rax
cmpq -0x30(%rbp), %rax
jae 0xfa4e
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0xfa4e
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0xfa4e
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0xfa5b
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
cmpl $0xf0, -0x24(%rbp)
jne 0xfa7e
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x90, %eax
jge 0xfa7c
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
jmp 0xfaa3
cmpl $0xf4, -0x24(%rbp)
jne 0xfaa1
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x8f, %eax
jle 0xfa9f
movq $-0x3, -0x8(%rbp)
jmp 0xfae6
jmp 0xfaa1
jmp 0xfaa3
movl -0x24(%rbp), %ecx
andl $0x7, %ecx
shll $0x12, %ecx
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0xc, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0x3f, %eax
shll $0x6, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0x3f, %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq $0x4, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax)