// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rax
pushq $0x5c
popq %rcx
leaq 0x1(%rdi), %rdx
movb (%rdi), %sil
leaq 0x1(%rbx), %r8
movzbl (%rbx), %r9d
cmpl $0x3f, %r9d
je 0x5ee7
cmpl $0x5b, %r9d
je 0x5dee
cmpl $0x5c, %r9d
je 0x5ec2
testl %r9d, %r9d
je 0x5f53
cmpl $0x2a, %r9d
jne 0x5ed6
jmp 0x5f20
movb (%r8), %r9b
xorl %ebp, %ebp
testb %r9b, %r9b
je 0x5f15
xorl %edi, %edi
movq %rax, %r8
xorl %r10d, %r10d
movl %r9d, %r11d
leaq (%rbx,%r8), %r9
incq %r9
cmpq $0x2, %r8
jl 0x5e1e
cmpb $0x5d, %r11b
je 0x5ef8
movb (%r9), %r14b
testb %r14b, %r14b
je 0x5f13
cmpb $0x2d, %r11b
setne %r9b
testb %r10b, %r10b
sete %r15b
cmpb $0x5d, %r14b
sete %r12b
orb %r9b, %r15b
orb %r12b, %r15b
je 0x5e66
cmpb $0x5c, %r11b
jne 0x5e77
movb 0x2(%rbx,%r8), %r9b
testb %r9b, %r9b
je 0x5f13
addq $0x2, %r8
movl %r14d, %r11d
jmp 0x5e7d
cmpb $0x5c, %r14b
jne 0x5e89
movb 0x2(%rbx,%r8), %r14b
addq $0x3, %r8
jmp 0x5e8d
incq %r8
movl %r14d, %r9d
xorl %r14d, %r14d
cmpb %r11b, %sil
sete %r14b
jmp 0x5eb0
addq $0x2, %r8
movb (%rbx,%r8), %r9b
testb %r9b, %r9b
je 0x5f13
cmpb %sil, %r10b
ja 0x5ea0
cmpb %r14b, %sil
jbe 0x5ebb
xorl %r14d, %r14d
cmpb %sil, %r10b
sete %r14b
negl %r14d
xorl %r11d, %r11d
movl %r11d, %r10d
addl %r14d, %edi
jmp 0x5e04
incl %ebp
jmp 0x5e01
movzbl 0x1(%rbx), %r9d
addq $0x2, %rbx
testb %r9b, %r9b
cmovel %ecx, %r9d
cmovneq %rbx, %r8
movq %rdx, %rdi
movq %r8, %rbx
cmpb %sil, %r9b
je 0x5dad
jmp 0x5f13
movq %rdx, %rdi
movq %r8, %rbx
testb %sil, %sil
jne 0x5dad
jmp 0x5f13
testl %edi, %edi
setg %sil
testl %ebp, %ebp
setne %dil
orb %sil, %dil
movq %rdx, %rdi
movq %r9, %rbx
jne 0x5dad
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 0x5f20
testl %eax, %eax
jne 0x5f35
movb $0x1, %bpl
jmp 0x5f15
cmpb $0x0, (%rdi)
setne %bpl
je 0x5f15
leaq 0x1(%rdi), %r14
movq %rbx, %rsi
callq 0x5d9c
movq %r14, %rdi
testb %al, %al
je 0x5f35
jmp 0x5f15
testb %sil, %sil
sete %bpl
jmp 0x5f15