// File: /workspace/github_c_makefile_star2_O1/msteveb[P]autosetup/./jimsh0.c
// Function: JimCharsetMatch
static const char *JimCharsetMatch(const char *pattern, int plen, int c, int flags)
{
    int not = 0;
    int pchar;
    int match = 0;
    int nocase = 0;
    int n;

    if (flags & JIM_NOCASE) {
        nocase++;
        c = utf8_upper(c);
    }

    if (flags & JIM_CHARSET_SCAN) {
        if (*pattern == '^') {
            not++;
            pattern++;
            plen--;
        }


        if (*pattern == ']') {
            goto first;
        }
    }

    while (plen && *pattern != ']') {

        if (pattern[0] == '\\') {
first:
            n = utf8_tounicode_case(pattern, &pchar, nocase);
            pattern += n;
            plen -= n;
        }
        else {

            int start;
            int end;

            n = utf8_tounicode_case(pattern, &start, nocase);
            pattern += n;
            plen -= n;
            if (pattern[0] == '-' && plen > 1) {

                n = 1 + utf8_tounicode_case(pattern + 1, &end, nocase);
                pattern += n;
                plen -= n;


                if ((c >= start && c <= end) || (c >= end && c <= start)) {
                    match = 1;
                }
                continue;
            }
            pchar = start;
        }

        if (pchar == c) {
            match = 1;
        }
    }
    if (not) {
        match = !match;
    }

    return match ? pattern : NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %rbx
movl %ecx, -0x34(%rbp)
testb $0x1, %cl
je 0x17e33
movl %r12d, %edi
callq 0x60e0
movl %eax, %r12d
testb $0x2, -0x34(%rbp)
jne 0x17e4a
movq $0x0, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x17e8c
xorl %eax, %eax
cmpb $0x5e, (%rbx)
sete %al
subl %eax, %r15d
movl $0x0, -0x2c(%rbp)
cmpb $0x5d, (%rbx,%rax)
movq %rax, -0x40(%rbp)
leaq (%rbx,%rax), %rbx
jne 0x17e8c
movzbl (%rbx), %eax
movl %eax, -0x30(%rbp)
testb $0x1, -0x34(%rbp)
je 0x17e81
movl -0x30(%rbp), %edi
callq 0x60e0
movl %eax, -0x30(%rbp)
incq %rbx
decl %r15d
jmp 0x17f26
testl %r15d, %r15d
je 0x17f3d
movzbl (%rbx), %r13d
cmpl $0x5d, %r13d
je 0x17f3d
cmpl $0x5c, %r13d
je 0x17e6a
testb $0x1, -0x34(%rbp)
je 0x17eba
movl %r13d, %edi
callq 0x60e0
movl %eax, %r13d
cmpb $0x2d, 0x1(%rbx)
setne %al
cmpl $0x3, %r15d
setl %r14b
orb %al, %r14b
je 0x17eda
incq %rbx
decl %r15d
movl %r13d, -0x30(%rbp)
jmp 0x17f1d
movzbl 0x2(%rbx), %eax
testb $0x1, -0x34(%rbp)
je 0x17eeb
movl %eax, %edi
callq 0x60e0
addq $0x3, %rbx
addl $-0x3, %r15d
cmpl %r13d, %r12d
setl %cl
cmpl %eax, %r12d
setg %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x17f16
cmpl %eax, %r12d
setl %al
cmpl %r13d, %r12d
setg %cl
orb %al, %cl
jne 0x17f1d
movl $0x1, -0x2c(%rbp)
testb %r14b, %r14b
je 0x17e8c
cmpl %r12d, -0x30(%rbp)
movl $0x1, %eax
movl -0x2c(%rbp), %ecx
cmovel %eax, %ecx
movl %ecx, -0x2c(%rbp)
jmp 0x17e8c
xorl %eax, %eax
movl -0x2c(%rbp), %ecx
testl %ecx, %ecx
sete %al
cmpl $0x0, -0x40(%rbp)
cmovel %ecx, %eax
xorl %ecx, %ecx
testl %eax, %eax
cmoveq %rcx, %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq