// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/util.c
// Function: stringmatchlen
int stringmatchlen(const char *pattern, int patternLen,
        const char *string, int stringLen, int nocase)
{
    while(patternLen) {
        switch(pattern[0]) {
        case '*':
            while (pattern[1] == '*') {
                pattern++;
                patternLen--;
            }
            if (patternLen == 1)
                return 1; /* match */
            while(stringLen) {
                if (stringmatchlen(pattern+1, patternLen-1,
                            string, stringLen, nocase))
                    return 1; /* match */
                string++;
                stringLen--;
            }
            return 0; /* no match */
            break;
        case '?':
            if (stringLen == 0)
                return 0; /* no match */
            string++;
            stringLen--;
            break;
        case '[':
        {
            int not, match;

            pattern++;
            patternLen--;
            not = pattern[0] == '^';
            if (not) {
                pattern++;
                patternLen--;
            }
            match = 0;
            while(1) {
                if (pattern[0] == '\\') {
                    pattern++;
                    patternLen--;
                    if (pattern[0] == string[0])
                        match = 1;
                } else if (pattern[0] == ']') {
                    break;
                } else if (patternLen == 0) {
                    pattern--;
                    patternLen++;
                    break;
                } else if (pattern[1] == '-' && patternLen >= 3) {
                    int start = pattern[0];
                    int end = pattern[2];
                    int c = string[0];
                    if (start > end) {
                        int t = start;
                        start = end;
                        end = t;
                    }
                    if (nocase) {
                        start = tolower(start);
                        end = tolower(end);
                        c = tolower(c);
                    }
                    pattern += 2;
                    patternLen -= 2;
                    if (c >= start && c <= end)
                        match = 1;
                } else {
                    if (!nocase) {
                        if (pattern[0] == string[0])
                            match = 1;
                    } else {
                        if (tolower((int)pattern[0]) == tolower((int)string[0]))
                            match = 1;
                    }
                }
                pattern++;
                patternLen--;
            }
            if (not)
                match = !match;
            if (!match)
                return 0; /* no match */
            string++;
            stringLen--;
            break;
        }
        case '\\':
            if (patternLen >= 2) {
                pattern++;
                patternLen--;
            }
            /* fall through */
        default:
            if (!nocase) {
                if (pattern[0] != string[0])
                    return 0; /* no match */
            } else {
                if (tolower((int)pattern[0]) != tolower((int)string[0]))
                    return 0; /* no match */
            }
            string++;
            stringLen--;
            break;
        }
        pattern++;
        patternLen--;
        if (stringLen == 0) {
            while(*pattern == '*') {
                pattern++;
                patternLen--;
            }
            break;
        }
    }
    if (patternLen == 0 && stringLen == 0)
        return 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0x4(%rsp)
movl %ecx, %ebp
movq %rdx, 0x8(%rsp)
movl %esi, %r13d
movq %rdi, %rbx
testl %r13d, %r13d
je 0x25061
movzbl (%rbx), %eax
cmpl $0x5a, %eax
jle 0x24e44
cmpl $0x5b, %eax
je 0x24e67
cmpl $0x5c, %eax
jne 0x24f7f
cmpl $0x2, %r13d
jl 0x24f7f
incq %rbx
decl %r13d
jmp 0x24f7f
cmpl $0x3f, %eax
jne 0x24f76
testl %ebp, %ebp
je 0x2505c
incq 0x8(%rsp)
decl %ebp
movl %r13d, %r15d
movq %rbx, %r12
jmp 0x24fee
movl %ebp, 0x14(%rsp)
leaq 0x1(%rbx), %rax
movb 0x1(%rbx), %cl
addq $0x2, %rbx
xorl %r15d, %r15d
movb %cl, 0x3(%rsp)
cmpb $0x5e, %cl
sete %r15b
cmovneq %rax, %rbx
notl %r15d
addl %r13d, %r15d
xorl %r14d, %r14d
movq %rbx, %r12
movq 0x8(%rsp), %r13
movl $0x1, %ebp
movzbl (%r12), %eax
cmpl $0x5c, %eax
je 0x24f36
cmpl $0x5d, %eax
je 0x24fcb
testl %r15d, %r15d
je 0x24fc2
movsbl %al, %edi
cmpb $0x2d, 0x1(%r12)
jne 0x24f47
cmpl $0x3, %r15d
jl 0x24f47
movzbl 0x2(%r12), %ecx
cmpb %cl, %al
movl %ecx, %eax
cmovgl %edi, %eax
cmovll %edi, %ecx
movsbl (%r13), %ebx
movsbl %al, %r13d
movsbl %cl, %ebp
cmpl $0x0, 0x4(%rsp)
je 0x24f0f
movl %ebp, %edi
callq 0x125b0
movl %eax, %ebp
movl %r13d, %edi
callq 0x125b0
movl %eax, %r13d
movl %ebx, %edi
callq 0x125b0
movl %eax, %ebx
movl %r14d, %eax
cmpl %r13d, %ebx
jg 0x24f1c
movl $0x1, %eax
addq $0x2, %r12
addl $-0x2, %r15d
cmpl %ebp, %ebx
cmovgel %eax, %r14d
movq 0x8(%rsp), %r13
movl $0x1, %ebp
jmp 0x24f6b
decl %r15d
movb 0x1(%r12), %al
incq %r12
cmpb (%r13), %al
jmp 0x24f67
cmpl $0x0, 0x4(%rsp)
je 0x24f63
callq 0x125b0
movl %eax, %ebx
movsbl (%r13), %edi
callq 0x125b0
cmpl %eax, %ebx
jmp 0x24f67
cmpb (%r13), %al
cmovel %ebp, %r14d
incq %r12
decl %r15d
jmp 0x24e9e
cmpl $0x2a, %eax
je 0x2501b
movl %r13d, %r15d
movq %rbx, %r12
movsbl (%rbx), %edi
cmpl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %r14
je 0x24fad
callq 0x125b0
movl %eax, %ebx
movsbl (%r14), %edi
callq 0x125b0
cmpl %eax, %ebx
je 0x24fb6
jmp 0x2505c
cmpb (%r14), %dil
jne 0x2505c
incq %r14
movq %r14, 0x8(%rsp)
decl %ebp
jmp 0x24fee
decq %r12
movl $0x1, %r15d
cmpb $0x5e, 0x3(%rsp)
sete %cl
testl %r14d, %r14d
setne %al
xorb %cl, %al
je 0x2505c
movzbl %al, %eax
movl 0x14(%rsp), %ebp
subl %eax, %ebp
addq %rax, %r13
movq %r13, 0x8(%rsp)
leaq 0x1(%r12), %rbx
leal -0x1(%r15), %r13d
testl %ebp, %ebp
jne 0x24e10
cmpb $0x2a, (%rbx)
jne 0x25064
xorl %r13d, %r13d
cmpb $0x2a, 0x2(%r12,%r13)
leaq 0x1(%r13), %r13
je 0x25007
notl %r13d
addl %r15d, %r13d
jmp 0x25064
decl %r13d
cmpb $0x2a, 0x1(%rbx)
leaq 0x1(%rbx), %rbx
je 0x2501b
movl $0x1, %r15d
testl %r13d, %r13d
je 0x2506e
testl %ebp, %ebp
je 0x2505c
movq 0x8(%rsp), %r14
movq %rbx, %rdi
movl %r13d, %esi
movq %r14, %rdx
movl %ebp, %ecx
movl 0x4(%rsp), %r8d
callq 0x24df0
testl %eax, %eax
jne 0x2506e
incq %r14
decl %ebp
jne 0x2503c
xorl %r15d, %r15d
jmp 0x2506e
xorl %r13d, %r13d
xorl %r15d, %r15d
orl %r13d, %ebp
sete %r15b
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq