// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %rcx, %r15
movq %rsi, %r13
cmpl $0x3, %edx
jl 0xa0c9
movl %edx, %ebx
movq 0x280(%r13), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%r15), %r12
cmpb $0x2d, (%r12)
jne 0xa098
movq %r13, 0x20(%rsp)
leaq 0x10(%r15), %r13
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq %r12, %rdi
leaq 0xc28e(%rip), %rsi      # 0x162d1
callq 0x4310
movl $0x1, %r14d
testl %eax, %eax
je 0xa06c
movq %r12, %rdi
leaq 0xc27e(%rip), %rsi      # 0x162da
callq 0x4310
testl %eax, %eax
jne 0xa0a6
movl $0x1, %ebp
jmp 0xa074
movl $0x1, 0x10(%rsp)
movq %r13, %rcx
cmpl $0x2, %ebx
jle 0xa08f
movq (%rcx), %r12
leaq 0x8(%rcx), %r13
decl %ebx
cmpb $0x2d, (%r12)
movl %ebx, %r14d
je 0xa039
leaq -0x8(%rcx), %r12
movl %r14d, %ebx
jmp 0xa0b1
leaq 0x8(%r15), %rcx
movb $0x1, %al
movq %r15, %r12
movb $0x1, %bpl
jmp 0xa0c4
movq %r13, %rcx
leaq -0x10(%r13), %r12
addq $-0x8, %rcx
testl %ebp, %ebp
sete %bpl
cmpl $0x0, 0x10(%rsp)
sete %al
movq 0x20(%rsp), %r13
cmpl $0x3, %ebx
jge 0xa106
movq (%r15), %rdx
leaq 0xb7a1(%rip), %rsi      # 0x15874
leaq 0xc1b6(%rip), %rcx      # 0x16290
leaq 0xc1de(%rip), %r8       # 0x162bf
movq %r13, %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4500
movl $0x1, %r14d
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %al, 0xf(%rsp)
movq %rcx, 0x18(%rsp)
movq (%rcx), %rsi
movq %r13, %rdi
callq 0x40b0
movl $0x1, %r14d
testq %rax, %rax
je 0xa0f4
movq %rax, %r15
movq 0x10(%r12), %rdi
testb %bpl, %bpl
movq %r12, 0x30(%rsp)
je 0xa141
movq %rdi, 0x10(%rsp)
jmp 0xa1d0
movq %r15, 0x38(%rsp)
movq %r13, 0x20(%rsp)
callq 0x41d0
leal 0x1(%rax), %esi
leaq 0xc188(%rip), %rdx      # 0x162e2
movq 0x28(%rsp), %rdi
movl $0x77, %ecx
callq 0x44c0
movq %rax, %rbp
movq 0x10(%r12), %r15
movb (%r15), %r13b
movq %rax, 0x10(%rsp)
testb %r13b, %r13b
je 0xa1bc
callq 0x4640
movq %rax, %r12
incq %r15
movq 0x10(%rsp), %rbp
movq (%r12), %rax
movsbq %r13b, %r14
testb $0x1, 0x1(%rax,%r14,2)
je 0xa1aa
callq 0x4630
movq (%rax), %rax
movb (%rax,%r14,4), %r13b
movb %r13b, (%rbp)
incq %rbp
movb (%r15), %r13b
incq %r15
testb %r13b, %r13b
jne 0xa18e
movb $0x0, (%rbp)
movq 0x20(%rsp), %r13
movl $0x1, %r14d
movq 0x38(%rsp), %r15
movq $0x0, 0x290(%r13)
movq %r13, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %rbp
movq %rbp, %rdx
callq 0x4570
movl %eax, %r12d
movq 0x30(%rsp), %rax
cmpq 0x10(%rax), %rbp
je 0xa215
leaq 0xc0df(%rip), %rdx      # 0x162e2
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movl $0x86, %ecx
callq 0x4280
movq 0x290(%r13), %rdx
testq %rdx, %rdx
je 0xa239
leaq 0xc0c5(%rip), %rsi      # 0x162ed
movq %r13, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4500
jmp 0xa0f4
testl %r12d, %r12d
je 0xa253
cmpl $0xd, %ebx
jle 0xa25f
leaq 0xc0c2(%rip), %rax      # 0x1630c
movq %rax, (%r13)
jmp 0xa0f4
leaq 0xbd33(%rip), %rax      # 0x15f8d
jmp 0xa36b
cmpl $0x3, %ebx
je 0xa364
movq %rbp, %rax
notq %rax
movq %rax, 0x28(%rsp)
cmpl $0x5, %ebx
movl $0x4, %r12d
cmovgel %ebx, %r12d
addl $-0x3, %r12d
xorl %r14d, %r14d
movq %r12, 0x20(%rsp)
movq (%r15,%r14,8), %rdx
testq %rdx, %rdx
je 0xa2e6
cmpb $0x0, 0xf(%rsp)
je 0xa303
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rbx
subq %rbp, %rdx
addq %rbx, %rdx
movq %r15, %r12
movq 0x50(%r15,%r14,8), %r15
subq %rbp, %r15
movb (%rbx,%r15), %bpl
movb $0x0, (%rbx,%r15)
movq 0x18(%rsp), %rax
movq 0x10(%rax,%r14,8), %rsi
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x4450
movb %bpl, (%rbx,%r15)
movq 0x10(%rsp), %rbp
movq %r12, %r15
movq 0x20(%rsp), %r12
jmp 0xa353
cmpb $0x0, 0xf(%rsp)
je 0xa338
movq 0x18(%rsp), %rax
movq 0x10(%rax,%r14,8), %rsi
movq %r13, %rdi
leaq 0xcc32(%rip), %rdx      # 0x16f33
jmp 0xa34c
subq %rbp, %rdx
movq 0x50(%r15,%r14,8), %rcx
addq 0x28(%rsp), %rcx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0xc010(%rip), %rsi      # 0x1632f
xorl %eax, %eax
callq 0x45d0
movq 0x18(%rsp), %rax
movq 0x10(%rax,%r14,8), %rsi
movq %r13, %rdi
movq %rbx, %rdx
jmp 0xa34c
movq 0x18(%rsp), %rax
movq 0x10(%rax,%r14,8), %rsi
movq %r13, %rdi
leaq 0xbfdd(%rip), %rdx      # 0x16329
xorl %ecx, %ecx
callq 0x4450
testq %rax, %rax
je 0xa377
incq %r14
cmpq %r14, %r12
jne 0xa28c
leaq 0xbfc2(%rip), %rax      # 0x1632d
movq %rax, (%r13)
xorl %r14d, %r14d
jmp 0xa0f4
movq 0x18(%rsp), %rax
movq 0x10(%rax,%r14,8), %rdx
leaq 0xbfaf(%rip), %rsi      # 0x16337
leaq 0xaf20(%rip), %rcx      # 0x152af
movq %r13, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
jmp 0xa0ee