// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxUtil.c
// Function: HaxCompileRegexp
regexp *
HaxCompileRegexp(
    Hax_Interp *interp,			/* For use in error reporting. */
    char *string			/* String for which to produce
					 * compiled regular expression. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int i, length;
    regexp *result;

    length = strlen(string);
    for (i = 0; i < NUM_REGEXPS; i++) {
	if ((length == iPtr->patLengths[i])
		&& (strcmp(string, iPtr->patterns[i]) == 0)) {
	    /*
	     * Move the matched pattern to the first slot in the
	     * cache and shift the other patterns down one position.
	     */

	    if (i != 0) {
		int j;
		char *cachedString;

		cachedString = iPtr->patterns[i];
		result = iPtr->regexps[i];
		for (j = i-1; j >= 0; j--) {
		    iPtr->patterns[j+1] = iPtr->patterns[j];
		    iPtr->patLengths[j+1] = iPtr->patLengths[j];
		    iPtr->regexps[j+1] = iPtr->regexps[j];
		}
		iPtr->patterns[0] = cachedString;
		iPtr->patLengths[0] = length;
		iPtr->regexps[0] = result;
	    }
	    return iPtr->regexps[0];
	}
    }

    /*
     * No match in the cache.  Compile the string and add it to the
     * cache.
     */

    iPtr->haxRegexpError = NULL;
    result = RegComp(interp, string);
    if (iPtr->haxRegexpError != NULL) {
	Hax_AppendResult(interp,
	    "couldn't compile regular expression pattern: ",
	    iPtr->haxRegexpError, (char *) NULL);
	return NULL;
    }
    if (iPtr->patterns[NUM_REGEXPS-1] != NULL) {
	ckfree(memoryp, iPtr->patterns[NUM_REGEXPS-1]);
	ckfree(memoryp, (char *) iPtr->regexps[NUM_REGEXPS-1]);
    }
    for (i = NUM_REGEXPS - 2; i >= 0; i--) {
	iPtr->patterns[i+1] = iPtr->patterns[i];
	iPtr->patLengths[i+1] = iPtr->patLengths[i];
	iPtr->regexps[i+1] = iPtr->regexps[i];
    }
    iPtr->patterns[0] = (char *) ckalloc(memoryp, (unsigned) (length+1));
    strcpy(iPtr->patterns[0], string);
    iPtr->patLengths[0] = length;
    iPtr->regexps[0] = result;
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq 0x280(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rsi, %rdi
callq 0x41d0
movq %rax, %r14
leaq 0x128(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x168(%rbx), %r13
xorl %r15d, %r15d
cmpl %r14d, -0x18(%r13,%r15,4)
jne 0x1193e
movq -0x40(%r13,%r15,8), %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4320
testl %eax, %eax
je 0x11984
incq %r15
cmpq $0x5, %r15
jne 0x11923
movq $0x0, 0x290(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40d0
movq 0x290(%rbx), %rdx
testq %rdx, %rdx
je 0x1199d
leaq 0x4820(%rip), %rsi      # 0x16190
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4510
jmp 0x11aba
movq %r15, %rax
subq $0x1, %rax
jae 0x11a5d
movq 0x168(%rbx), %r15
jmp 0x11aba
movq %rax, %r15
movq 0x148(%rbx), %rsi
testq %rsi, %rsi
movq 0x10(%rsp), %r13
je 0x119df
leaq 0x4786(%rip), %rbp      # 0x1613e
movq %r13, %rdi
movq %rbp, %rdx
movl $0x582, %ecx            # imm = 0x582
callq 0x4280
movq 0x188(%rbx), %rsi
movq %r13, %rdi
movq %rbp, %rdx
movl $0x583, %ecx            # imm = 0x583
callq 0x4280
movq 0x8(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x140(%rbx)
movups %xmm0, 0x130(%rbx)
movq 0x150(%rbx), %rax
movq 0x158(%rbx), %rcx
movq %rcx, 0x15c(%rbx)
movups 0x178(%rbx), %xmm0
movups %xmm0, 0x180(%rbx)
movq %rax, 0x154(%rbx)
movups 0x168(%rbx), %xmm0
movups %xmm0, 0x170(%rbx)
leal 0x1(%r14), %esi
leaq 0x4702(%rip), %rdx      # 0x1613e
movq %r13, %rdi
movl $0x58a, %ecx            # imm = 0x58A
callq 0x44d0
movq %rax, 0x128(%rbx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x40f0
jmp 0x11aac
movq 0x168(%rbx,%r15,8), %r15
movl %eax, %ecx
movq 0x128(%rbx,%rcx,8), %rdx
movq %rdx, 0x130(%rbx,%rax,8)
movl 0x150(%rbx,%rcx,4), %edx
movl %edx, 0x154(%rbx,%rax,4)
movq 0x168(%rbx,%rcx,8), %rcx
movq %rcx, 0x170(%rbx,%rax,8)
leaq -0x1(%rax), %rcx
incq %rax
cmpq $0x1, %rax
movq %rcx, %rax
jg 0x11a65
movq %rbp, 0x128(%rbx)
movl %r14d, 0x150(%rbx)
movq %r15, 0x168(%rbx)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq