// File: /workspace/github_c_makefile_star2_O1/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, (%rsp)
movq %rdi, %r15
callq 0x30f0
movq %rax, %rbx
incq %rbx
cmpq 0x137bc(%rip), %rbx     # 0x19a00
seta %al
movq 0x13792(%rip), %rdi     # 0x199e0
testq %rdi, %rdi
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x62c7
callq 0xa095
movq 0x13781(%rip), %rdi     # 0x199e8
callq 0xa095
movq 0x1377d(%rip), %rdi     # 0x199f0
callq 0xa095
movq 0x13779(%rip), %rdi     # 0x199f8
callq 0xa095
movq %rbx, %rdi
callq 0xa0c4
movq %rax, 0x1374d(%rip)     # 0x199e0
movq %rbx, %rdi
callq 0xa0c4
movq %rax, 0x13746(%rip)     # 0x199e8
movq %rbx, %rdi
callq 0xa0c4
movq %rax, 0x1373f(%rip)     # 0x199f0
movq %rbx, %rdi
callq 0xa0c4
movq %rax, 0x13738(%rip)     # 0x199f8
movq %rbx, 0x13739(%rip)     # 0x19a00
movq 0x13712(%rip), %rsi     # 0x199e0
movq 0x13713(%rip), %rbx     # 0x199e8
movq 0x13714(%rip), %rdx     # 0x199f0
movq 0x13715(%rip), %rbp     # 0x199f8
xorl %r14d, %r14d
movzbl (%r15,%r14), %eax
testl %eax, %eax
je 0x6309
cmpl $0x2f, %eax
je 0x6309
movb %al, (%rsi,%r14)
movq (%rsp), %rax
movb (%rax,%r14), %al
movb %al, (%rdx,%r14)
incq %r14
jmp 0x62e6
movb $0x0, (%rsi,%r14)
cmpb $0x0, (%r15,%r14)
movq %r15, 0x10(%rsp)
je 0x6339
cmpb $0x2f, (%r15)
jne 0x634d
leaq 0x30(%rsp), %r12
movq %rsi, (%r12)
movq %rdx, 0x8(%r12)
movq $0x0, 0x10(%r12)
jmp 0x635c
leaq 0x8d97(%rip), %rdi      # 0xf0d7
callq 0x6508
movq %rax, %rcx
jmp 0x64d5
leaq 0x8d83(%rip), %rdi      # 0xf0d7
callq 0x6508
movq %rax, %r12
addq %r14, %r15
addq %r14, (%rsp)
callq 0xbae1
cmpb $0x2f, (%r15)
jne 0x6386
xorl %r14d, %r14d
cmpb $0x2f, 0x1(%r15,%r14)
leaq 0x1(%r14), %r14
je 0x6371
addq %r14, %r15
addq %r14, (%rsp)
jmp 0x6389
xorl %r14d, %r14d
xorl %r13d, %r13d
movzbl (%r15,%r13), %eax
testl %eax, %eax
je 0x63b0
cmpl $0x2f, %eax
je 0x63b0
movb %al, (%rbx,%r13)
movq (%rsp), %rax
movb (%rax,%r13), %al
movb %al, (%rbp,%r13)
incq %r13
jmp 0x638c
movb $0x0, (%rbx,%r13)
movq 0x1362c(%rip), %rbp     # 0x199e8
movq 0x13635(%rip), %rbx     # 0x199f8
leaq 0x1(%r14), %rsi
cmpq 0x136f2(%rip), %rsi     # 0x19ac0
jbe 0x63ed
addq %rsi, %rsi
movq %rsi, 0x136e6(%rip)     # 0x19ac0
movq 0x136c7(%rip), %rdi     # 0x19aa8
callq 0xa111
movq %rax, 0x136bb(%rip)     # 0x19aa8
movq 0x136b4(%rip), %rax     # 0x19aa8
movb $0x0, (%rax,%r14)
testq %r14, %r14
je 0x6410
movq 0x136a3(%rip), %rax     # 0x19aa8
movb $0x2f, -0x1(%rax,%r14)
decq %r14
jne 0x63fe
testq %r12, %r12
jne 0x6423
movq $0x0, 0x8(%rsp)
jmp 0x64ae
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq (%r12), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x6508
testq %rax, %rax
je 0x64a4
movq (%r12), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x20(%rsp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq (%r12), %rcx
cmpb $0x2f, (%rcx)
jne 0x6466
cmpb $0x0, 0x1(%rcx)
je 0x6475
leaq 0x1363b(%rip), %rdi     # 0x19aa8
movq %rax, %rsi
callq 0x67cf
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x67cf
testq %r14, %r14
je 0x648d
movq %rax, 0x10(%r14)
jmp 0x6495
movq %rax, %r14
movq %rax, 0x8(%rsp)
movq %r14, %rax
movq %rax, %r14
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x6498
movq 0x10(%r12), %r12
testq %r12, %r12
jne 0x642f
addq %r13, (%rsp)
addq %r13, %r15
movq 0x1352c(%rip), %rbx     # 0x199e8
movq 0x13535(%rip), %rbp     # 0x199f8
cmpb $0x0, (%r15)
movq 0x8(%rsp), %rcx
movq %rcx, %r12
jne 0x6363
testq %rcx, %rcx
jne 0x64f6
movl $0x18, %edi
callq 0x9f28
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rax, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rcx)
movq %rcx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq