// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxRegexp.c
// Function: Reg
static char *
Reg(
Hax_Interp *interp,
int paren,			/* Parenthesized? */
int *flagp)
{
	Interp *iPtr = (Interp *) interp;
	char *ret;
	char *br;
	char *ender;
	int parno = 0;
	int flags;

	*flagp = HASWIDTH;	/* Tentatively. */

	/* Make an OPEN node, if parenthesized. */
	if (paren) {
		if (iPtr->regnpar >= NSUBEXP)
			FAIL((char *) "too many ()");
		parno = iPtr->regnpar;
		iPtr->regnpar++;
		ret = RegNode(interp, OPEN+parno);
	} else
		ret = NULL;

	/* Pick up the branches, linking them together. */
	br = RegBranch(interp, &flags);
	if (br == NULL)
		return(NULL);
	if (ret != NULL)
		RegTail(interp, ret, br);	/* OPEN -> first. */
	else
		ret = br;
	if (!(flags&HASWIDTH))
		*flagp &= ~HASWIDTH;
	*flagp |= flags&SPSTART;
	while (*iPtr->regparse == '|') {
		iPtr->regparse++;
		br = RegBranch(interp, &flags);
		if (br == NULL)
			return(NULL);
		RegTail(interp, ret, br);	/* BRANCH -> BRANCH. */
		if (!(flags&HASWIDTH))
			*flagp &= ~HASWIDTH;
		*flagp |= flags&SPSTART;
	}

	/* Make a closing node, and hook it on the end. */
	ender = RegNode(interp, (paren) ? CLOSE+parno : END);
	RegTail(interp, ret, ender);

	/* Hook the tails of the branches to the closing node. */
	for (br = ret; br != NULL; br = RegNext(interp, br))
		RegOpTail(interp, br, ender);

	/* Check for proper termination. */
	if (paren && *iPtr->regparse++ != ')') {
		FAIL((char *) "unmatched ()");
	} else if (!paren && *iPtr->regparse != '\0') {
		if (*iPtr->regparse == ')') {
			FAIL((char *) "unmatched ()");
		} else
			FAIL((char *) "junk on end");	/* "Can't happen". */
		/* NOTREACHED */
	}

	return(ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
movl $0x1, (%rdx)
testl %esi, %esi
je 0x49a6
movl 0x2a0(%rbx), %r13d
cmpl $0x9, %r13d
jle 0x49c0
leaq 0xf79a(%rip), %rsi      # 0x1413b
jmp 0x4b6e
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x4d53
xorl %r13d, %r13d
testq %rax, %rax
jne 0x4a2f
jmp 0x4b76
leal 0x1(%r13), %eax
movl %eax, 0x2a0(%rbx)
movq 0x2a8(%rbx), %r14
leaq 0x2a4(%rbx), %rax
cmpq %rax, %r14
je 0x49f8
leal 0x14(%r13), %eax
movb %al, (%r14)
movw $0x0, 0x1(%r14)
leaq 0x3(%r14), %rax
movq %rax, 0x2a8(%rbx)
jmp 0x4a00
addq $0x3, 0x2b0(%rbx)
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x4d53
testq %rax, %rax
je 0x4b76
addb $0x1e, %r13b
testq %r14, %r14
je 0x4a2f
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x56d2
jmp 0x4a32
movq %rax, %r14
movl 0x4(%rsp), %eax
movl (%r15), %ecx
movl %ecx, %edx
andl $-0x2, %edx
testb $0x1, %al
cmovnel %ecx, %edx
andl $0x4, %eax
orl %edx, %eax
movl %eax, (%r15)
movq 0x298(%rbx), %rax
cmpb $0x7c, (%rax)
jne 0x4aad
leaq 0x4(%rsp), %r12
incq %rax
movq %rax, 0x298(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4d53
testq %rax, %rax
je 0x4b76
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x56d2
movl 0x4(%rsp), %eax
movl (%r15), %ecx
movl %ecx, %edx
andl $-0x2, %edx
testb $0x1, %al
cmovnel %ecx, %edx
andl $0x4, %eax
orl %edx, %eax
movl %eax, (%r15)
movq 0x298(%rbx), %rax
cmpb $0x7c, (%rax)
je 0x4a5c
movq 0x2a8(%rbx), %r15
leaq 0x2a4(%rbx), %r12
cmpq %r12, %r15
je 0x4ad7
movb %r13b, (%r15)
movw $0x0, 0x1(%r15)
leaq 0x3(%r15), %rax
movq %rax, 0x2a8(%rbx)
jmp 0x4adf
addq $0x3, 0x2b0(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x56d2
cmpq %r14, %r12
je 0x4b35
movq %r14, %r13
cmpb $0x6, (%r13)
jne 0x4b0b
leaq 0x3(%r13), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x56d2
movzwl 0x1(%r13), %eax
rolw $0x8, %ax
testw %ax, %ax
je 0x4b35
movzwl %ax, %eax
movl %eax, %eax
movq %rax, %rcx
negq %rcx
cmpb $0x7, (%r13)
cmovneq %rax, %rcx
addq %rcx, %r13
cmpq %r13, %r12
jne 0x4af5
movq 0x298(%rbx), %rax
testl %ebp, %ebp
je 0x4b52
leaq 0x1(%rax), %rcx
movq %rcx, 0x298(%rbx)
cmpb $0x29, (%rax)
jne 0x4b5e
jmp 0x4b79
movzbl (%rax), %eax
testl %eax, %eax
je 0x4b79
cmpl $0x29, %eax
jne 0x4b67
leaq 0xf5e2(%rip), %rsi      # 0x14147
jmp 0x4b6e
leaq 0xf5e6(%rip), %rsi      # 0x14154
movq %rbx, %rdi
callq 0x4220
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq