// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxRegexp.c
// Function: RegComp
regexp *
RegComp(Hax_Interp *interp, char *exp)
{
	Interp *iPtr = (Interp *) interp;
	Hax_Memoryp *memoryp = iPtr->memoryp;
	regexp *r;
	char *scan;
	char *longest;
	int len;
	int flags;

	if (exp == NULL)
		FAIL((char *) "NULL argument");

	/* First pass: determine size, legality. */
	iPtr->regparse = exp;
	iPtr->regnpar = 1;
	iPtr->regsize = 0L;
	iPtr->regcode = &iPtr->regdummy;
	RegC(interp, MAGIC);
	if (Reg(interp, 0, &flags) == NULL)
		return(NULL);

	/* Small enough for pointer-storage convention? */
	if (iPtr->regsize >= 32767L)		/* Probably could be 65535L. */
		FAIL((char *) "regexp too big");

	/* Allocate space. */
	r = (regexp *)ckalloc(memoryp, sizeof(regexp) + (unsigned)iPtr->regsize);
	if (r == NULL)
		FAIL((char *) "out of space");

	/* Second pass: emit code. */
	iPtr->regparse = exp;
	iPtr->regnpar = 1;
	iPtr->regcode = r->program;
	RegC(interp, MAGIC);
	if (Reg(interp, 0, &flags) == NULL)
		return(NULL);

	/* Dig out information for optimizations. */
	r->regstart = '\0';	/* Worst-case defaults. */
	r->reganch = 0;
	r->regmust = NULL;
	r->regmlen = 0;
	scan = r->program+1;			/* First BRANCH. */
	if (OP(RegNext(interp, scan)) == END) {		/* Only one top-level choice. */
		scan = OPERAND(scan);

		/* Starting-point info. */
		if (OP(scan) == EXACTLY)
			r->regstart = *OPERAND(scan);
		else if (OP(scan) == BOL)
			r->reganch++;

		/*
		 * If there's something expensive in the r.e., find the
		 * longest literal string that must appear and make it the
		 * regmust.  Resolve ties in favor of later strings, since
		 * the regstart check works with the beginning of the r.e.
		 * and avoiding duplication strengthens checking.  Not a
		 * strong reason, but sufficient in the absence of others.
		 */
		if (flags&SPSTART) {
			longest = NULL;
			len = 0;
			for (; scan != NULL; scan = RegNext(interp, scan))
				if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
					longest = OPERAND(scan);
					len = strlen(OPERAND(scan));
				}
			r->regmust = longest;
			r->regmlen = len;
		}
	}

	return(r);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x477d
jmp 0x4760
movq -0x10(%rbp), %rdi
leaq 0x1894d(%rip), %rsi     # 0x1d0b8
callq 0x4200
movq $0x0, -0x8(%rbp)
jmp 0x4a1f
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x298(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x2a0(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x2b0(%rax)
movq -0x20(%rbp), %rcx
addq $0x2a4, %rcx            # imm = 0x2A4
movq -0x20(%rbp), %rax
movq %rcx, 0x2a8(%rax)
movq -0x10(%rbp), %rdi
movl $0xffffff9c, %esi       # imm = 0xFFFFFF9C
callq 0x4a30
movq -0x10(%rbp), %rdi
xorl %esi, %esi
leaq -0x48(%rbp), %rdx
callq 0x4aa0
cmpq $0x0, %rax
jne 0x47ef
movq $0x0, -0x8(%rbp)
jmp 0x4a1f
movq -0x20(%rbp), %rax
cmpq $0x7fff, 0x2b0(%rax) # imm = 0x7FFF
jl 0x481f
jmp 0x4802
movq -0x10(%rbp), %rdi
leaq 0x188b9(%rip), %rsi     # 0x1d0c6
callq 0x4200
movq $0x0, -0x8(%rbp)
jmp 0x4a1f
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x2b0(%rax), %rax
movl %eax, %eax
movl %eax, %esi
addq $0xb8, %rsi
leaq 0x18895(%rip), %rdx     # 0x1d0d5
movl $0xdd, %ecx
callq 0x44c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4874
jmp 0x4857
movq -0x10(%rbp), %rdi
leaq 0x1887f(%rip), %rsi     # 0x1d0e1
callq 0x4200
movq $0x0, -0x8(%rbp)
jmp 0x4a1f
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x298(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x2a0(%rax)
movq -0x30(%rbp), %rcx
addq $0xb4, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x2a8(%rax)
movq -0x10(%rbp), %rdi
movl $0xffffff9c, %esi       # imm = 0xFFFFFF9C
callq 0x4a30
movq -0x10(%rbp), %rdi
xorl %esi, %esi
leaq -0x48(%rbp), %rdx
callq 0x4aa0
cmpq $0x0, %rax
jne 0x48d7
movq $0x0, -0x8(%rbp)
jmp 0x4a1f
movq -0x30(%rbp), %rax
movb $0x0, 0xa0(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0xa1(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0xb0(%rax)
movq -0x30(%rbp), %rax
addq $0xb4, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4d70
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4a17
movq -0x38(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x8, %eax
jne 0x4960
movq -0x38(%rbp), %rax
movb 0x3(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0xa0(%rax)
jmp 0x4981
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x1, %eax
jne 0x497f
movq -0x30(%rbp), %rax
movb 0xa1(%rax), %cl
addb $0x1, %cl
movb %cl, 0xa1(%rax)
jmp 0x4981
movl -0x48(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4a15
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x49f9
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x8, %eax
jne 0x49e4
movq -0x38(%rbp), %rdi
addq $0x3, %rdi
callq 0x41b0
movslq -0x44(%rbp), %rcx
cmpq %rcx, %rax
jb 0x49e4
movq -0x38(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
addq $0x3, %rdi
callq 0x41b0
movl %eax, -0x44(%rbp)
jmp 0x49e6
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4d70
movq %rax, -0x38(%rbp)
jmp 0x499f
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl -0x44(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xb0(%rax)
jmp 0x4a17
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)