// File: /workspace/github_c_makefile_star2_O0/s3lase[P]v6shell/glob6.c
// Function: glob1
static const char **
glob1(const char **gav, char *as, int *pmc)
{
	DIR *dirp;
	struct dirent *entry;
	ptrdiff_t gidx;
	const char *ds;
	char *ps;

	ds = ps = as;
	while (*ps != ASTERISK && *ps != QUESTION && *ps != LBRACKET)
		if (*ps++ == EOS) {
			gav = gnew(gav);
			*gavp++ = gcat(as, "");
			*gavp = NULL;
			return gav;
		}
	if (strlen(as) >= PATHMAX)
		err(SH_ERR, FMT1S, ERR_PATTOOLONG);
	for (;;) {
		if (ps == ds) {
			ds = "";
			break;
		}
		if ((*--ps & ASCII) == SLASH) {
			*ps = EOS;
			if (ds == ps)
				ds = "/";
			*ps++ = (char)QUOTE;
			break;
		}
	}
	if ((dirp = gopendir(*ds != EOS ? ds : ".")) == NULL) {
		err(SH_ERR, FMT1S, ERR_NODIR);
		/*NOTREACHED*/
	}
	gidx = (ptrdiff_t)(gavp - gav);
	while ((entry = readdir(dirp)) != NULL) {
		if (entry->d_name[0] == DOT && (*ps & ASCII) != DOT)
			continue;
		if (glob2(UCPTR(entry->d_name), UCPTR(ps))) {
			gav = gnew(gav);
			*gavp++ = gcat(ds, entry->d_name);
			(*pmc)++;
		}
	}
	(void)closedir(dirp);
	gsort(gav + gidx);
	*gavp = NULL;
	return gav;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2a, %ecx
movb %al, -0x49(%rbp)
je 0x14a2
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x3f, %ecx
movb %al, -0x49(%rbp)
je 0x14a2
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x14ab
jmp 0x151a
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1515
movq -0x10(%rbp), %rdi
callq 0x16e0
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1cfc(%rip), %rsi      # 0x31d6
callq 0x17c0
movq %rax, %rcx
movq 0x3c1f(%rip), %rax      # 0x5108
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x3c11(%rip)      # 0x5108
movq %rcx, (%rax)
movq 0x3c07(%rip), %rax      # 0x5108
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16d5
jmp 0x1470
movq -0x18(%rbp), %rdi
callq 0x10d0
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x1545
movl $0x2, %edi
leaq 0x1cf2(%rip), %rsi      # 0x3229
leaq 0x1c02(%rip), %rdx      # 0x3140
movb $0x0, %al
callq 0x1e00
jmp 0x1547
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x155e
leaq 0x1c7e(%rip), %rax      # 0x31d6
movq %rax, -0x40(%rbp)
jmp 0x15ab
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
movsbl -0x1(%rax), %eax
andl $0x7f, %eax
cmpl $0x2f, %eax
jne 0x15a9
movq -0x48(%rbp), %rax
movb $0x0, (%rax)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x1595
leaq 0x1bc0(%rip), %rax      # 0x3151
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $-0x80, (%rax)
jmp 0x15ab
jmp 0x1547
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x15c1
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x15ce
leaq 0x1c3a(%rip), %rax      # 0x3202
movq %rax, -0x58(%rbp)
jmp 0x15ce
movq -0x58(%rbp), %rdi
callq 0x19c0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x15fb
movl $0x2, %edi
leaq 0x1c3c(%rip), %rsi      # 0x3229
leaq 0x1b5f(%rip), %rdx      # 0x3153
movb $0x0, %al
callq 0x1e00
movq 0x3b06(%rip), %rax      # 0x5108
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1170
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x16a2
movq -0x30(%rbp), %rax
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
jne 0x1642
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
andl $0x7f, %eax
cmpl $0x2e, %eax
je 0x1642
jmp 0x1611
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
movq -0x48(%rbp), %rsi
callq 0x1a90
testb $0x1, %al
jne 0x1659
jmp 0x169d
movq -0x10(%rbp), %rdi
callq 0x16e0
movq %rax, -0x10(%rbp)
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x13, %rsi
callq 0x17c0
movq %rax, %rcx
movq 0x3a87(%rip), %rax      # 0x5108
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x3a79(%rip)      # 0x5108
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1611
movq -0x28(%rbp), %rdi
callq 0x1120
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x1d60
movq 0x3a42(%rip), %rax      # 0x5108
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop