// File: /workspace/github_c_makefile_star2_O2/neosploit[P]compiler/libfort/lib/fort.c
// Function: utf8ncasecmp
int utf8ncasecmp(const void *src1, const void *src2, size_t n)
{
    utf8_int32_t src1_cp, src2_cp, src1_orig_cp, src2_orig_cp;

    do {
        const unsigned char *const s1 = (const unsigned char *)src1;
        const unsigned char *const s2 = (const unsigned char *)src2;

        // first check that we have enough bytes left in n to contain an entire
        // codepoint
        if (0 == n) {
            return 0;
        }

        if ((1 == n) && ((0xc0 == (0xe0 & *s1)) || (0xc0 == (0xe0 & *s2)))) {
            const utf8_int32_t c1 = (0xe0 & *s1);
            const utf8_int32_t c2 = (0xe0 & *s2);

            if (c1 < c2) {
                return -1;
            } else if (c1 > c2) {
                return 1;
            } else {
                return 0;
            }
        }

        if ((2 >= n) && ((0xe0 == (0xf0 & *s1)) || (0xe0 == (0xf0 & *s2)))) {
            const utf8_int32_t c1 = (0xf0 & *s1);
            const utf8_int32_t c2 = (0xf0 & *s2);

            if (c1 < c2) {
                return -1;
            } else if (c1 > c2) {
                return 1;
            } else {
                return 0;
            }
        }

        if ((3 >= n) && ((0xf0 == (0xf8 & *s1)) || (0xf0 == (0xf8 & *s2)))) {
            const utf8_int32_t c1 = (0xf8 & *s1);
            const utf8_int32_t c2 = (0xf8 & *s2);

            if (c1 < c2) {
                return -1;
            } else if (c1 > c2) {
                return 1;
            } else {
                return 0;
            }
        }

        src1 = utf8codepoint(src1, &src1_cp);
        src2 = utf8codepoint(src2, &src2_cp);
        n -= utf8codepointsize(src1_cp);

        // Take a copy of src1 & src2
        src1_orig_cp = src1_cp;
        src2_orig_cp = src2_cp;

        // Lower srcs if required
        src1_cp = utf8lwrcodepoint(src1_cp);
        src2_cp = utf8lwrcodepoint(src2_cp);

        // Check if the lowered codepoints match
        if ((0 == src1_orig_cp) && (0 == src2_orig_cp)) {
            return 0;
        } else if (src1_cp == src2_cp) {
            continue;
        }

        // If they don't match, then we return which of the original's are less
        if (src1_orig_cp < src2_orig_cp) {
            return -1;
        } else if (src1_orig_cp > src2_orig_cp) {
            return 1;
        }
    } while (0 < n);

    // both utf8 strings matched
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
cmpq $0x1, %rdx
je 0xd95e
testq %rdx, %rdx
je 0xda56
cmpq $0x2, %rdx
ja 0xda2d
movb (%rdi), %al
movb (%r15), %cl
jmp 0xd984
movb (%rdi), %al
movl %eax, %r8d
andb $-0x20, %r8b
movb (%r15), %cl
movl %ecx, %esi
andb $-0x20, %sil
cmpb $-0x40, %r8b
je 0xda62
cmpb $-0x40, %sil
je 0xda5f
movl %eax, %r8d
andb $-0x10, %r8b
movl %ecx, %esi
andb $-0x10, %sil
cmpb $-0x20, %r8b
je 0xda62
cmpb $-0x20, %sil
je 0xda51
andb $-0x8, %al
andb $-0x8, %cl
cmpb $-0x10, %al
je 0xda3f
cmpb $-0x10, %cl
je 0xda3d
movq %rdx, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x30(%rbp), %rsi
callq 0xcebe
movq %rax, %r14
movq %r15, %rdi
leaq -0x34(%rbp), %rsi
callq 0xcebe
movq %rax, %r15
movl -0x30(%rbp), %edi
callq 0xda93
movq %rax, %r12
movl -0x30(%rbp), %ebx
movl -0x34(%rbp), %r13d
movl %ebx, %edi
callq 0xcf8d
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %edi
callq 0xcf8d
movl %eax, -0x34(%rbp)
movl %ebx, %ecx
orl %r13d, %ecx
je 0xda81
cmpl %eax, -0x30(%rbp)
je 0xda1b
cmpl %r13d, %ebx
jl 0xda75
jg 0xda79
movq -0x40(%rbp), %rdx
subq %r12, %rdx
movq %r14, %rdi
jne 0xd93e
jmp 0xda81
cmpq $0x3, %rdx
jne 0xd9bb
movb (%rdi), %al
movb (%r15), %cl
jmp 0xd9a5
movb $-0x10, %cl
xorl %edx, %edx
cmpb %cl, %al
seta %dl
pushq $-0x1
popq %rax
cmovael %edx, %eax
movl %eax, -0x2c(%rbp)
jmp 0xda81
movb $-0x20, %sil
jmp 0xda62
movl $0x0, -0x2c(%rbp)
jmp 0xda81
movb $-0x40, %sil
xorl %eax, %eax
cmpb %sil, %r8b
seta %al
pushq $-0x1
popq %rcx
cmovael %eax, %ecx
movl %ecx, -0x2c(%rbp)
jmp 0xda81
pushq $-0x1
jmp 0xda7b
pushq $0x1
popq %r15
movl %r15d, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq