// File: /workspace/github_c_makefile_star2_O1/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 0x653d
cmpb $0x0, (%rbx)
je 0x653d
movq %rdx, %r14
movl $0x1, %eax
cmpb $0x0, -0x1(%r14,%rax)
jne 0x65a4
cmpb $0x0, (%rbx,%rax)
leaq 0x1(%rax), %rax
jne 0x652b
leaq 0x9192(%rip), %rdi      # 0xf6d6
xorl %r15d, %r15d
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb274
leaq 0x134c0(%rip), %rsi     # 0x19a18
movq %rax, %rdi
callq 0x31d0
testl %eax, %eax
js 0x66dd
movl $0x18, %edi
callq 0x9f28
movq %rax, %r15
movq %rbx, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9f28
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3070
movq %r14, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
jmp 0x66dd
cmpb $0x0, (%rsi)
leaq 0x8b26(%rip), %r15      # 0xf0d4
cmovneq %rsi, %r15
movq %r15, %rdi
callq 0x30e0
movq %rax, 0x13447(%rip)     # 0x19a08
testq %rax, %rax
je 0x66da
leaq 0x13447(%rip), %rsi     # 0x19a18
movq %r15, %rdi
callq 0x3210
testl %eax, %eax
js 0x66ce
movl $0xf000, %eax           # imm = 0xF000
andl 0x13444(%rip), %eax     # 0x19a30
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x66ce
movq 0x1340a(%rip), %rdi     # 0x19a08
callq 0x3250
movq %rax, 0x13406(%rip)     # 0x19a10
testq %rax, %rax
je 0x66ef
movq $0x0, (%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpb $0x2e, 0x13(%rax)
jne 0x662c
cmpb $0x2e, (%rbx)
jne 0x66a9
addq $0x13, %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x9d6c
testl %eax, %eax
je 0x66a9
movl $0x18, %edi
callq 0x9f28
movq %rax, %r12
movq %rax, %rbp
testq %r15, %r15
je 0x665e
movq %r12, 0x10(%r13)
movq %r15, %rbp
movq 0x133ab(%rip), %rdi     # 0x19a10
addq $0x13, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9f28
movq %rax, %r15
movq 0x1338f(%rip), %rsi     # 0x19a10
addq $0x13, %rsi
movq %rax, %rdi
callq 0x3070
movq %r15, (%r12)
movq $0x0, 0x8(%r12)
movl $0x1, %eax
movq %rax, (%rsp)
movq %rbp, %r15
movq %r12, %r13
movq 0x13358(%rip), %rdi     # 0x19a08
callq 0x3250
movq %rax, 0x13354(%rip)     # 0x19a10
testq %rax, %rax
jne 0x6621
cmpl $0x0, (%rsp)
sete %bl
jmp 0x66f7
movq 0x13333(%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
movb $0x1, %bl
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x1330a(%rip), %rdi     # 0x19a08
callq 0x31a0
testb %bl, %bl
jne 0x66da
movq $0x0, 0x10(%r13)
jmp 0x66dd
nopl (%rax)