// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl -0x1c(%rbp), %eax
andl $0xff, %eax
cmpl $0x0, %eax
je 0x8e58
leaq -0x18(%rbp), %rdi
callq 0xfcf0
cmpl $0x0, %eax
jne 0x8e4d
movl $0x0, -0x4(%rbp)
jmp 0x8faa
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8e26
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x8e76
cmpl $0x0, -0x1c(%rbp)
je 0x8e76
movl $0x1, -0x4(%rbp)
jmp 0x8faa
jmp 0x8e78
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
je 0x8ea4
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x8f44
cmpl $0x0, -0x20(%rbp)
jne 0x8eb6
movl $0x0, -0x4(%rbp)
jmp 0x8faa
movl $0x0, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0x8edf
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8eea
movl -0x3c(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x3c(%rbp)
jmp 0x8eec
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x3f, %ecx
movb %al, -0x3d(%rbp)
je 0x8f0d
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
sete %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x8ebd
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
callq 0x8e10
cmpl $0x0, %eax
je 0x8f38
movl $0x1, -0x4(%rbp)
jmp 0x8faa
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x38(%rbp)
jmp 0x8f7a
leaq -0x28(%rbp), %rdi
callq 0xfcf0
movl %eax, -0x34(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xfcf0
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x8f66
jmp 0x8f7a
cmpl $0x0, -0x34(%rbp)
jne 0x8f75
movl $0x1, -0x4(%rbp)
jmp 0x8faa
jmp 0x8e88
leaq -0x18(%rbp), %rdi
callq 0xfcf0
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x3e(%rbp)
je 0x8f98
cmpl $0x0, -0x38(%rbp)
setne %al
movb %al, -0x3e(%rbp)
movb -0x3e(%rbp), %al
testb $0x1, %al
jne 0x8e78
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)