// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rsi, %r15
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %r13, %r13
je 0xe026
cmpq $0x1, %r13
jne 0xe005
movb (%rdi), %al
andb $-0x20, %al
cmpb $-0x40, %al
je 0xdfed
movb (%r15), %cl
andb $-0x20, %cl
cmpb $-0x40, %cl
jne 0xe005
movb (%r15), %cl
andb $-0x20, %cl
xorl %ebx, %ebx
cmpb %cl, %al
seta %bl
cmovbl %edx, %ebx
movl $0x1, %r13d
jmp 0xe058
cmpq $0x2, %r13
ja 0xe02f
movb (%rdi), %al
andb $-0x10, %al
cmpb $-0x20, %al
je 0xe01e
movb (%r15), %cl
andb $-0x10, %cl
cmpb $-0x20, %cl
jne 0xe02f
movb (%r15), %cl
andb $-0x10, %cl
jmp 0xe04e
movl $0x1, %ecx
xorl %ebx, %ebx
jmp 0xe05d
cmpq $0x3, %r13
ja 0xe078
movb (%rdi), %al
andb $-0x8, %al
cmpb $-0x10, %al
je 0xe048
movb (%r15), %cl
andb $-0x8, %cl
cmpb $-0x10, %cl
jne 0xe078
movb (%r15), %cl
andb $-0x8, %cl
xorl %ebx, %ebx
cmpb %cl, %al
seta %bl
cmovbl %edx, %ebx
movl $0x1, %ecx
cmpl $0x3, %ecx
je 0xe06a
testl %ecx, %ecx
jne 0xe118
testq %r13, %r13
jne 0xdfcf
jmp 0xe116
leaq -0x2c(%rbp), %rsi
callq 0xd49c
movq %rax, -0x38(%rbp)
movq %r15, %rdi
leaq -0x30(%rbp), %rsi
callq 0xd49c
movq %rax, %r15
movl -0x2c(%rbp), %edi
callq 0xe129
subq %rax, %r13
movl -0x2c(%rbp), %r14d
movl -0x30(%rbp), %r12d
movl %r14d, %edi
callq 0xd549
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %edi
callq 0xd549
movl %eax, -0x30(%rbp)
movl %r14d, %ecx
orl %r12d, %ecx
jne 0xe0ce
movl $0x1, %ecx
xorl %ebx, %ebx
jmp 0xe0d8
movl $0x3, %ecx
cmpl %eax, -0x2c(%rbp)
jne 0xe0e6
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rdi
jmp 0xe05d
cmpl %r12d, %r14d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rdi
jge 0xe103
movl $0x1, %ecx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0xe05d
setg %al
movzbl %al, %ecx
movl $0x1, %eax
cmovgl %eax, %ebx
jmp 0xe05d
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq