// File: /workspace/github_c_makefile_star2_O0/rakitzis[P]rc/glob.c
// Function: doglob
static List *doglob(char *w, char *m) {
	static char *dir = NULL, *pattern = NULL, *metadir = NULL, *metapattern = NULL;
	static size_t dsize = 0;
	char *d, *p, *md, *mp;
	size_t psize;
	char *s = w;
	List firstdir;
	List *matched;
	if ((psize = strlen(w) + 1) > dsize || dir == NULL) {
		efree(dir); efree(pattern); efree(metadir); efree(metapattern);
		dir = ealloc(psize);
		pattern = ealloc(psize);
		metadir = ealloc(psize);
		metapattern = ealloc(psize);
		dsize = psize;
	}
	d = dir;
	p = pattern;
	md = metadir;
	mp = metapattern;
	while (*s != '/' && *s != '\0') {
		*d++ = *s++; /* get first directory component */
		*md++ = *m++;
	}
	*d = '\0';
	/*
	   Special case: no slashes in the pattern, i.e., open the current directory.
	   Remember that w cannot consist of slashes alone (the other way *s could be
	   zero) since doglob gets called iff there's a metacharacter to be matched
	*/
	if (*s == '\0') {
		matched = dmatch(".", dir, metadir);
		goto end;
	}
	if (*w == '/') {
		firstdir.w = dir;
		firstdir.m = metadir;
		firstdir.n = NULL;
		matched = &firstdir;
	} else {
		/*
		   we must glob against current directory,
		   since the first character is not a slash.
		*/
		matched = dmatch(".", dir, metadir);
	}
	do {
		size_t slashcount;
		sigchk();
		for (slashcount = 0; *s == '/'; s++, m++)
			slashcount++; /* skip slashes */
		while (*s != '/' && *s != '\0')
			*p++ = *s++, *mp++ = *m++; /* get pattern */
		*p = '\0';
		matched = lglob(matched, pattern, metapattern, slashcount);
		p = pattern, mp = metapattern;
	} while (*s != '\0');
end:	if (matched == NULL) {
		matched = nnew(List);
		matched->w = w;
		matched->m = NULL;
		matched->n = NULL;
	}
	return matched;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30f0
addq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpq 0x17e60(%rip), %rax     # 0x1fa90
ja 0x7c3c
cmpq $0x0, 0x17e36(%rip)     # 0x1fa70
jne 0x7cb7
movq 0x17e2d(%rip), %rdi     # 0x1fa70
callq 0xd7a0
movq 0x17e29(%rip), %rdi     # 0x1fa78
callq 0xd7a0
movq 0x17e25(%rip), %rdi     # 0x1fa80
callq 0xd7a0
movq 0x17e21(%rip), %rdi     # 0x1fa88
callq 0xd7a0
movq -0x38(%rbp), %rdi
callq 0xd820
movq %rax, 0x17df4(%rip)     # 0x1fa70
movq -0x38(%rbp), %rdi
callq 0xd820
movq %rax, 0x17dec(%rip)     # 0x1fa78
movq -0x38(%rbp), %rdi
callq 0xd820
movq %rax, 0x17de4(%rip)     # 0x1fa80
movq -0x38(%rbp), %rdi
callq 0xd820
movq %rax, 0x17ddc(%rip)     # 0x1fa88
movq -0x38(%rbp), %rax
movq %rax, 0x17dd9(%rip)     # 0x1fa90
movq 0x17db2(%rip), %rax     # 0x1fa70
movq %rax, -0x18(%rbp)
movq 0x17daf(%rip), %rax     # 0x1fa78
movq %rax, -0x20(%rbp)
movq 0x17dac(%rip), %rax     # 0x1fa80
movq %rax, -0x28(%rbp)
movq 0x17da9(%rip), %rax     # 0x1fa88
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2f, %ecx
movb %al, -0x69(%rbp)
je 0x7d04
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x7d0d
jmp 0x7d53
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb (%rax), %cl
movq -0x18(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x7ce3
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x7d89
movq 0x17d03(%rip), %rsi     # 0x1fa70
movq 0x17d0c(%rip), %rdx     # 0x1fa80
leaq 0xd3b0(%rip), %rdi      # 0x1512b
callq 0x7f20
movq %rax, -0x60(%rbp)
jmp 0x7edc
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x7dbd
movq 0x17cd4(%rip), %rax     # 0x1fa70
movq %rax, -0x58(%rbp)
movq 0x17cd9(%rip), %rax     # 0x1fa80
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x7ddb
movq 0x17cac(%rip), %rsi     # 0x1fa70
movq 0x17cb5(%rip), %rdx     # 0x1fa80
leaq 0xd359(%rip), %rdi      # 0x1512b
callq 0x7f20
movq %rax, -0x60(%rbp)
jmp 0x7ddd
callq 0x104a0
movq $0x0, -0x68(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x7e1c
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x7dea
jmp 0x7e1e
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2f, %ecx
movb %al, -0x6a(%rbp)
je 0x7e3f
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
testb $0x1, %al
jne 0x7e48
jmp 0x7e8e
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb (%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
jmp 0x7e1e
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x60(%rbp), %rdi
movq 0x17bd8(%rip), %rsi     # 0x1fa78
movq 0x17be1(%rip), %rdx     # 0x1fa88
movq -0x68(%rbp), %rcx
callq 0x81d0
movq %rax, -0x60(%rbp)
movq 0x17bbd(%rip), %rax     # 0x1fa78
movq %rax, -0x20(%rbp)
movq 0x17bc2(%rip), %rax     # 0x1fa88
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x7ddd
jmp 0x7edc
cmpq $0x0, -0x60(%rbp)
jne 0x7f14
movl $0x18, %edi
callq 0xd4c0
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x60(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x60(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop