// File: /workspace/github_c_makefile_star2_O0/michaelnmmeyer[P]gourgandine/src/lib/utf8proc.c
// Function: utf8proc_decompose
UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose(
  const utf8proc_uint8_t *str, utf8proc_ssize_t strlen,
  utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options
) {
  /* strlen will be ignored, if UTF8PROC_NULLTERM is set in options */
  utf8proc_ssize_t wpos = 0;
  if ((options & UTF8PROC_COMPOSE) && (options & UTF8PROC_DECOMPOSE))
    return UTF8PROC_ERROR_INVALIDOPTS;
  if ((options & UTF8PROC_STRIPMARK) &&
      !(options & UTF8PROC_COMPOSE) && !(options & UTF8PROC_DECOMPOSE))
    return UTF8PROC_ERROR_INVALIDOPTS;
  {
    utf8proc_int32_t uc;
    utf8proc_ssize_t rpos = 0;
    utf8proc_ssize_t decomp_result;
    int boundclass = UTF8PROC_BOUNDCLASS_START;
    while (1) {
      if (options & UTF8PROC_NULLTERM) {
        rpos += utf8proc_iterate(str + rpos, -1, &uc);
        /* checking of return value is not necessary,
           as 'uc' is < 0 in case of error */
        if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
        if (rpos < 0) return UTF8PROC_ERROR_OVERFLOW;
        if (uc == 0) break;
      } else {
        if (rpos >= strlen) break;
        rpos += utf8proc_iterate(str + rpos, strlen - rpos, &uc);
        if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
      }
      decomp_result = utf8proc_decompose_char(
        uc, buffer + wpos, (bufsize > wpos) ? (bufsize - wpos) : 0, options,
        &boundclass
      );
      if (decomp_result < 0) return decomp_result;
      wpos += decomp_result;
      /* prohibiting integer overflows due to too long strings: */
      if (wpos < 0 ||
          wpos > (utf8proc_ssize_t)(SSIZE_MAX/sizeof(utf8proc_int32_t)/2))
        return UTF8PROC_ERROR_OVERFLOW;
    }
  }
  if ((options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) && bufsize >= wpos) {
    utf8proc_ssize_t pos = 0;
    while (pos < wpos-1) {
      utf8proc_int32_t uc1, uc2;
      const utf8proc_property_t *property1, *property2;
      uc1 = buffer[pos];
      uc2 = buffer[pos+1];
      property1 = unsafe_get_property(uc1);
      property2 = unsafe_get_property(uc2);
      if (property1->combining_class > property2->combining_class &&
          property2->combining_class > 0) {
        buffer[pos] = uc2;
        buffer[pos+1] = uc1;
        if (pos > 0) pos--; else pos++;
      } else {
        pos++;
      }
    }
  }
  return wpos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movl -0x2c(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1078a
movl -0x2c(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x1078a
movq $-0x5, -0x8(%rbp)
jmp 0x10a04
movl -0x2c(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x107ba
movl -0x2c(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x107ba
movl -0x2c(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x107ba
movq $-0x5, -0x8(%rbp)
jmp 0x10a04
movq $0x0, -0x48(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x10828
movq -0x10(%rbp), %rdi
addq -0x48(%rbp), %rdi
movq $-0x1, %rsi
leaq -0x3c(%rbp), %rdx
callq 0xf840
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x10807
movq $-0x3, -0x8(%rbp)
jmp 0x10a04
cmpq $0x0, -0x48(%rbp)
jge 0x1081b
movq $-0x2, -0x8(%rbp)
jmp 0x10a04
cmpl $0x0, -0x3c(%rbp)
jne 0x10826
jmp 0x10919
jmp 0x1086d
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jl 0x10837
jmp 0x10919
movq -0x10(%rbp), %rdi
addq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
subq -0x48(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0xf840
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x1086b
movq $-0x3, -0x8(%rbp)
jmp 0x10a04
jmp 0x1086d
movl -0x3c(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jle 0x108a4
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x108af
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0x108af
movq -0x80(%rbp), %rsi
movl -0x84(%rbp), %edi
movq -0x90(%rbp), %rdx
movl -0x2c(%rbp), %ecx
leaq -0x54(%rbp), %r8
callq 0xffa0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jge 0x108e4
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x10a04
movq -0x50(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jl 0x10907
movabsq $0xfffffffffffffff, %rax # imm = 0xFFFFFFFFFFFFFFF
cmpq %rax, -0x38(%rbp)
jle 0x10914
movq $-0x2, -0x8(%rbp)
jmp 0x10a04
jmp 0x107c9
movl -0x2c(%rbp), %eax
andl $0x18, %eax
cmpl $0x0, %eax
je 0x109fc
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jl 0x109fc
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x109fa
movq -0x20(%rbp), %rax
movq -0x60(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rax
movq -0x60(%rbp), %rcx
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %edi
callq 0xfcc0
movq %rax, -0x70(%rbp)
movl -0x68(%rbp), %edi
callq 0xfcc0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movswl 0x2(%rax), %eax
movq -0x78(%rbp), %rcx
movswl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jle 0x109e9
movq -0x78(%rbp), %rax
movswl 0x2(%rax), %eax
cmpl $0x0, %eax
jle 0x109e9
movl -0x68(%rbp), %edx
movq -0x20(%rbp), %rax
movq -0x60(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x64(%rbp), %edx
movq -0x20(%rbp), %rax
movq -0x60(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,4)
cmpq $0x0, -0x60(%rbp)
jle 0x109db
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x109e7
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x109f5
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x1093e
jmp 0x109fc
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)