// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %r12
callq 0x30f0
movq %rax, %rbx
incq %rbx
cmpq 0x13a6e(%rip), %rbx     # 0x19a00
seta %al
movq 0x13a44(%rip), %rsi     # 0x199e0
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x6021
movq %rsi, %rdi
callq 0x9a5c
movq 0x13a33(%rip), %rdi     # 0x199e8
callq 0x9a5c
movq 0x13a2f(%rip), %rdi     # 0x199f0
callq 0x9a5c
movq 0x13a2b(%rip), %rdi     # 0x199f8
callq 0x9a5c
movq %rbx, %rdi
callq 0x9a83
movq %rax, 0x139ff(%rip)     # 0x199e0
movq %rbx, %rdi
callq 0x9a83
movq %rax, 0x139f8(%rip)     # 0x199e8
movq %rbx, %rdi
callq 0x9a83
movq %rax, 0x139f1(%rip)     # 0x199f0
movq %rbx, %rdi
callq 0x9a83
movq %rax, %rbp
movq %rax, 0x139e7(%rip)     # 0x199f8
movq %rbx, 0x139e8(%rip)     # 0x19a00
movq 0x139c1(%rip), %rsi     # 0x199e0
jmp 0x6028
movq 0x139d0(%rip), %rbp     # 0x199f8
movq 0x139b9(%rip), %rbx     # 0x199e8
movq 0x139ba(%rip), %rdx     # 0x199f0
xorl %r15d, %r15d
movzbl (%r12,%r15), %eax
testl %eax, %eax
je 0x6058
cmpl $0x2f, %eax
je 0x6058
movb %al, (%rsi,%r15)
movb (%r14,%r15), %al
movb %al, (%rdx,%r15)
incq %r15
jmp 0x6039
movb $0x0, (%rsi,%r15)
cmpb $0x0, (%r12,%r15)
movq %r12, 0x10(%rsp)
je 0x6086
cmpb $0x2f, (%r12)
jne 0x609a
leaq 0x30(%rsp), %rcx
movq %rsi, (%rcx)
movq %rdx, 0x8(%rcx)
movq %rcx, %rax
andq $0x0, 0x10(%rcx)
jmp 0x60a6
leaq 0x8021(%rip), %rdi      # 0xe0ae
callq 0x6230
movq %rax, %r12
jmp 0x61fc
leaq 0x800d(%rip), %rdi      # 0xe0ae
callq 0x6230
leaq (%r12,%r15), %r13
addq %r15, %r14
movq %rax, %r12
callq 0xb266
pushq $0x2
popq %rsi
xorl %r15d, %r15d
movb (%r13,%r15), %al
cmpb $0x2f, %al
jne 0x60cd
incq %r15
addq $0x2, %rsi
jmp 0x60bb
addq %r15, %r14
addq %r15, %r13
testb %al, %al
je 0x60f9
movzbl %al, %ecx
cmpl $0x2f, %ecx
je 0x60f9
movb %al, (%rbx)
incq %rbx
movb (%r14), %al
incq %r14
movb %al, (%rbp)
incq %rbp
movb 0x1(%r13), %al
incq %r13
jmp 0x60d3
movb $0x0, (%rbx)
movq 0x138e5(%rip), %rbp     # 0x199e8
movq 0x138ee(%rip), %rbx     # 0x199f8
leaq 0x1(%r15), %rcx
movq 0x13993(%rip), %rax     # 0x19aa8
cmpq 0x139a4(%rip), %rcx     # 0x19ac0
jbe 0x6134
movq %rsi, 0x1399b(%rip)     # 0x19ac0
movq %rax, %rdi
callq 0x9acc
movq %rax, 0x13974(%rip)     # 0x19aa8
movb $0x0, (%rax,%r15)
movq %r15, %rax
subq $0x1, %rax
jb 0x6154
movq 0x1395f(%rip), %rcx     # 0x19aa8
movb $0x2f, -0x1(%rcx,%r15)
movq %rax, %r15
jmp 0x613c
movq %r12, %r15
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
testq %r15, %r15
je 0x61de
movq (%r15), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x6230
testq %rax, %rax
je 0x61d8
movq (%r15), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x20(%rsp), %rdx
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
cmpb $0x2f, (%rcx)
jne 0x6199
cmpb $0x0, 0x1(%rcx)
je 0x61a8
leaq 0x13908(%rip), %rdi     # 0x19aa8
movq %rax, %rsi
callq 0x6492
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x6492
testq %r12, %r12
je 0x61c1
movq %rax, 0x10(%r12)
jmp 0x61c9
movq %rax, %r12
movq %rax, 0x8(%rsp)
movq %r12, %rax
movq %rax, %r12
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x61cc
movq 0x10(%r15), %r15
jmp 0x6163
movq 0x13803(%rip), %rbx     # 0x199e8
movq 0x1380c(%rip), %rbp     # 0x199f8
cmpb $0x0, (%r13)
movq 0x8(%rsp), %r12
jne 0x60b0
testq %r12, %r12
jne 0x621e
pushq $0x18
popq %rdi
callq 0x9928
movq %rax, %r12
movq 0x10(%rsp), %rax
movq %rax, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r12)
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq