// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq 0x280(%rdi), %rax
movq %rax, (%rsp)
movq %rsi, %rdi
callq 0x41d0
movq %rax, %r14
leaq 0x168(%rbx), %r12
xorl %r13d, %r13d
cmpq $0x5, %r13
je 0x10ac1
cmpl %r14d, -0x18(%r12,%r13,4)
jne 0x10abc
movq -0x40(%r12,%r13,8), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4330
testl %eax, %eax
je 0x10afb
incq %r13
jmp 0x10a9b
andq $0x0, 0x290(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40d0
movq 0x290(%rbx), %rdx
testq %rdx, %rdx
je 0x10b4a
leaq 0x4679(%rip), %rsi      # 0x15160
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4520
jmp 0x10c14
testq %r13, %r13
je 0x10c0d
movq 0x168(%rbx,%r13,8), %r12
testq %r13, %r13
jle 0x10bf6
movq 0x120(%rbx,%r13,8), %rax
movq %rax, 0x128(%rbx,%r13,8)
movl 0x14c(%rbx,%r13,4), %eax
movl %eax, 0x150(%rbx,%r13,4)
movq 0x160(%rbx,%r13,8), %rax
movq %rax, 0x168(%rbx,%r13,8)
decq %r13
jmp 0x10b0c
movq %rax, %r12
movq 0x148(%rbx), %rsi
testq %rsi, %rsi
movq (%rsp), %r13
je 0x10b8b
leaq 0x45aa(%rip), %rbp      # 0x1510e
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
xorl %eax, %eax
leaq 0x3(%rax), %rcx
testl %ecx, %ecx
js 0x10bca
movl %ecx, %ecx
movq 0x128(%rbx,%rcx,8), %rdx
movq %rdx, 0x148(%rbx,%rax,8)
movl 0x150(%rbx,%rcx,4), %edx
movl %edx, 0x160(%rbx,%rax,4)
movq 0x168(%rbx,%rcx,8), %rcx
movq %rcx, 0x188(%rbx,%rax,8)
decq %rax
jmp 0x10b8d
leal 0x1(%r14), %esi
leaq 0x4539(%rip), %rdx      # 0x1510e
movq %r13, %rdi
movl $0x58a, %ecx            # imm = 0x58A
callq 0x44e0
movq %rax, 0x128(%rbx)
movq %rax, %rdi
movq %r15, %rsi
callq 0x40f0
jmp 0x10bfd
movq %rbp, 0x128(%rbx)
movl %r14d, 0x150(%rbx)
movq %r12, 0x168(%rbx)
jmp 0x10c14
movq 0x168(%rbx), %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq