// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxCmdMZ.c
// Function: Hax_RegexpCmd
int
Hax_RegexpCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int noCase = 0;
    int indices = 0;
    regexp *regexpPtr;
    char **argPtr, *string;
    int match, i;

    if (argc < 3) {
	wrongNumArgs:
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" ?-nocase? exp string ?matchVar? ?subMatchVar ",
		"subMatchVar ...?\"", (char *) NULL);
	return HAX_ERROR;
    }
    argPtr = argv+1;
    argc--;
    while ((argc > 0) && (argPtr[0][0] == '-')) {
	if (strcmp(argPtr[0], "-indices") == 0) {
	    argPtr++;
	    argc--;
	    indices = 1;
	} else if (strcmp(argPtr[0], "-nocase") == 0) {
	    argPtr++;
	    argc--;
	    noCase = 1;
	} else {
	    break;
	}
    }
    if (argc < 2) {
	goto wrongNumArgs;
    }
    regexpPtr = HaxCompileRegexp(interp, argPtr[0]);
    if (regexpPtr == NULL) {
	return HAX_ERROR;
    }

    /*
     * Convert the string to lower case, if desired, and perform
     * the match.
     */

    if (noCase) {
	char *dst, *src;

	string = (char *) ckalloc(memoryp, (unsigned) (strlen(argPtr[1]) + 1));
	for (src = argPtr[1], dst = string; *src != 0; src++, dst++) {
	    if (isupper(*src)) {
		*dst = tolower(*src);
	    } else {
		*dst = *src;
	    }
	}
	*dst = 0;
    } else {
	string = argPtr[1];
    }
    iPtr->haxRegexpError = NULL;
    match = RegExec(interp, regexpPtr, string);
    if (string != argPtr[1]) {
	ckfree(memoryp, string);
    }
    if (iPtr->haxRegexpError != NULL) {
	Hax_AppendResult(interp, "error while matching pattern: ",
		iPtr->haxRegexpError, (char *) NULL);
	return HAX_ERROR;
    }
    if (!match) {
	interp->result = (char *) "0";
	return HAX_OK;
    }

    /*
     * If additional variable names have been specified, return
     * index information in those variables.
     */

    argc -= 2;
    if (argc > NSUBEXP) {
	interp->result = (char *) "too many substring variables";
	return HAX_ERROR;
    }
    for (i = 0; i < argc; i++) {
	char *result, info[50];

	if (regexpPtr->startp[i] == NULL) {
	    if (indices) {
		result = Hax_SetVar(interp, argPtr[i+2], (char *) "-1 -1", 0);
	    } else {
		result = Hax_SetVar(interp, argPtr[i+2], (char *) "", 0);
	    }
	} else {
	    if (indices) {
		sprintf(info, "%ld %ld", regexpPtr->startp[i] - string,
			regexpPtr->endp[i] - string - 1);
		result = Hax_SetVar(interp, argPtr[i+2], info, 0);
	    } else {
		char savedChar, *first, *last;

		first = argPtr[1] + (regexpPtr->startp[i] - string);
		last = argPtr[1] + (regexpPtr->endp[i] - string);
		savedChar = *last;
		*last = 0;
		result = Hax_SetVar(interp, argPtr[i+2], first, 0);
		*last = savedChar;
	    }
	}
	if (result == NULL) {
	    Hax_AppendResult(interp, "couldn't set variable \"",
		    argPtr[i+2], "\"", (char *) NULL);
	    return HAX_ERROR;
	}
    }
    interp->result = (char *) "1";
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
cmpl $0x3, %edx
jl 0x9e00
movl %edx, %r12d
movq 0x20(%rsp), %rax
movq 0x280(%rax), %rax
movq %rax, 0x28(%rsp)
addl $-0x3, %r12d
movq 0x8(%rsp), %rax
leaq 0x18(%rax), %rbx
xorl %r14d, %r14d
leaq 0xb465(%rip), %r15      # 0x150dd
leaq 0xb467(%rip), %rbp      # 0x150e6
movl $0x0, 0x14(%rsp)
movq -0x10(%rbx), %r13
cmpb $0x2d, (%r13)
jne 0x9cdb
movq %r13, %rdi
movq %r15, %rsi
callq 0x4320
testl %eax, %eax
je 0x9cb8
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4320
testl %eax, %eax
jne 0x9cdb
movl $0x1, %r14d
jmp 0x9cc0
movl $0x1, 0x14(%rsp)
leal -0x1(%r12), %eax
addl $0x3, %r12d
addq $0x8, %rbx
cmpl $0x2, %r12d
movl %eax, %r12d
ja 0x9c87
jmp 0x9e00
cmpl $-0x1, %r12d
je 0x9e00
movq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x40b0
movl $0x1, %ebp
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x9e31
movq -0x8(%rbx), %r13
testl %r14d, %r14d
je 0x9da2
movq %r13, %rdi
callq 0x41d0
leal 0x1(%rax), %esi
leaq 0xb3c7(%rip), %rdx      # 0x150ee
movq 0x28(%rsp), %rdi
movl $0x77, %ecx
callq 0x44d0
movq %rax, %rbp
movq -0x8(%rbx), %r13
movb (%r13), %r15b
movq %rax, 0x18(%rsp)
testb %r15b, %r15b
je 0x9d8f
callq 0x4650
movq %rax, %rcx
incq %r13
movq 0x18(%rsp), %rbp
movq (%rcx), %rax
movsbq %r15b, %r14
testb $0x1, 0x1(%rax,%r14,2)
je 0x9d7c
movq %rcx, %r15
callq 0x4640
movq %r15, %rcx
movq (%rax), %rax
movb (%rax,%r14,4), %r15b
movb %r15b, (%rbp)
incq %rbp
movb (%r13), %r15b
incq %r13
testb %r15b, %r15b
jne 0x9d5b
movb $0x0, (%rbp)
movq 0x20(%rsp), %r15
movl $0x1, %ebp
movq 0x18(%rsp), %r13
movq $0x0, 0x290(%r15)
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x4580
movl %eax, %r14d
cmpq -0x8(%rbx), %r13
je 0x9ddf
leaq 0xb321(%rip), %rdx      # 0x150ee
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movl $0x86, %ecx
callq 0x4280
movq 0x290(%r15), %rdx
testq %rdx, %rdx
je 0x9e42
leaq 0xb307(%rip), %rsi      # 0x150f9
movq %r15, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4510
jmp 0x9e31
movq 0x8(%rsp), %rax
movq (%rax), %rdx
leaq 0xaa51(%rip), %rsi      # 0x14860
leaq 0xb286(%rip), %rcx      # 0x1509c
leaq 0xb2ae(%rip), %r8       # 0x150cb
movq 0x20(%rsp), %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4510
movl $0x1, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
je 0x9e5d
leal 0x3(%r12), %eax
cmpl $0xd, %eax
jle 0x9e69
leaq 0xb2c0(%rip), %rax      # 0x15118
movq %rax, (%r15)
jmp 0x9e31
leaq 0xaf85(%rip), %rax      # 0x14de9
jmp 0x9f54
movq %r13, 0x18(%rsp)
cmpl $0x4, %eax
movl 0x14(%rsp), %ebp
jl 0x9f4d
movq 0x18(%rsp), %rax
notq %rax
movq %rax, 0x28(%rsp)
movl %r12d, %r12d
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %rdx
testq %rdx, %rdx
je 0x9ed6
testl %ebp, %ebp
je 0x9eea
subq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rax
movq 0x50(%rax,%r13,8), %rcx
addq 0x28(%rsp), %rcx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
leaq 0xb278(%rip), %rsi      # 0x1513b
xorl %eax, %eax
callq 0x45e0
movq (%rbx,%r13,8), %rsi
movq %r15, %rdi
movq %r14, %rdx
jmp 0x9f35
movq (%rbx,%r13,8), %rsi
movq %r15, %rdi
testl %ebp, %ebp
je 0x9f2e
leaq 0xb24d(%rip), %rdx      # 0x15135
jmp 0x9f35
movq -0x8(%rbx), %r15
movq 0x18(%rsp), %rcx
subq %rcx, %rdx
addq %r15, %rdx
movq 0x8(%rsp), %rax
movq 0x50(%rax,%r13,8), %rbp
subq %rcx, %rbp
movb (%r15,%rbp), %r14b
movb $0x0, (%r15,%rbp)
movq (%rbx,%r13,8), %rsi
movq 0x20(%rsp), %rdi
xorl %ecx, %ecx
callq 0x4460
movb %r14b, (%r15,%rbp)
movl 0x14(%rsp), %ebp
movq 0x20(%rsp), %r15
jmp 0x9f3c
leaq 0xbd02(%rip), %rdx      # 0x15c37
xorl %ecx, %ecx
callq 0x4460
testq %rax, %rax
je 0x9f5e
incq %r13
cmpq %r13, %r12
jne 0x9e8e
leaq 0xb1e5(%rip), %rax      # 0x15139
movq %rax, (%r15)
xorl %ebp, %ebp
jmp 0x9e31
movq (%rbx,%r13,8), %rdx
leaq 0xb1da(%rip), %rsi      # 0x15143
leaq 0xa33f(%rip), %rcx      # 0x142af
movq %r15, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
jmp 0x9e2c