// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movq %rsi, %rbx
movl $0x5c, %eax
leaq 0x1(%rdi), %rcx
movb (%rdi), %dl
leaq 0x1(%rbx), %rsi
movb (%rbx), %r8b
movzbl %r8b, %r9d
cmpl $0x5a, %r9d
jle 0x5f4a
cmpl $0x5b, %r9d
je 0x5f63
cmpl $0x5c, %r9d
jne 0x606b
movzbl 0x1(%rbx), %r8d
addq $0x2, %rbx
testb %r8b, %r8b
cmovel %eax, %r8d
cmovneq %rbx, %rsi
jmp 0x606b
cmpl $0x3f, %r9d
jne 0x6060
movq %rcx, %rdi
movq %rsi, %rbx
testb %dl, %dl
jne 0x5f0a
jmp 0x607a
movb (%rsi), %r8b
xorl %ebp, %ebp
testb %r8b, %r8b
je 0x607c
leaq 0x2(%rbx), %r11
movl $0x1, %esi
movl $0x2, %r10d
xorl %r9d, %r9d
xorl %edi, %edi
movb (%r11), %r11b
testb %r11b, %r11b
je 0x607a
cmpb $0x2d, %r8b
setne %r14b
testb %r9b, %r9b
sete %r15b
cmpb $0x5d, %r11b
sete %r12b
orb %r14b, %r15b
orb %r12b, %r15b
je 0x5fcd
cmpb $0x5c, %r8b
jne 0x5fde
movb 0x2(%rbx,%rsi), %r14b
testb %r14b, %r14b
je 0x607a
addq $0x2, %rsi
movl %r11d, %r8d
jmp 0x5fe5
cmpb $0x5c, %r11b
jne 0x5ffa
movb 0x2(%rbx,%rsi), %r11b
addq $0x3, %rsi
jmp 0x5ffe
movb (%rbx,%r10), %r14b
movq %r10, %rsi
movl %r8d, %r9d
xorl %r8d, %r8d
cmpb %r9b, %dl
sete %r8b
addl %r8d, %ebp
movl %r14d, %r8d
jmp 0x6025
addq $0x2, %rsi
movb (%rbx,%rsi), %r8b
testb %r8b, %r8b
je 0x607a
cmpb %dl, %r9b
ja 0x6015
cmpb %r11b, %dl
ja 0x6015
incl %edi
jmp 0x6022
xorl %r10d, %r10d
cmpb %dl, %r9b
sete %r10b
subl %r10d, %ebp
xorl %r9d, %r9d
leaq 0x1(%rsi), %r10
leaq (%rbx,%rsi), %r11
incq %r11
cmpq $0x2, %rsi
jl 0x5f85
cmpb $0x5d, %r8b
jne 0x5f85
testl %ebp, %ebp
setg %dl
testl %edi, %edi
setg %sil
orb %dl, %sil
movq %rcx, %rdi
movq %r11, %rbx
jne 0x5f0a
jmp 0x607a
testl %r9d, %r9d
je 0x60ba
cmpl $0x2a, %r9d
je 0x6087
movq %rcx, %rdi
movq %rsi, %rbx
cmpb %dl, %r8b
je 0x5f0a
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movzbl 0x1(%rbx), %eax
incq %rbx
cmpl $0x2a, %eax
je 0x6087
testl %eax, %eax
jne 0x609c
movb $0x1, %bpl
jmp 0x607c
cmpb $0x0, (%rdi)
setne %bpl
je 0x607c
leaq 0x1(%rdi), %r14
movq %rbx, %rsi
callq 0x5efa
movq %r14, %rdi
testb %al, %al
je 0x609c
jmp 0x607c
testb %dl, %dl
sete %bpl
jmp 0x607c