// File: /workspace/github_c_makefile_star2_O1/s3lase[P]v6shell/osh.c
// Function: glob2
static bool
glob2(const UChar *ename, const UChar *pattern)
{
	int cok, rok;		/* `[...]' - cok (class), rok (range) */
	UChar c, ec, pc;
	const UChar *e, *n, *p;

	e = ename;
	p = pattern;

	ec = *e++;
	switch (pc = *p++) {
	case EOS:
		return ec == EOS;

	case ASTERISK:
		/*
		 * Ignore all but the last `*' in a group of consecutive
		 * `*' characters to avoid unnecessary glob2() recursion.
		 */
		while (*p++ == ASTERISK)
			;	/* nothing */
		if (*--p == EOS)
			return true;
		e--;
		while (*e != EOS)
			if (glob2(e++, p))
				return true;
		break;

	case QUESTION:
		if (ec != EOS)
			return glob2(e, p);
		break;

	case LBRACKET:
		if (*p == EOS)
			break;
		for (c = UCHAR(EOS), cok = rok = 0, n = p + 1; ; ) {
			pc = *p++;
			if (pc == RBRACKET && p > n) {
				if (cok > 0 || rok > 0)
					return glob2(e, p);
				break;
			}
			if (*p == EOS)
				break;
			if (pc == HYPHEN && c != EOS && *p != RBRACKET) {
				if ((pc = *p++) == BQUOT)
					pc = *p++;
				if (*p == EOS)
					break;
				if (c <= ec && ec <= pc)
					rok++;
				else if (c == ec)
					cok--;
				c = UCHAR(EOS);
			} else {
				if (pc == BQUOT) {
					pc = *p++;
					if (*p == EOS)
						break;
				}
				c = pc;
				if (ec == c)
					cok++;
			}
		}
		break;

	case BQUOT:
		if (*p != EOS)
			pc = *p++;
		/*FALLTHROUGH*/

	default:
		if (pc == ec)
			return glob2(e, p);
	}
	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x1(%rdi), %rax
movb (%rdi), %cl
leaq 0x1(%rbx), %rdx
movb (%rbx), %sil
movzbl %sil, %r8d
cmpl $0x5a, %r8d
jle 0x5fee
cmpl $0x5b, %r8d
je 0x6007
cmpl $0x5c, %r8d
jne 0x6102
movzbl 0x1(%rbx), %esi
addq $0x2, %rbx
testb %sil, %sil
cmovnel %esi, %r8d
cmovneq %rbx, %rdx
movl %r8d, %esi
jmp 0x6102
cmpl $0x3f, %r8d
jne 0x60f7
movq %rax, %rdi
movq %rdx, %rbx
testb %cl, %cl
jne 0x5fac
jmp 0x6111
xorl %ebp, %ebp
cmpb $0x0, (%rdx)
je 0x6113
leaq 0x2(%rbx), %r10
movb 0x1(%rbx), %r9b
movl $0x1, %esi
movl $0x2, %r8d
xorl %edi, %edi
xorl %edx, %edx
movb (%r10), %r10b
testb %r10b, %r10b
je 0x6111
cmpb $0x2d, %r9b
setne %r11b
testb %dil, %dil
sete %r14b
cmpb $0x5d, %r10b
sete %r15b
orb %r11b, %r14b
orb %r15b, %r14b
je 0x6082
cmpb $0x5c, %r9b
jne 0x606f
cmpb $0x0, 0x2(%rbx,%rsi)
je 0x6111
addq $0x2, %rsi
movl %r10d, %r9d
movq %rsi, %r8
xorl %esi, %esi
cmpb %r9b, %cl
sete %sil
addl %esi, %ebp
movl %r9d, %edi
movq %r8, %rsi
jmp 0x60ba
cmpb $0x5c, %r10b
jne 0x6093
movb 0x2(%rbx,%rsi), %r10b
addq $0x3, %rsi
jmp 0x6097
addq $0x2, %rsi
cmpb $0x0, (%rbx,%rsi)
je 0x6111
cmpb %cl, %dil
ja 0x60ab
cmpb %r10b, %cl
ja 0x60ab
incl %edx
jmp 0x60b8
xorl %r8d, %r8d
cmpb %cl, %dil
sete %r8b
subl %r8d, %ebp
xorl %edi, %edi
leaq 0x1(%rsi), %r8
leaq (%rbx,%rsi), %r10
incq %r10
movb -0x1(%r10), %r9b
cmpq $0x2, %rsi
jl 0x6029
cmpb $0x5d, %r9b
jne 0x6029
testl %ebp, %ebp
setg %cl
testl %edx, %edx
setg %dl
orb %cl, %dl
movq %rax, %rdi
movq %r10, %rbx
jne 0x5fac
jmp 0x6111
testl %r8d, %r8d
je 0x6153
cmpl $0x2a, %r8d
je 0x6120
movq %rax, %rdi
movq %rdx, %rbx
cmpb %cl, %sil
je 0x5fac
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movzbl 0x1(%rbx), %eax
incq %rbx
cmpl $0x2a, %eax
je 0x6120
testl %eax, %eax
jne 0x6135
movb $0x1, %bpl
jmp 0x6113
cmpb $0x0, (%rdi)
setne %bpl
je 0x6113
leaq 0x1(%rdi), %r14
movq %rbx, %rsi
callq 0x5fa2
movq %r14, %rdi
testb %al, %al
je 0x6135
jmp 0x6113
testb %cl, %cl
sete %bpl
jmp 0x6113