// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/src/lib/utf8proc.c
// Function: utf8proc_decompose_char
UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, utf8proc_option_t options, int *last_boundclass) {
  const utf8proc_property_t *property;
  utf8proc_propval_t category;
  utf8proc_int32_t hangul_sindex;
  if (uc < 0 || uc >= 0x110000) return UTF8PROC_ERROR_NOTASSIGNED;
  property = unsafe_get_property(uc);
  category = property->category;
  hangul_sindex = uc - UTF8PROC_HANGUL_SBASE;
  if (options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) {
    if (hangul_sindex >= 0 && hangul_sindex < UTF8PROC_HANGUL_SCOUNT) {
      utf8proc_int32_t hangul_tindex;
      if (bufsize >= 1) {
        dst[0] = UTF8PROC_HANGUL_LBASE +
          hangul_sindex / UTF8PROC_HANGUL_NCOUNT;
        if (bufsize >= 2) dst[1] = UTF8PROC_HANGUL_VBASE +
          (hangul_sindex % UTF8PROC_HANGUL_NCOUNT) / UTF8PROC_HANGUL_TCOUNT;
      }
      hangul_tindex = hangul_sindex % UTF8PROC_HANGUL_TCOUNT;
      if (!hangul_tindex) return 2;
      if (bufsize >= 3) dst[2] = UTF8PROC_HANGUL_TBASE + hangul_tindex;
      return 3;
    }
  }
  if (options & UTF8PROC_REJECTNA) {
    if (!category) return UTF8PROC_ERROR_NOTASSIGNED;
  }
  if (options & UTF8PROC_IGNORE) {
    if (property->ignorable) return 0;
  }
  if (options & UTF8PROC_LUMP) {
    if (category == UTF8PROC_CATEGORY_ZS) utf8proc_decompose_lump(0x0020);
    if (uc == 0x2018 || uc == 0x2019 || uc == 0x02BC || uc == 0x02C8)
      utf8proc_decompose_lump(0x0027);
    if (category == UTF8PROC_CATEGORY_PD || uc == 0x2212)
      utf8proc_decompose_lump(0x002D);
    if (uc == 0x2044 || uc == 0x2215) utf8proc_decompose_lump(0x002F);
    if (uc == 0x2236) utf8proc_decompose_lump(0x003A);
    if (uc == 0x2039 || uc == 0x2329 || uc == 0x3008)
      utf8proc_decompose_lump(0x003C);
    if (uc == 0x203A || uc == 0x232A || uc == 0x3009)
      utf8proc_decompose_lump(0x003E);
    if (uc == 0x2216) utf8proc_decompose_lump(0x005C);
    if (uc == 0x02C4 || uc == 0x02C6 || uc == 0x2038 || uc == 0x2303)
      utf8proc_decompose_lump(0x005E);
    if (category == UTF8PROC_CATEGORY_PC || uc == 0x02CD)
      utf8proc_decompose_lump(0x005F);
    if (uc == 0x02CB) utf8proc_decompose_lump(0x0060);
    if (uc == 0x2223) utf8proc_decompose_lump(0x007C);
    if (uc == 0x223C) utf8proc_decompose_lump(0x007E);
    if ((options & UTF8PROC_NLF2LS) && (options & UTF8PROC_NLF2PS)) {
      if (category == UTF8PROC_CATEGORY_ZL ||
          category == UTF8PROC_CATEGORY_ZP)
        utf8proc_decompose_lump(0x000A);
    }
  }
  if (options & UTF8PROC_STRIPMARK) {
    if (category == UTF8PROC_CATEGORY_MN ||
      category == UTF8PROC_CATEGORY_MC ||
      category == UTF8PROC_CATEGORY_ME) return 0;
  }
  if (options & UTF8PROC_CASEFOLD) {
    if (property->casefold_mapping != UINT16_MAX) {
      const utf8proc_int32_t *casefold_entry;
      utf8proc_ssize_t written = 0;
      for (casefold_entry = &utf8proc_sequences[property->casefold_mapping];
          *casefold_entry >= 0; casefold_entry++) {
        written += utf8proc_decompose_char(*casefold_entry, dst+written,
          (bufsize > written) ? (bufsize - written) : 0, options,
          last_boundclass);
        if (written < 0) return UTF8PROC_ERROR_OVERFLOW;
      }
      return written;
    }
  }
  if (options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) {
    if (property->decomp_mapping != UINT16_MAX &&
        (!property->decomp_type || (options & UTF8PROC_COMPAT))) {
      const utf8proc_int32_t *decomp_entry;
      utf8proc_ssize_t written = 0;
      for (decomp_entry = &utf8proc_sequences[property->decomp_mapping];
          *decomp_entry >= 0; decomp_entry++) {
        written += utf8proc_decompose_char(*decomp_entry, dst+written,
          (bufsize > written) ? (bufsize - written) : 0, options,
        last_boundclass);
        if (written < 0) return UTF8PROC_ERROR_OVERFLOW;
      }
      return written;
    }
  }
  if (options & UTF8PROC_CHARBOUND) {
    utf8proc_bool boundary;
    int tbc = property->boundclass;
    boundary = grapheme_break(*last_boundclass, tbc);
    *last_boundclass = tbc;
    if (boundary) {
      if (bufsize >= 1) dst[0] = 0xFFFF;
      if (bufsize >= 2) dst[1] = uc;
      return 2;
    }
  }
  if (bufsize >= 1) *dst = uc;
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, (%rsp)
movl %ecx, %ebx
andl $0xffffefff, %ebx       # imm = 0xFFFFEFFF
pushq $-0x4
popq %r12
pushq $0x20
popq %r15
pushq $0x27
popq %r14
cmpl $0x10ffff, %edi         # imm = 0x10FFFF
ja 0x7bd8
movl %ecx, %ebp
movl %edi, %r13d
callq 0x765f
leal -0xac00(%r13), %ecx
testb $0x18, %bpl
setne %dl
cmpl $0x2ba4, %ecx           # imm = 0x2BA4
setb %sil
andb %dl, %sil
cmpb $0x1, %sil
je 0x7a03
movzwl (%rax), %edx
testb $0x40, %bpl
sete %cl
testw %dx, %dx
setne %sil
orb %cl, %sil
cmpb $0x1, %sil
jne 0x7bd8
testb $0x20, %bpl
je 0x782e
testb $0x4, 0x20(%rax)
jne 0x79fb
btl $0xc, %ebp
jae 0x79e8
movl %r15d, %edi
movl %ebx, %ecx
cmpw $0x17, %dx
je 0x77c5
movl %r13d, %esi
andl $0x1ffffe, %esi         # imm = 0x1FFFFE
movl %r14d, %edi
movl %ebx, %ecx
cmpl $0x2018, %esi           # imm = 0x2018
je 0x77c5
movl %r14d, %edi
movl %ebx, %ecx
cmpl $0x2bc, %r13d           # imm = 0x2BC
je 0x77c5
movl %r14d, %edi
movl %ebx, %ecx
cmpl $0x2c8, %r13d           # imm = 0x2C8
je 0x77c5
cmpw $0xd, %dx
sete %cl
cmpl $0x2212, %r13d          # imm = 0x2212
sete %sil
orb %cl, %sil
pushq $0x2d
popq %rdi
movl %ebx, %ecx
jne 0x77c5
cmpl $0x2039, %r13d          # imm = 0x2039
je 0x7918
cmpl $0x203a, %r13d          # imm = 0x203A
je 0x7922
pushq $0x2f
popq %rdi
movl %ebx, %ecx
cmpl $0x2044, %r13d          # imm = 0x2044
je 0x77c5
movl %ebx, %ecx
cmpl $0x2215, %r13d          # imm = 0x2215
je 0x77c5
cmpl $0x2216, %r13d          # imm = 0x2216
je 0x79b2
cmpl $0x3009, %r13d          # imm = 0x3009
je 0x7922
cmpl $0x2329, %r13d          # imm = 0x2329
je 0x7918
cmpl $0x232a, %r13d          # imm = 0x232A
je 0x7922
cmpl $0x3008, %r13d          # imm = 0x3008
je 0x7918
cmpl $0x2236, %r13d          # imm = 0x2236
jne 0x792c
pushq $0x3a
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
pushq $0x3c
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
pushq $0x3e
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
movl %r13d, %esi
andl $0x1ffffd, %esi         # imm = 0x1FFFFD
pushq $0x5e
popq %rdi
movl %ebx, %ecx
cmpl $0x2c4, %esi            # imm = 0x2C4
je 0x77c5
movl %ebx, %ecx
cmpl $0x2038, %r13d          # imm = 0x2038
je 0x77c5
movl %ebx, %ecx
cmpl $0x2303, %r13d          # imm = 0x2303
je 0x77c5
cmpw $0xc, %dx
sete %cl
cmpl $0x2cd, %r13d           # imm = 0x2CD
sete %sil
orb %cl, %sil
pushq $0x5f
popq %rdi
movl %ebx, %ecx
jne 0x77c5
pushq $0x60
popq %rdi
movl %ebx, %ecx
cmpl $0x2cb, %r13d           # imm = 0x2CB
je 0x77c5
cmpl $0x223c, %r13d          # imm = 0x223C
je 0x79bc
cmpl $0x2223, %r13d          # imm = 0x2223
jne 0x79c6
pushq $0x7c
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
pushq $0x5c
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
pushq $0x7e
popq %rdi
movl %ebx, %ecx
jmp 0x77c5
movl %ebp, %ecx
notl %ecx
testw $0x180, %cx             # imm = 0x180
jne 0x79e8
movl %edx, %esi
andl $0xfffe, %esi           # imm = 0xFFFE
pushq $0xa
popq %rdi
movl %ebx, %ecx
cmpw $0x18, %si
je 0x77c5
movl %ebp, %ecx
shrl $0xd, %ecx
addl $-0x6, %edx
cmpw $0x3, %dx
setb %dl
testb %dl, %cl
je 0x7a50
xorl %r12d, %r12d
jmp 0x7bd8
movq 0x8(%rsp), %r8
testq %r8, %r8
movq (%rsp), %rdi
jle 0x7b47
movw $0x24c, %si             # imm = 0x24C
movl %ecx, %eax
xorl %edx, %edx
divw %si
orl $0x1100, %eax           # imm = 0x1100
movzwl %ax, %eax
movl %eax, (%rdi)
movw $0x1c, %si
cmpq $0x1, %r8
jne 0x7b35
movl %ecx, %eax
xorl %edx, %edx
divw %si
cmpw $0x1, %dx
pushq $0x3
popq %r12
sbbq $0x0, %r12
jmp 0x7bd8
btl $0xa, %ebp
jae 0x7ab7
movzwl 0xa(%rax), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
je 0x7ab7
leaq 0x904b6(%rip), %rax     # 0x97f20
leaq (%rax,%rcx,4), %rbx
xorl %r14d, %r14d
pushq $-0x2
popq %r15
xorl %r12d, %r12d
movq (%rsp), %r13
movl (%rbx), %edi
testl %edi, %edi
js 0x7bd8
leaq (,%r12,4), %rsi
addq %r13, %rsi
movq 0x8(%rsp), %rdx
subq %r12, %rdx
cmovleq %r14, %rdx
movl %ebp, %ecx
movq 0x10(%rsp), %r8
callq 0x7795
addq $0x4, %rbx
addq %rax, %r12
jns 0x7a7c
jmp 0x7bd5
testb $0x18, %bpl
je 0x7adf
movzwl 0x8(%rax), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
je 0x7adf
testb $0x4, %bpl
jne 0x7b8a
cmpw $0x0, 0x6(%rax)
je 0x7b8a
btl $0xb, %ebp
jae 0x7b75
movl 0x20(%rax), %ebp
shrl $0x4, %ebp
andl $0xf, %ebp
movq 0x10(%rsp), %rbx
movl (%rbx), %edi
movl %ebp, %esi
callq 0x76bd
movl %ebp, (%rbx)
testb %al, %al
je 0x7b75
pushq $0x2
popq %r12
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jle 0x7bd8
movq (%rsp), %rax
movl $0xffff, (%rax)         # imm = 0xFFFF
cmpq $0x1, %rcx
je 0x7bd8
movl %r13d, 0x4(%rax)
jmp 0x7bd8
movl %edx, %eax
xorl %edx, %edx
divw %si
addl $0x1161, %eax           # imm = 0x1161
movzwl %ax, %eax
movl %eax, 0x4(%rdi)
movw $0x1c, %si
movl %ecx, %eax
xorl %edx, %edx
divw %si
testw %dx, %dx
je 0x7b6f
pushq $0x3
popq %r12
cmpq $0x3, %r8
jl 0x7bd8
addl $0x11a7, %edx           # imm = 0x11A7
movzwl %dx, %eax
movl %eax, 0x8(%rdi)
jmp 0x7bd8
pushq $0x2
popq %r12
jmp 0x7bd8
pushq $0x1
popq %r12
cmpq $0x0, 0x8(%rsp)
jle 0x7bd8
movq (%rsp), %rax
movl %r13d, (%rax)
jmp 0x7bd8
leaq 0x9038f(%rip), %rax     # 0x97f20
leaq (%rax,%rcx,4), %rbx
xorl %r14d, %r14d
pushq $-0x2
popq %r15
xorl %r12d, %r12d
movq (%rsp), %r13
movl (%rbx), %edi
testl %edi, %edi
js 0x7bd8
leaq (,%r12,4), %rsi
addq %r13, %rsi
movq 0x8(%rsp), %rdx
subq %r12, %rdx
cmovleq %r14, %rdx
movl %ebp, %ecx
movq 0x10(%rsp), %r8
callq 0x7795
addq $0x4, %rbx
addq %rax, %r12
jns 0x7ba3
movq %r15, %r12
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq