// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxRegexp.c
// Function: RegMatch
static int			/* 0 failure, 1 success */
RegMatch(
Hax_Interp *interp,
char *prog)
{
	Interp *iPtr = (Interp *) interp;
	char *scan;	/* Current node. */
	char *next;		/* Next node. */

	scan = prog;
#ifdef DEBUG
	if (scan != NULL && regnarrate)
		printf("%s(\n", Regprop(scan));
#endif
	while (scan != NULL) {
#ifdef DEBUG
		if (regnarrate)
			printf("%s...\n", Regprop(scan));
#endif
		next = RegNext(interp, scan);

		switch (OP(scan)) {
		case BOL:
			if (iPtr->reginput != iPtr->regbol)
				return(0);
			break;
		case EOL:
			if (*iPtr->reginput != '\0')
				return(0);
			break;
		case ANY:
			if (*iPtr->reginput == '\0')
				return(0);
			iPtr->reginput++;
			break;
		case EXACTLY: {
				int len;
				char *opnd;

				opnd = OPERAND(scan);
				/* Inline the first character, for speed. */
				if (*opnd != *iPtr->reginput)
					return(0);
				len = strlen(opnd);
				if (len > 1 && strncmp(opnd, iPtr->reginput, len) != 0)
					return(0);
				iPtr->reginput += len;
			}
			break;
		case ANYOF:
 			if (*iPtr->reginput == '\0' || strchr(OPERAND(scan), *iPtr->reginput) == NULL)
				return(0);
			iPtr->reginput++;
			break;
		case ANYBUT:
 			if (*iPtr->reginput == '\0' || strchr(OPERAND(scan), *iPtr->reginput) != NULL)
				return(0);
			iPtr->reginput++;
			break;
		case NOTHING:
			break;
		case BACK:
			break;
		case OPEN+1:
		case OPEN+2:
		case OPEN+3:
		case OPEN+4:
		case OPEN+5:
		case OPEN+6:
		case OPEN+7:
		case OPEN+8:
		case OPEN+9: {
				int no;
				char *save;

				no = OP(scan) - OPEN;
				save = iPtr->reginput;

				if (RegMatch(interp, next)) {
					/*
					 * Don't set startp if some later
					 * invocation of the same parentheses
					 * already has.
					 */
					if (iPtr->regstartp[no] == NULL)
						iPtr->regstartp[no] = save;
					return(1);
				} else
					return(0);
			}
			/* NOTREACHED */
		case CLOSE+1:
		case CLOSE+2:
		case CLOSE+3:
		case CLOSE+4:
		case CLOSE+5:
		case CLOSE+6:
		case CLOSE+7:
		case CLOSE+8:
		case CLOSE+9: {
				int no;
				char *save;

				no = OP(scan) - CLOSE;
				save = iPtr->reginput;

				if (RegMatch(interp, next)) {
					/*
					 * Don't set endp if some later
					 * invocation of the same parentheses
					 * already has.
					 */
					if (iPtr->regendp[no] == NULL)
						iPtr->regendp[no] = save;
					return(1);
				} else
					return(0);
			}
			/* NOTREACHED */
		case BRANCH: {
				char *save;

				if (OP(next) != BRANCH)		/* No choice. */
					next = OPERAND(scan);	/* Avoid recursion. */
				else {
					do {
						save = iPtr->reginput;
						if (RegMatch(interp, OPERAND(scan)))
							return(1);
						iPtr->reginput = save;
						scan = RegNext(interp, scan);
					} while (scan != NULL && OP(scan) == BRANCH);
					return(0);
					/* NOTREACHED */
				}
			}
			/* NOTREACHED */
			break;
		case STAR:
		case PLUS: {
				char nextch;
				int no;
				char *save;
				int min;

				/*
				 * Lookahead to avoid useless match attempts
				 * when we know what character comes next.
				 */
				nextch = '\0';
				if (OP(next) == EXACTLY)
					nextch = *OPERAND(next);
				min = (OP(scan) == STAR) ? 0 : 1;
				save = iPtr->reginput;
				no = RegRepeat(interp, OPERAND(scan));
				while (no >= min) {
					/* If it could work, try it. */
					if (nextch == '\0' || *iPtr->reginput == nextch)
						if (RegMatch(interp, next))
							return(1);
					/* Couldn't or didn't -- back up. */
					no--;
					iPtr->reginput = save + no;
				}
				return(0);
			}
			/* NOTREACHED */
		case END:
			return(1);	/* Success! */
		default:
			RegError(interp, (char *) "memory corruption");
			return(0);
		}

		scan = next;
	}

	/*
	 * We get here only if there's trouble -- normally "case END" is
	 * the terminating point.
	 */
	RegError(interp, (char *) "corrupted pointers");
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xdc4a(%rip), %r12      # 0x1302c
testq %r14, %r14
je 0x5522
movq %r14, %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4ad2
movzbl (%r14), %ebp
cmpq $0x27, %rbp
ja 0x5601
movq %rax, %r14
movslq (%r12,%rbp,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x2b8(%rbx), %rax
cmpq 0x2c0(%rbx), %rax
je 0x53e2
jmp 0x5702
movq 0x2b8(%rbx), %rax
cmpb $0x0, (%rax)
je 0x5702
incq %rax
movq %rax, 0x2b8(%rbx)
jmp 0x53e2
cmpb $0x6, (%r14)
je 0x560d
addq $0x3, %r15
movq %r15, %r14
jmp 0x53e2
movq 0x2b8(%rbx), %rax
cmpb $0x0, (%rax)
je 0x53e2
jmp 0x5702
movq 0x2b8(%rbx), %r12
movsbl (%r12), %esi
xorl %ebp, %ebp
testl %esi, %esi
je 0x5704
addq $0x3, %r15
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
je 0x54c3
jmp 0x5704
movq 0x2b8(%rbx), %r12
movsbl (%r12), %esi
xorl %ebp, %ebp
testl %esi, %esi
je 0x5704
addq $0x3, %r15
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
je 0x5704
incq %r12
jmp 0x5516
movb 0x3(%r15), %al
movq 0x2b8(%rbx), %r12
xorl %ebp, %ebp
cmpb (%r12), %al
jne 0x5704
addq $0x3, %r15
movq %r15, %rdi
callq 0x41d0
movq %rax, %r13
cmpl $0x2, %r13d
jl 0x5510
movl %r13d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r15, %rdi
movq %r12, %rsi
callq 0x40c0
testl %eax, %eax
jne 0x5704
movslq %r13d, %rax
addq %rax, %r12
movq %r12, 0x2b8(%rbx)
jmp 0x53db
leaq 0xdcd6(%rip), %rsi      # 0x131ff
movq %rbx, %rdi
callq 0x4220
jmp 0x5702
movq 0x2b8(%rbx), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53ca
testl %eax, %eax
je 0x5702
movq 0x2c8(%rbx), %rax
cmpq $0x0, -0xa0(%rax,%rbp,8)
jne 0x55a0
movq %r15, -0xa0(%rax,%rbp,8)
jmp 0x55a0
movq 0x2b8(%rbx), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53ca
testl %eax, %eax
je 0x5702
movq 0x2d0(%rbx), %rax
cmpq $0x0, -0xf0(%rax,%rbp,8)
jne 0x55a0
movq %r15, -0xf0(%rax,%rbp,8)
pushq $0x1
popq %rbp
jmp 0x5704
movl $0x0, 0x4(%rsp)
cmpb $0x8, (%r14)
jne 0x55bf
movsbl 0x3(%r14), %eax
movl %eax, 0x4(%rsp)
movq 0x2b8(%rbx), %r12
movzbl 0x3(%r15), %eax
addl $-0x3, %eax
cmpl $0x5, %eax
ja 0x56a5
addq $0x6, %r15
leaq 0xdaea(%rip), %rcx      # 0x130cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x41d0
movq %rax, %r13
movslq %r13d, %rax
addq %r12, %rax
jmp 0x56ba
leaq 0xdbe5(%rip), %rsi      # 0x131ed
jmp 0x5529
movq 0x2b8(%rbx), %r14
xorl %ebp, %ebp
leaq 0x3(%r15), %rsi
movq %rbx, %rdi
callq 0x53ca
testl %eax, %eax
jne 0x55a0
movq %r14, 0x2b8(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4ad2
testq %rax, %rax
je 0x5704
movq %rax, %r15
cmpb $0x6, (%rax)
je 0x5616
jmp 0x5704
xorl %r13d, %r13d
movsbl (%r12,%r13), %esi
testl %esi, %esi
je 0x569f
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
jne 0x569f
incq %r13
jmp 0x5655
xorl %r13d, %r13d
movsbl (%r12,%r13), %esi
testl %esi, %esi
je 0x569f
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
je 0x569f
incq %r13
jmp 0x5673
movb (%r15), %al
xorl %r13d, %r13d
cmpb (%r12,%r13), %al
jne 0x569f
incq %r13
jmp 0x5694
leaq (%r12,%r13), %rax
jmp 0x56ba
leaq 0xdb66(%rip), %rsi      # 0x13212
movq %rbx, %rdi
callq 0x4220
xorl %r13d, %r13d
movq %r12, %rax
xorl %r15d, %r15d
cmpb $0xa, %bpl
setne %r15b
movslq %r13d, %r13
decq %r12
movl 0x4(%rsp), %ebp
movq %rax, 0x2b8(%rbx)
cmpq %r15, %r13
jl 0x5702
testl %ebp, %ebp
je 0x56e6
movsbl (%rax), %eax
cmpl %eax, %ebp
jne 0x56f9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53ca
testl %eax, %eax
jne 0x55a0
leaq (%r12,%r13), %rax
decq %r13
jmp 0x56cf
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)