// File: /workspace/github_c_makefile_star2_O2/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, (%rsp)
movq %rsi, 0x10(%rsp)
cmpl $0x3, %edx
jge 0x9509
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0xa386(%rip), %rsi      # 0x13860
leaq 0xab8f(%rip), %rcx      # 0x14070
leaq 0xabb7(%rip), %r8       # 0x1409f
movq 0x10(%rsp), %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
movq 0x280(%rax), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0xab87(%rip), %r15      # 0x140b1
movq (%rsp), %rcx
addq $0x18, %rcx
movl %edx, %ebx
xorl %edx, %edx
movl %r13d, %esi
leal (%rbx,%rdx), %eax
cmpl $0x2, %eax
jl 0x94cc
movl %esi, %r13d
movq %rcx, %r12
movq %rdx, %r14
movq -0x10(%rcx), %rbp
cmpb $0x2d, (%rbp)
jne 0x959b
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4330
testl %eax, %eax
je 0x9584
movq %rbp, %rdi
leaq 0xab4d(%rip), %rsi      # 0x140ba
callq 0x4330
leaq 0x8(%r12), %rcx
leaq -0x1(%r14), %rdx
pushq $0x1
popq %rsi
testl %eax, %eax
je 0x9539
jmp 0x959b
addq $-0x10, %r12
leal (%rbx,%r14), %edx
decl %edx
movl $0x0, 0xc(%rsp)
movq %r12, %rcx
jmp 0x952e
leaq (%rbx,%r14), %rax
cmpl $0x2, %eax
je 0x94cc
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x40b0
movq %rax, %rbp
pushq $0x1
popq %rax
testq %rbp, %rbp
je 0x94fa
movq -0x8(%r12), %rdi
testl %r13d, %r13d
je 0x964e
movq %rbx, 0x28(%rsp)
movq %rbp, (%rsp)
callq 0x41d0
leal 0x1(%rax), %esi
leaq 0xaad4(%rip), %rdx      # 0x140c2
pushq $0x77
popq %rcx
movq 0x18(%rsp), %rdi
callq 0x44e0
movq %rax, %rbx
movq -0x8(%r12), %rbp
xorl %r13d, %r13d
movsbq (%rbp,%r13), %r15
testq %r15, %r15
je 0x9636
callq 0x4660
movq (%rax), %rax
testb $0x1, 0x1(%rax,%r15,2)
je 0x962d
callq 0x4650
movq (%rax), %rax
movb (%rax,%r15,4), %r15b
movb %r15b, (%rbx,%r13)
incq %r13
jmp 0x9606
movb $0x0, (%rbx,%r13)
movq %rbx, %r13
movq 0x10(%rsp), %r15
movq (%rsp), %rbp
movq 0x28(%rsp), %rbx
jmp 0x9651
movq %rdi, %r13
andq $0x0, 0x290(%r15)
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x4590
cmpq -0x8(%r12), %r13
je 0x9695
leaq 0xaa4d(%rip), %rdx      # 0x140c2
movq 0x18(%rsp), %rdi
movq %r13, %rsi
movl $0x86, %ecx
movq %r13, (%rsp)
movl %eax, %r13d
callq 0x4280
movl %r13d, %eax
movq (%rsp), %r13
movq 0x290(%r15), %rdx
testq %rdx, %rdx
je 0x96b9
leaq 0xaa25(%rip), %rsi      # 0x140cd
movq %r15, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4520
jmp 0x94f7
testl %eax, %eax
je 0x96d3
cmpl $0xd, 0x20(%rsp)
jle 0x96df
leaq 0xaa21(%rip), %rax      # 0x140ec
movq %rax, (%r15)
jmp 0x94f7
leaq 0xa70f(%rip), %rax      # 0x13de9
jmp 0x97c9
movq %r13, %rax
notq %rax
movq %rax, 0x18(%rsp)
addl $-0x3, %ebx
movslq %ebx, %rbx
addq %r14, %rbx
xorl %r14d, %r14d
movq %r13, (%rsp)
movq %rbx, 0x20(%rsp)
cmpq %rbx, %r14
jge 0x97c2
movq (%rbp,%r14,8), %rdx
testq %rdx, %rdx
je 0x975f
testb $0x1, 0xc(%rsp)
je 0x9776
movq -0x8(%r12), %r15
subq %r13, %rdx
addq %r15, %rdx
movq %rbp, %rbx
movq 0x50(%rbp,%r14,8), %rbp
subq %r13, %rbp
movb (%r15,%rbp), %r13b
movb $0x0, (%r15,%rbp)
movq (%r12,%r14,8), %rsi
movq 0x10(%rsp), %rdi
xorl %ecx, %ecx
callq 0x4470
movb %r13b, (%r15,%rbp)
movq (%rsp), %r13
movq %rbx, %rbp
movq 0x20(%rsp), %rbx
movq 0x10(%rsp), %r15
jmp 0x97b5
movq (%r12,%r14,8), %rsi
testb $0x1, 0xc(%rsp)
je 0x97a4
movq %r15, %rdi
leaq 0xb493(%rip), %rdx      # 0x14c07
jmp 0x97ae
subq %r13, %rdx
movq 0x50(%rbp,%r14,8), %rcx
addq 0x18(%rsp), %rcx
leaq 0x30(%rsp), %rdi
leaq 0xa980(%rip), %rsi      # 0x1410f
xorl %eax, %eax
callq 0x45f0
movq (%r12,%r14,8), %rsi
movq %r15, %rdi
leaq 0x30(%rsp), %rdx
jmp 0x97ae
movq %r15, %rdi
leaq 0xa95b(%rip), %rdx      # 0x14109
xorl %ecx, %ecx
callq 0x4470
testq %rax, %rax
je 0x97d3
incq %r14
jmp 0x96ff
leaq 0xa944(%rip), %rax      # 0x1410d
movq %rax, (%r15)
xorl %eax, %eax
jmp 0x94fa
movq (%r12,%r14,8), %rdx
leaq 0xa939(%rip), %rsi      # 0x14117
leaq 0x9aca(%rip), %rcx      # 0x132af
movq %r15, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
jmp 0x94f7