// File: /workspace/github_c_makefile_star2_O2/rakitzis[P]rc/glob.c
// Function: dmatch
static List *dmatch(char *d, char *p, char *m) {
	bool matched;
	List *top, *r;
	static DIR *dirp;
	static struct dirent *dp;
	static struct stat s;
	int i;

	/*
	   return a match if there are no metacharacters; allows globbing through
	   directories with no read permission. make sure the file exists, though.
	 */
	matched = TRUE;
	if (m != NULL)
		for (i = 0; p[i] != '\0'; i++)
			if (m[i]) {
				matched = FALSE;
				break;
			}

	if (matched) {
		char *path = nprint("%s/%s", d, p);
		if (lstat(path, &s) < 0)
			return NULL;
		r = nnew(List);
		r->w = ncpy(p);
		r->m = NULL;
		r->n = NULL;
		return r;
	}

	top = r = NULL;
	if (*d == '\0') d = "/";
	if ((dirp = opendir(d)) == NULL)
		return NULL;
	/* opendir succeeds on regular files on some systems, so the stat() call is necessary (sigh) */
	if (stat(d, &s) < 0 || (s.st_mode & S_IFMT) != S_IFDIR) {
		closedir(dirp);
		return NULL;
	}
	while ((dp = readdir(dirp)) != NULL)
		if ((*dp->d_name != '.' || *p == '.') && match(p, m, dp->d_name)) { /* match ^. explicitly */
			matched = TRUE;
			if (top == NULL)
				top = r = nnew(List);
			else
				r = r->n = nnew(List);
			r->w = ncpy(dp->d_name);
			r->m = NULL;
		}
	closedir(dirp);
	if (!matched)
		return NULL;
	r->n = NULL;
	return top;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %rsi
testq %rdx, %rdx
je 0x6368
movq %rdx, %r14
xorl %eax, %eax
cmpb $0x0, (%rbx,%rax)
je 0x6368
cmpb $0x0, (%r14,%rax)
leaq 0x1(%rax), %rax
je 0x624f
cmpb $0x0, (%rsi)
leaq 0x7e65(%rip), %r15      # 0xe0d3
cmovneq %rsi, %r15
movq %r15, %rdi
callq 0x30e0
movq %rax, 0x13787(%rip)     # 0x19a08
testq %rax, %rax
je 0x63d2
leaq 0x13787(%rip), %rsi     # 0x19a18
movq %r15, %rdi
callq 0x3210
testl %eax, %eax
js 0x63c6
movl $0xf000, %eax           # imm = 0xF000
andl 0x13784(%rip), %eax     # 0x19a30
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x63c6
movb $0x1, %r12b
xorl %ebp, %ebp
pushq $0x18
popq %r13
xorl %r15d, %r15d
movq 0x1373e(%rip), %rdi     # 0x19a08
callq 0x3250
movq %rax, 0x1373a(%rip)     # 0x19a10
testq %rax, %rax
je 0x63e7
cmpb $0x2e, 0x13(%rax)
jne 0x62ea
cmpb $0x2e, (%rbx)
jne 0x62c3
addq $0x13, %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x978c
testl %eax, %eax
je 0x62c3
movq %rbp, %r12
movq %r13, %rdi
callq 0x9928
movq %rax, %r13
movq %rax, %rbp
testq %r15, %r15
je 0x631e
movq %r13, 0x10(%r12)
movq %r15, %rbp
movq 0x136eb(%rip), %rdi     # 0x19a10
addq $0x13, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9928
movq %rax, %r15
movq 0x136cf(%rip), %rsi     # 0x19a10
addq $0x13, %rsi
movq %rax, %rdi
callq 0x3070
movq %r15, (%r13)
andq $0x0, 0x8(%r13)
xorl %r12d, %r12d
movq %rbp, %r15
movq %r13, %rbp
pushq $0x18
popq %r13
jmp 0x62c3
leaq 0x8357(%rip), %rdi      # 0xe6c6
xorl %r15d, %r15d
movq %rbx, %rdx
xorl %eax, %eax
callq 0xaaee
leaq 0x13695(%rip), %rsi     # 0x19a18
movq %rax, %rdi
callq 0x31d0
testl %eax, %eax
js 0x63d5
pushq $0x18
popq %rdi
callq 0x9928
movq %rax, %r15
movq %rbx, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9928
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3070
movq %r14, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
jmp 0x63d5
movq 0x1363b(%rip), %rdi     # 0x19a08
callq 0x31a0
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1361a(%rip), %rdi     # 0x19a08
callq 0x31a0
testb $0x1, %r12b
jne 0x63d2
andq $0x0, 0x10(%rbp)
jmp 0x63d5