// File: /workspace/github_c_makefile_star2_O3/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 0x647d
cmpb $0x0, (%rbx)
je 0x647d
movq %rdx, %r14
movl $0x1, %eax
cmpb $0x0, -0x1(%r14,%rax)
jne 0x64e4
cmpb $0x0, (%rbx,%rax)
leaq 0x1(%rax), %rax
jne 0x646b
leaq 0x9242(%rip), %rdi      # 0xf6c6
xorl %r15d, %r15d
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb191
leaq 0x13580(%rip), %rsi     # 0x19a18
movq %rax, %rdi
callq 0x31d0
testl %eax, %eax
js 0x6630
movl $0x18, %edi
callq 0x9e80
movq %rax, %r15
movq %rbx, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9e80
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3070
movq %r14, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
jmp 0x6630
cmpb $0x0, (%rsi)
leaq 0x8be5(%rip), %r15      # 0xf0d3
cmovneq %rsi, %r15
movq %r15, %rdi
callq 0x30e0
movq %rax, 0x13507(%rip)     # 0x19a08
testq %rax, %rax
je 0x662d
leaq 0x13507(%rip), %rsi     # 0x19a18
movq %r15, %rdi
callq 0x3210
testl %eax, %eax
js 0x6621
movl $0xf000, %eax           # imm = 0xF000
andl 0x13504(%rip), %eax     # 0x19a30
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6621
movq 0x134ca(%rip), %rdi     # 0x19a08
callq 0x3250
movq %rax, 0x134c6(%rip)     # 0x19a10
testq %rax, %rax
je 0x6621
xorl %r13d, %r13d
xorl %r15d, %r15d
movl $0x0, 0x4(%rsp)
cmpb $0x2e, 0x13(%rax)
jne 0x656c
cmpb $0x2e, (%rbx)
jne 0x65e8
addq $0x13, %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x9cc8
testl %eax, %eax
je 0x65e8
movl $0x18, %edi
callq 0x9e80
movq %rax, %r12
movq %rax, %rbp
testq %r15, %r15
je 0x659e
movq %r12, 0x10(%r13)
movq %r15, %rbp
movq 0x1346b(%rip), %rdi     # 0x19a10
addq $0x13, %rdi
callq 0x30f0
leaq 0x1(%rax), %rdi
callq 0x9e80
movq %rax, %r15
movq 0x1344f(%rip), %rsi     # 0x19a10
addq $0x13, %rsi
movq %rax, %rdi
callq 0x3070
movq %r15, (%r12)
movq $0x0, 0x8(%r12)
movl $0x1, 0x4(%rsp)
movq %rbp, %r15
movq %r12, %r13
movq 0x13419(%rip), %rdi     # 0x19a08
callq 0x3250
movq %rax, 0x13415(%rip)     # 0x19a10
testq %rax, %rax
jne 0x6561
movq 0x133fd(%rip), %rdi     # 0x19a08
callq 0x31a0
cmpl $0x0, 0x4(%rsp)
je 0x662d
movq $0x0, 0x10(%r13)
jmp 0x6630
movq 0x133e0(%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
nop