// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxUtil.c
// Function: Hax_StringMatch
int
Hax_StringMatch(
    char *string,	/* String. */
    char *pattern	/* Pattern, which may contain
				 * special characters. */)
{
    char c2;

    while (1) {
	/* See if we're at the end of both the pattern and the string.
	 * If so, we succeeded.  If we're at the end of the pattern
	 * but not at the end of the string, we failed.
	 */

	if (*pattern == 0) {
	    if (*string == 0) {
		return 1;
	    } else {
		return 0;
	    }
	}
	if ((*string == 0) && (*pattern != '*')) {
	    return 0;
	}

	/* Check for a "*" as the next pattern character.  It matches
	 * any substring.  We handle this by calling ourselves
	 * recursively for each postfix of string, until either we
	 * match or we reach the end of the string.
	 */

	if (*pattern == '*') {
	    pattern += 1;
	    if (*pattern == 0) {
		return 1;
	    }
	    while (1) {
		if (Hax_StringMatch(string, pattern)) {
		    return 1;
		}
		if (*string == 0) {
		    return 0;
		}
		string += 1;
	    }
	}

	/* Check for a "?" as the next pattern character.  It matches
	 * any single character.
	 */

	if (*pattern == '?') {
	    goto thisCharOK;
	}

	/* Check for a "[" as the next pattern character.  It is followed
	 * by a list of characters that are acceptable, or by a range
	 * (two characters separated by "-").
	 */

	if (*pattern == '[') {
	    pattern += 1;
	    while (1) {
		if ((*pattern == ']') || (*pattern == 0)) {
		    return 0;
		}
		if (*pattern == *string) {
		    break;
		}
		if (pattern[1] == '-') {
		    c2 = pattern[2];
		    if (c2 == 0) {
			return 0;
		    }
		    if ((*pattern <= *string) && (c2 >= *string)) {
			break;
		    }
		    if ((*pattern >= *string) && (c2 <= *string)) {
			break;
		    }
		    pattern += 2;
		}
		pattern += 1;
	    }
	    while ((*pattern != ']') && (*pattern != 0)) {
		pattern += 1;
	    }
	    goto thisCharOK;
	}

	/* If the next pattern character is '/', just strip off the '/'
	 * so we do exact matching on the character that follows.
	 */

	if (*pattern == '\\') {
	    pattern += 1;
	    if (*pattern == 0) {
		return 0;
	    }
	}

	/* There's no special character.  Just make sure that the next
	 * characters of each string match.
	 */

	if (*pattern != *string) {
	    return 0;
	}

	thisCharOK: pattern += 1;
	string += 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18820
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18814
movl $0x1, -0x4(%rbp)
jmp 0x18a56
movl $0x0, -0x4(%rbp)
jmp 0x18a56
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18844
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
je 0x18844
movl $0x0, -0x4(%rbp)
jmp 0x18a56
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x188ba
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18874
movl $0x1, -0x4(%rbp)
jmp 0x18a56
jmp 0x18876
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4460
cmpl $0x0, %eax
je 0x18894
movl $0x1, -0x4(%rbp)
jmp 0x18a56
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x188ac
movl $0x0, -0x4(%rbp)
jmp 0x18a56
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x18876
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0x188cb
jmp 0x18a39
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x189ed
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
je 0x188ff
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1890b
movl $0x0, -0x4(%rbp)
jmp 0x18a56
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x18922
jmp 0x189b1
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x189a0
movq -0x18(%rbp), %rax
movb 0x2(%rax), %al
movb %al, -0x19(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jne 0x1894e
movl $0x0, -0x4(%rbp)
jmp 0x18a56
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0x18971
movsbl -0x19(%rbp), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jl 0x18971
jmp 0x189b1
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jl 0x18994
movsbl -0x19(%rbp), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0x18994
jmp 0x189b1
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x188e7
jmp 0x189b3
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x5d, %ecx
movb %al, -0x1a(%rbp)
je 0x189d4
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x1a(%rbp)
movb -0x1a(%rbp), %al
testb $0x1, %al
jne 0x189dd
jmp 0x189eb
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x189b3
jmp 0x18a39
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x18a1c
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18a1a
movl $0x0, -0x4(%rbp)
jmp 0x18a56
jmp 0x18a1c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x18a37
movl $0x0, -0x4(%rbp)
jmp 0x18a56
jmp 0x18a39
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x187f0
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop