// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
testq %rsi, %rsi
je 0x58b3
movq %rsi, %r15
leaq 0x2a4(%rdi), %rcx
leaq 0xe8ea(%rip), %rbx      # 0x1402c
movq %rdi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
cmpq %r15, %rcx
je 0x5775
movzwl 0x1(%r15), %eax
rolw $0x8, %ax
testw %ax, %ax
je 0x5775
movzwl %ax, %eax
movb (%r15), %r12b
movl %eax, %eax
cmpb $0x7, %r12b
jne 0x57b0
movq %r15, %r14
subq %rax, %r14
jmp 0x5778
xorl %r14d, %r14d
movb (%r15), %r12b
cmpb $0x27, %r12b
ja 0x59a0
movl $0x1, %ebp
movzbl %r12b, %r13d
movslq (%rbx,%r13,4), %rax
addq %rbx, %rax
jmpq *%rax
movq 0x2b8(%rdi), %rax
cmpq 0x2c0(%rdi), %rax
je 0x58a7
jmp 0x58bf
addq %r15, %rax
movq %rax, %r14
jmp 0x577b
cmpb $0x6, (%r14)
je 0x59ac
addq $0x3, %r15
movq %r15, %r14
jmp 0x58a7
movb 0x3(%r15), %al
movq 0x2b8(%rdi), %r12
xorl %ebp, %ebp
cmpb (%r12), %al
jne 0x58c1
addq $0x3, %r15
movq %r15, %rdi
callq 0x41d0
movq %rax, %r13
cmpl $0x2, %r13d
jl 0x5816
movl %r13d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r15, %rdi
movq %r12, %rsi
callq 0x40c0
testl %eax, %eax
jne 0x58c1
movslq %r13d, %rax
addq %rax, %r12
jmp 0x5896
movq 0x2b8(%rdi), %rax
cmpb $0x0, (%rax)
je 0x58a7
jmp 0x58bf
movq 0x2b8(%rdi), %rax
cmpb $0x0, (%rax)
je 0x58bf
incq %rax
movq %rax, 0x2b8(%rdi)
jmp 0x58a7
movq 0x2b8(%rdi), %r12
movsbl (%r12), %esi
xorl %ebp, %ebp
testl %esi, %esi
je 0x58c1
addq $0x3, %r15
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
jne 0x5893
jmp 0x58c1
movq 0x2b8(%rdi), %r12
movsbl (%r12), %esi
xorl %ebp, %ebp
testl %esi, %esi
je 0x58c1
addq $0x3, %r15
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
jne 0x58c1
incq %r12
movq 0x8(%rsp), %rdi
movq %r12, 0x2b8(%rdi)
movq 0x10(%rsp), %rcx
movq %r14, %r15
testq %r14, %r14
jne 0x574c
leaq 0xe945(%rip), %rsi      # 0x141ff
callq 0x4220
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b8(%rdi), %rbx
movq %rdi, %r15
movq %r14, %rsi
callq 0x571a
testl %eax, %eax
je 0x58bf
movq 0x2c8(%r15), %rax
cmpq $0x0, -0xa0(%rax,%r13,8)
jne 0x58c1
movq %rbx, -0xa0(%rax,%r13,8)
jmp 0x5934
movq 0x2b8(%rdi), %rbx
movq %rdi, %r15
movq %r14, %rsi
callq 0x571a
testl %eax, %eax
je 0x58bf
movq 0x2d0(%r15), %rax
cmpq $0x0, -0xf0(%rax,%r13,8)
jne 0x58c1
movq %rbx, -0xf0(%rax,%r13,8)
movl $0x1, %ebp
jmp 0x58c1
xorl %edx, %edx
cmpb $0x8, (%r14)
jne 0x5948
movsbl 0x3(%r14), %edx
xorl %esi, %esi
cmpb $0xa, %r12b
setne %sil
movq 0x2b8(%rdi), %rbx
movzbl 0x3(%r15), %eax
addl $-0x3, %eax
cmpl $0x5, %eax
ja 0x5aa2
addq $0x6, %r15
leaq 0xe757(%rip), %rcx      # 0x140cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movl %edx, %ebp
movl %esi, %r15d
callq 0x41d0
movl %r15d, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rdi
movq %rax, %r13
movslq %r13d, %rax
jmp 0x5a9d
leaq 0xe846(%rip), %rsi      # 0x141ed
jmp 0x58ba
movq 0x2b8(%rdi), %rbx
movq 0x8(%rsp), %r14
xorl %ebp, %ebp
leaq 0x3(%r15), %rsi
movq %r14, %rdi
callq 0x571a
testl %eax, %eax
jne 0x5934
movq %rbx, 0x2b8(%r14)
cmpq %r15, 0x10(%rsp)
je 0x58c1
movzwl 0x1(%r15), %eax
rolw $0x8, %ax
testw %ax, %ax
je 0x58c1
movzwl %ax, %eax
movl %eax, %eax
movq %rax, %rcx
negq %rcx
cmpb $0x7, (%r15)
cmovneq %rax, %rcx
cmpb $0x6, (%r15,%rcx)
leaq (%r15,%rcx), %r15
je 0x59ba
jmp 0x58c1
movb (%rbx), %al
testb %al, %al
je 0x5ac2
movl %esi, 0x10(%rsp)
movl %edx, %ebp
xorl %r13d, %r13d
movsbl %al, %esi
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
jne 0x5a71
movb 0x1(%rbx,%r13), %al
incq %r13
testb %al, %al
jne 0x5a28
jmp 0x5a71
movb (%rbx), %al
testb %al, %al
je 0x5ac2
movl %esi, 0x10(%rsp)
movl %edx, %ebp
xorl %r13d, %r13d
movsbl %al, %esi
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
je 0x5a71
movb 0x1(%rbx,%r13), %al
incq %r13
testb %al, %al
jne 0x5a55
movq %r13, %rax
addq %rbx, %rax
movq 0x8(%rsp), %rdi
movl %ebp, %edx
movl 0x10(%rsp), %esi
jmp 0x5ac8
movb (%r15), %al
cmpb (%rbx), %al
jne 0x5ac2
xorl %r13d, %r13d
movq %r13, %rcx
incq %r13
cmpb 0x1(%rbx,%rcx), %al
je 0x5a8e
movq %r13, %rax
addq %rbx, %rax
jmp 0x5ac8
movl %esi, %r15d
leaq 0xe766(%rip), %rsi      # 0x14212
movq 0x8(%rsp), %rdi
movl %edx, %ebp
callq 0x4220
movl %r15d, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rdi
xorl %r13d, %r13d
movq %rbx, %rax
movq %rax, 0x2b8(%rdi)
xorl %ebp, %ebp
cmpl %esi, %r13d
jl 0x58c1
xorl %ecx, %ecx
cmpb $0xa, %r12b
setne %cl
movq %rcx, 0x10(%rsp)
movslq %r13d, %r12
leaq 0x1(%r12), %r13
testl %edx, %edx
je 0x5afb
movsbl (%rax), %eax
cmpl %eax, %edx
jne 0x5b1f
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %r15
movl %edx, %ebx
callq 0x571a
movl %ebx, %edx
movq %r15, %rbx
movq 0x8(%rsp), %rdi
testl %eax, %eax
jne 0x5934
leaq (%rbx,%r12), %rax
decq %rax
decq %r12
leaq (%rbx,%r13), %rcx
addq $-0x2, %rcx
movq %rcx, 0x2b8(%rdi)
decq %r13
cmpq 0x10(%rsp), %r13
jg 0x5af0
jmp 0x58c1
nop