// File: /workspace/github_c_makefile_star2_O2/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, %r14d
movq %rdx, 0x8(%rsp)
movl %esi, %r12d
movq %rdi, %r13
testl %r12d, %r12d
je 0x394ed
movzbl (%r13), %eax
cmpl $0x3f, %eax
je 0x393f5
cmpl $0x5b, %eax
je 0x392f0
cmpl $0x5c, %eax
je 0x3940a
cmpl $0x2a, %eax
jne 0x39416
jmp 0x3949a
movl %r14d, 0x14(%rsp)
leaq 0x1(%r13), %rax
movb 0x1(%r13), %cl
addq $0x2, %r13
xorl %ebx, %ebx
movb %cl, 0x3(%rsp)
cmpb $0x5e, %cl
sete %bl
cmovneq %rax, %r13
notl %ebx
addl %r12d, %ebx
xorl %r14d, %r14d
movq %r13, %r15
movq 0x8(%rsp), %r12
pushq $0x1
popq %r13
movzbl (%r15), %eax
cmpl $0x5c, %eax
je 0x393b8
cmpl $0x5d, %eax
je 0x39458
testl %ebx, %ebx
je 0x39452
movsbl %al, %edi
cmpb $0x2d, 0x1(%r15)
jne 0x393c7
cmpl $0x3, %ebx
jl 0x393c7
movzbl 0x2(%r15), %ecx
cmpb %cl, %al
movl %ecx, %eax
cmovgl %edi, %eax
cmovll %edi, %ecx
movsbl (%r12), %ebp
movsbl %al, %r13d
movsbl %cl, %r12d
cmpl $0x0, 0x4(%rsp)
je 0x39394
movl %r12d, %edi
callq 0x26900
movl %eax, %r12d
movl %r13d, %edi
callq 0x26900
movl %eax, %r13d
movl %ebp, %edi
callq 0x26900
movl %eax, %ebp
movl %r14d, %eax
cmpl %r13d, %ebp
pushq $0x1
popq %r13
jg 0x393a3
movl %r13d, %eax
addq $0x2, %r15
addl $-0x2, %ebx
cmpl %r12d, %ebp
cmovgel %eax, %r14d
movq 0x8(%rsp), %r12
jmp 0x393eb
decl %ebx
movb 0x1(%r15), %al
incq %r15
cmpb (%r12), %al
jmp 0x393e7
cmpl $0x0, 0x4(%rsp)
je 0x393e3
callq 0x26900
movl %eax, %ebp
movsbl (%r12), %edi
callq 0x26900
cmpl %eax, %ebp
jmp 0x393e7
cmpb (%r12), %al
cmovel %r13d, %r14d
incq %r15
decl %ebx
jmp 0x39325
movl %r12d, %ebx
movq %r13, %r15
testl %r14d, %r14d
movq 0x8(%rsp), %r12
jne 0x39472
jmp 0x394e4
cmpl $0x2, %r12d
jl 0x39416
incq %r13
decl %r12d
movl %r12d, %ebx
movq %r13, %r15
movsbl (%r13), %edi
cmpl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %r12
je 0x39447
callq 0x26900
movl %eax, %ebp
movsbl (%r12), %edi
callq 0x26900
cmpl %eax, %ebp
je 0x39472
jmp 0x394e4
cmpb (%r12), %dil
je 0x39472
jmp 0x394e4
decq %r15
movl %r13d, %ebx
xorl %eax, %eax
testl %r14d, %r14d
sete %al
cmpb $0x5e, 0x3(%rsp)
cmovnel %r14d, %eax
testl %eax, %eax
movl 0x14(%rsp), %r14d
je 0x394e4
incq %r12
movq %r12, 0x8(%rsp)
leaq 0x1(%r15), %r13
leal -0x1(%rbx), %r12d
decl %r14d
jne 0x392bd
pushq $0x1
popq %rax
cmpb $0x2a, (%r15,%rax)
jne 0x394e8
incq %rax
jmp 0x3948e
decl %r12d
cmpb $0x2a, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0x3949a
pushq $0x1
popq %rbx
testl %r12d, %r12d
je 0x394f5
movl %r14d, %ebp
subl $0x1, %ebp
jb 0x394e4
movq %r13, %rdi
movl %r12d, %esi
movl %r14d, %ecx
movq 0x8(%rsp), %r14
movq %r14, %rdx
movl 0x4(%rsp), %r8d
callq 0x3929c
testl %eax, %eax
jne 0x394f5
incq %r14
movq %r14, 0x8(%rsp)
movl %ebp, %r14d
jmp 0x394b3
xorl %ebx, %ebx
jmp 0x394f5
subl %eax, %ebx
movl %ebx, %r14d
xorl %ebx, %ebx
testl %r14d, %r14d
sete %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq