// File: /workspace/github_c_makefile_star2_O3/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 %rdx, %r14
movq %rsi, %r15
cmpq $0x1, %r14
je 0xde7d
testq %r14, %r14
je 0xdf67
cmpq $0x2, %r14
ja 0xdf3c
movb (%rdi), %al
movb (%r15), %cl
jmp 0xdea0
movb (%rdi), %al
movl %eax, %edx
andb $-0x20, %dl
movb (%r15), %cl
movl %ecx, %esi
andb $-0x20, %sil
cmpb $-0x40, %dl
je 0xdf73
cmpb $-0x40, %sil
je 0xdf70
movl %eax, %edx
andb $-0x10, %dl
movl %ecx, %esi
andb $-0x10, %sil
cmpb $-0x20, %dl
je 0xdf73
cmpb $-0x20, %sil
je 0xdf62
andb $-0x8, %al
andb $-0x8, %cl
cmpb $-0x10, %al
je 0xdf4e
cmpb $-0x10, %cl
je 0xdf4c
movl $0x0, -0x2c(%rbp)
leaq -0x30(%rbp), %rsi
callq 0xd354
movq %rax, -0x40(%rbp)
movq %r15, %rdi
leaq -0x34(%rbp), %rsi
callq 0xd354
movq %rax, %r15
movl -0x30(%rbp), %edi
callq 0xdfaa
movq %rax, %r12
movl -0x30(%rbp), %ebx
movl -0x34(%rbp), %r13d
movl %ebx, %edi
callq 0xd401
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %edi
callq 0xd401
movl %eax, -0x34(%rbp)
movl %ebx, %ecx
orl %r13d, %ecx
je 0xdf86
cmpl %eax, -0x30(%rbp)
je 0xdf2d
cmpl %r13d, %ebx
jl 0xdf98
jg 0xdfa1
subq %r12, %r14
movq -0x40(%rbp), %rdi
jne 0xde5d
jmp 0xdf86
cmpq $0x3, %r14
jne 0xded0
movb (%rdi), %al
movb (%r15), %cl
jmp 0xdebe
movb $-0x10, %cl
xorl %edx, %edx
cmpb %cl, %al
seta %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %edx, %eax
movl %eax, -0x2c(%rbp)
jmp 0xdf86
movb $-0x20, %sil
jmp 0xdf73
movl $0x0, -0x2c(%rbp)
jmp 0xdf86
movb $-0x40, %sil
xorl %eax, %eax
cmpb %sil, %dl
seta %al
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovael %eax, %ecx
movl %ecx, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xdf86
movl $0x1, -0x2c(%rbp)
jmp 0xdf86