// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7f80
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x7f7e
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x7f71
movl $0x0, -0x24(%rbp)
jmp 0x7f7e
jmp 0x7f73
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x7f49
jmp 0x7f80
cmpl $0x0, -0x24(%rbp)
je 0x8024
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0xd78b(%rip), %rdi      # 0x15724
movb $0x0, %al
callq 0xf6d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x17af9(%rip), %rsi     # 0x1faa8
callq 0x31c0
cmpl $0x0, %eax
jge 0x7fc6
movq $0x0, -0x8(%rbp)
jmp 0x81bc
movl $0x18, %edi
callq 0xd4c0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0xd4c0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x3070
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x81bc
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x804b
leaq 0xd0e1(%rip), %rax      # 0x15128
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30e0
movq %rax, 0x17a3d(%rip)     # 0x1fa98
cmpq $0x0, %rax
jne 0x806e
movq $0x0, -0x8(%rbp)
jmp 0x81bc
movq -0x10(%rbp), %rdi
leaq 0x17a2f(%rip), %rsi     # 0x1faa8
callq 0x3200
cmpl $0x0, %eax
jl 0x8095
movl 0x17a37(%rip), %eax     # 0x1fac0
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
je 0x80ae
movq 0x179fc(%rip), %rdi     # 0x1fa98
callq 0x31a0
movq $0x0, -0x8(%rbp)
jmp 0x81bc
jmp 0x80b0
movq 0x179e1(%rip), %rdi     # 0x1fa98
callq 0x3240
movq %rax, 0x179dd(%rip)     # 0x1faa0
cmpq $0x0, %rax
je 0x818c
movq 0x179cc(%rip), %rax     # 0x1faa0
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
jne 0x80ed
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x8187
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x179a4(%rip), %rdx     # 0x1faa0
addq $0x13, %rdx
callq 0xd110
cmpl $0x0, %eax
je 0x8187
movl $0x1, -0x24(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x812c
movl $0x18, %edi
callq 0xd4c0
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x8142
movl $0x18, %edi
callq 0xd4c0
movq -0x38(%rbp), %rcx
movq %rax, 0x10(%rcx)
movq %rax, -0x38(%rbp)
movq 0x17957(%rip), %rdi     # 0x1faa0
addq $0x13, %rdi
callq 0x30f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0xd4c0
movq %rax, %rdi
movq 0x17938(%rip), %rsi     # 0x1faa0
addq $0x13, %rsi
callq 0x3070
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x80b0
movq 0x17905(%rip), %rdi     # 0x1fa98
callq 0x31a0
cmpl $0x0, -0x24(%rbp)
jne 0x81a8
movq $0x0, -0x8(%rbp)
jmp 0x81bc
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)