// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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, %ebx
movq %rdx, 0x8(%rsp)
movl %esi, %r13d
movq %rdi, %rbp
testl %r13d, %r13d
je 0x3fc97
movzbl (%rbp), %eax
cmpl $0x5a, %eax
jle 0x3fa85
cmpl $0x5b, %eax
je 0x3faa6
cmpl $0x5c, %eax
jne 0x3fbbe
cmpl $0x2, %r13d
jl 0x3fbbe
incq %rbp
decl %r13d
jmp 0x3fbbe
cmpl $0x3f, %eax
jne 0x3fbb5
movl %r13d, %r15d
movq %rbp, %r12
testl %ebx, %ebx
movq 0x8(%rsp), %r13
jne 0x3fc1b
jmp 0x3fc92
movl %ebx, 0x14(%rsp)
leaq 0x1(%rbp), %rax
movb 0x1(%rbp), %cl
addq $0x2, %rbp
xorl %r15d, %r15d
movb %cl, 0x3(%rsp)
cmpb $0x5e, %cl
sete %r15b
cmovneq %rax, %rbp
notl %r15d
addl %r13d, %r15d
xorl %r14d, %r14d
movq %rbp, %r12
movq 0x8(%rsp), %r13
movl $0x1, %ebx
movzbl (%r12), %eax
cmpl $0x5c, %eax
je 0x3fb75
cmpl $0x5d, %eax
je 0x3fc02
testl %r15d, %r15d
je 0x3fbf9
movsbl %al, %edi
cmpb $0x2d, 0x1(%r12)
jne 0x3fb86
cmpl $0x3, %r15d
jl 0x3fb86
movzbl 0x2(%r12), %ecx
cmpb %cl, %al
movl %ecx, %eax
cmovgl %edi, %eax
cmovll %edi, %ecx
movsbl (%r13), %ebp
movsbl %al, %r13d
movsbl %cl, %ebx
cmpl $0x0, 0x4(%rsp)
je 0x3fb4e
movl %ebx, %edi
callq 0x26900
movl %eax, %ebx
movl %r13d, %edi
callq 0x26900
movl %eax, %r13d
movl %ebp, %edi
callq 0x26900
movl %eax, %ebp
movl %r14d, %eax
cmpl %r13d, %ebp
jg 0x3fb5b
movl $0x1, %eax
addq $0x2, %r12
addl $-0x2, %r15d
cmpl %ebx, %ebp
cmovgel %eax, %r14d
movq 0x8(%rsp), %r13
movl $0x1, %ebx
jmp 0x3fbaa
decl %r15d
movb 0x1(%r12), %al
incq %r12
cmpb (%r13), %al
jmp 0x3fba6
cmpl $0x0, 0x4(%rsp)
je 0x3fba2
callq 0x26900
movl %eax, %ebp
movsbl (%r13), %edi
callq 0x26900
cmpl %eax, %ebp
jmp 0x3fba6
cmpb (%r13), %al
cmovel %ebx, %r14d
incq %r12
decl %r15d
jmp 0x3fadd
cmpl $0x2a, %eax
je 0x3fc51
movl %r13d, %r15d
movq %rbp, %r12
movsbl (%rbp), %edi
cmpl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %r13
je 0x3fbee
callq 0x26900
movl %eax, %ebp
movsbl (%r13), %edi
callq 0x26900
cmpl %eax, %ebp
je 0x3fc1b
jmp 0x3fc92
cmpb (%r13), %dil
je 0x3fc1b
jmp 0x3fc92
decq %r12
movl $0x1, %r15d
xorl %eax, %eax
testl %r14d, %r14d
sete %al
cmpb $0x5e, 0x3(%rsp)
cmovnel %r14d, %eax
testl %eax, %eax
movl 0x14(%rsp), %ebx
je 0x3fc92
incq %r13
movq %r13, 0x8(%rsp)
leaq 0x1(%r12), %rbp
leal -0x1(%r15), %r13d
decl %ebx
jne 0x3fa50
cmpb $0x2a, (%rbp)
jne 0x3fc9a
xorl %r13d, %r13d
cmpb $0x2a, 0x2(%r12,%r13)
leaq 0x1(%r13), %r13
je 0x3fc3d
notl %r13d
addl %r15d, %r13d
jmp 0x3fc9a
decl %r13d
cmpb $0x2a, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
je 0x3fc51
movl $0x1, %r15d
testl %r13d, %r13d
je 0x3fca4
testl %ebx, %ebx
je 0x3fc92
movq 0x8(%rsp), %r14
movq %rbp, %rdi
movl %r13d, %esi
movq %r14, %rdx
movl %ebx, %ecx
movl 0x4(%rsp), %r8d
callq 0x3fa30
testl %eax, %eax
jne 0x3fca4
incq %r14
decl %ebx
jne 0x3fc72
xorl %r15d, %r15d
jmp 0x3fca4
movl %ebx, %r13d
xorl %r15d, %r15d
testl %r13d, %r13d
sete %r15b
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq