// File: /workspace/github_c_makefile_star2_O1/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 0x49a2
movl 0x2a0(%rbx), %r13d
cmpl $0x9, %r13d
jle 0x49aa
leaq 0x1079e(%rip), %rsi     # 0x1513b
jmp 0x4b53
xorl %r13d, %r13d
xorl %r14d, %r14d
jmp 0x49ee
leal 0x1(%r13), %eax
movl %eax, 0x2a0(%rbx)
movq 0x2a8(%rbx), %r14
leaq 0x2a4(%rbx), %rax
cmpq %rax, %r14
je 0x49e2
leal 0x14(%r13), %eax
movb %al, (%r14)
movw $0x0, 0x1(%r14)
leaq 0x3(%r14), %rax
movq %rax, 0x2a8(%rbx)
jmp 0x49ea
addq $0x3, 0x2b0(%rbx)
addb $0x1e, %r13b
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x4d45
testq %rax, %rax
je 0x4b5b
testq %r14, %r14
je 0x4a19
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x5750
jmp 0x4a1c
movq %rax, %r14
movl 0x4(%rsp), %eax
testb $0x1, %al
jne 0x4a28
andb $-0x2, (%r15)
andl $0x4, %eax
orl %eax, (%r15)
movq 0x298(%rbx), %rax
cmpb $0x7c, (%rax)
jne 0x4a89
leaq 0x4(%rsp), %r12
incq %rax
movq %rax, 0x298(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4d45
testq %rax, %rax
je 0x4b5b
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x5750
movl 0x4(%rsp), %eax
testb $0x1, %al
jne 0x4a77
andb $-0x2, (%r15)
andl $0x4, %eax
orl %eax, (%r15)
movq 0x298(%rbx), %rax
cmpb $0x7c, (%rax)
je 0x4a3f
movq 0x2a8(%rbx), %r15
leaq 0x2a4(%rbx), %r12
cmpq %r12, %r15
je 0x4ab3
movb %r13b, (%r15)
movw $0x0, 0x1(%r15)
leaq 0x3(%r15), %rax
movq %rax, 0x2a8(%rbx)
jmp 0x4abb
addq $0x3, 0x2b0(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5750
movq %r14, %r13
cmpq %r13, %r12
je 0x4b0b
cmpb $0x6, (%r13)
jne 0x4ae7
leaq 0x3(%r13), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x5750
cmpq %r13, %r12
je 0x4b0b
movzwl 0x1(%r13), %eax
rolw $0x8, %ax
testw %ax, %ax
je 0x4b0b
movzwl %ax, %eax
cmpb $0x7, (%r13)
movl %eax, %eax
jne 0x4b15
subq %rax, %r13
jmp 0x4b0e
xorl %r13d, %r13d
testq %r13, %r13
jne 0x4acc
jmp 0x4b1a
addq %rax, %r13
jmp 0x4b0e
movq 0x298(%rbx), %rax
testl %ebp, %ebp
je 0x4b37
leaq 0x1(%rax), %rcx
movq %rcx, 0x298(%rbx)
cmpb $0x29, (%rax)
jne 0x4b43
jmp 0x4b5e
movzbl (%rax), %eax
testl %eax, %eax
je 0x4b5e
cmpl $0x29, %eax
jne 0x4b4c
leaq 0x105fd(%rip), %rsi     # 0x15147
jmp 0x4b53
leaq 0x10601(%rip), %rsi     # 0x15154
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