// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: pattern_match
static int pattern_match (	/* 0:mismatched, 1:matched */
	const TCHAR* pat,	/* Matching pattern */
	const TCHAR* nam,	/* String to be tested */
	UINT skip,			/* Number of pre-skip chars (number of ?s, b8:infinite (* specified)) */
	UINT recur			/* Recursion count */
)
{
	const TCHAR *pptr, *nptr;
	DWORD pchr, nchr;
	UINT sk;


	while ((skip & 0xFF) != 0) {		/* Pre-skip name chars */
		if (!get_achar(&nam)) return 0;	/* Branch mismatched if less name chars */
		skip--;
	}
	if (*pat == 0 && skip) return 1;	/* Matched? (short circuit) */

	do {
		pptr = pat; nptr = nam;			/* Top of pattern and name to match */
		for (;;) {
			if (*pptr == '?' || *pptr == '*') {	/* Wildcard term? */
				if (recur == 0) return 0;	/* Too many wildcard terms? */
				sk = 0;
				do {	/* Analyze the wildcard term */
					if (*pptr++ == '?') sk++; else sk |= 0x100;
				} while (*pptr == '?' || *pptr == '*');
				if (pattern_match(pptr, nptr, sk, recur - 1)) return 1;	/* Test new branch (recursive call) */
				nchr = *nptr; break;	/* Branch mismatched */
			}
			pchr = get_achar(&pptr);	/* Get a pattern char */
			nchr = get_achar(&nptr);	/* Get a name char */
			if (pchr != nchr) break;	/* Branch mismatched? */
			if (pchr == 0) return 1;	/* Branch matched? (matched at end of both strings) */
		}
		get_achar(&nam);			/* nam++ */
	} while (skip && nchr);		/* Retry until end of name if infinite search is specified */

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x18(%rsp)
movl %edx, %ebp
movq %rdi, %r14
movq %rsi, 0x8(%rsp)
testb %bpl, %bpl
je 0x7e49
leaq 0x8(%rsp), %r12
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x930e
cmpl $-0x1, %eax
cmovel %r15d, %eax
movl %eax, %edi
callq 0xbe55
testl %eax, %eax
je 0x7e59
decl %ebp
testb %bpl, %bpl
jne 0x7e28
testl %ebp, %ebp
je 0x7e6b
cmpb $0x0, (%r14)
jne 0x7e6b
movl $0x1, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x14(%rsp)
movq %rsp, %r13
leaq 0x20(%rsp), %r12
movq %r14, (%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
movzbl (%rax), %eax
cmpl $0x3f, %eax
je 0x7edc
cmpl $0x2a, %eax
je 0x7edc
movq %r13, %rdi
callq 0x930e
xorl %ebx, %ebx
cmpl $-0x1, %eax
cmovel %ebx, %eax
movl %eax, %edi
callq 0xbe55
movl %eax, %r15d
movq %r12, %rdi
callq 0x930e
cmpl $-0x1, %eax
je 0x7ec6
movl %eax, %ebx
movl %ebx, %edi
callq 0xbe55
cmpl %eax, %r15d
jne 0x7f30
testl %r15d, %r15d
jne 0x7e8c
jmp 0x7e53
cmpl $0x0, 0x18(%rsp)
je 0x7f62
movq (%rsp), %rdi
incq %rdi
xorl %edx, %edx
leal 0x1(%rdx), %eax
orl $0x100, %edx            # imm = 0x100
cmpb $0x3f, -0x1(%rdi)
cmovel %eax, %edx
movzbl (%rdi), %eax
cmpl $0x3f, %eax
je 0x7f09
cmpl $0x2a, %eax
jne 0x7f0e
incq %rdi
jmp 0x7eec
movq %rdi, (%rsp)
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
movl 0x14(%rsp), %ecx
callq 0x7dfe
testl %eax, %eax
jne 0x7e53
movsbl (%rbx), %ebx
jmp 0x7f32
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x930e
xorl %r15d, %r15d
cmpl $-0x1, %eax
cmovel %r15d, %eax
movl %eax, %edi
callq 0xbe55
testl %ebp, %ebp
je 0x7e59
testl %ebx, %ebx
jne 0x7e7e
jmp 0x7e59
xorl %r15d, %r15d
jmp 0x7e59