// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxCmdMZ.c
// Function: Hax_StringCmd
int
Hax_StringCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    int length;
    char *p, c;
    int match;
    int first;
    int left = 0, right = 0;

    if (argc < 2) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" option arg ?arg ...?\"", (char *) NULL);
	return HAX_ERROR;
    }
    c = argv[1][0];
    length = strlen(argv[1]);
    if ((c == 'c') && (strncmp(argv[1], "compare", length) == 0)) {
	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " compare string1 string2\"", (char *) NULL);
	    return HAX_ERROR;
	}
	match = strcmp(argv[2], argv[3]);
	if (match > 0) {
	    interp->result = (char *) "1";
	} else if (match < 0) {
	    interp->result = (char *) "-1";
	} else {
	    interp->result = (char *) "0";
	}
	return HAX_OK;
    } else if ((c == 'f') && (strncmp(argv[1], "first", length) == 0)) {
	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " first string1 string2\"", (char *) NULL);
	    return HAX_ERROR;
	}
	first = 1;

	firstLast:
	match = -1;
	c = *argv[2];
	length = strlen(argv[2]);
	for (p = argv[3]; *p != 0; p++) {
	    if (*p != c) {
		continue;
	    }
	    if (strncmp(argv[2], p, length) == 0) {
		match = p-argv[3];
		if (first) {
		    break;
		}
	    }
	}
	sprintf(interp->result, "%d", match);
	return HAX_OK;
    } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)) {
	long int index;

	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " index string charIndex\"", (char *) NULL);
	    return HAX_ERROR;
	}
	if (Hax_GetLong(interp, argv[3], &index) != HAX_OK) {
	    return HAX_ERROR;
	}
	if ((index >= 0) && (index < strlen(argv[2]))) {
	    interp->result[0] = argv[2][index];
	    interp->result[1] = 0;
	}
	return HAX_OK;
    } else if ((c == 'l') && (strncmp(argv[1], "last", length) == 0)
	    && (length >= 2)) {
	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " last string1 string2\"", (char *) NULL);
	    return HAX_ERROR;
	}
	first = 0;
	goto firstLast;
    } else if ((c == 'l') && (strncmp(argv[1], "length", length) == 0)
	    && (length >= 2)) {
	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " length string\"", (char *) NULL);
	    return HAX_ERROR;
	}
	sprintf(interp->result, "%lu", (unsigned long)strlen(argv[2]));
	return HAX_OK;
    } else if ((c == 'm') && (strncmp(argv[1], "match", length) == 0)) {
	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " match pattern string\"", (char *) NULL);
	    return HAX_ERROR;
	}
	if (Hax_StringMatch(argv[3], argv[2]) != 0) {
	    interp->result = (char *) "1";
	} else {
	    interp->result = (char *) "0";
	}
	return HAX_OK;
    } else if ((c == 'r') && (strncmp(argv[1], "range", length) == 0)) {
	long int first, last, stringLength;

	if (argc != 5) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " range string first last\"", (char *) NULL);
	    return HAX_ERROR;
	}
	stringLength = strlen(argv[2]);
	if (Hax_GetLong(interp, argv[3], &first) != HAX_OK) {
	    return HAX_ERROR;
	}
	if ((*argv[4] == 'e')
		&& (strncmp(argv[4], "end", strlen(argv[4])) == 0)) {
	    last = stringLength-1;
	} else {
	    if (Hax_GetLong(interp, argv[4], &last) != HAX_OK) {
		Hax_ResetResult(interp);
		Hax_AppendResult(interp,
			"expected integer or \"end\" but got \"",
			argv[4], "\"", (char *) NULL);
		return HAX_ERROR;
	    }
	}
	if (first < 0) {
	    first = 0;
	}
	if (last >= stringLength) {
	    last = stringLength-1;
	}
	if (last >= first) {
	    char saved, *p;

	    p = argv[2] + last + 1;
	    saved = *p;
	    *p = 0;
	    Hax_SetResult(interp, argv[2] + first, HAX_VOLATILE);
	    *p = saved;
	}
	return HAX_OK;
    } else if ((c == 't') && (strncmp(argv[1], "tolower", length) == 0)
	    && (length >= 3)) {
	char *p;

	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " tolower string\"", (char *) NULL);
	    return HAX_ERROR;
	}
	Hax_SetResult(interp, argv[2], HAX_VOLATILE);
	for (p = interp->result; *p != 0; p++) {
	    if (isupper(*p)) {
		*p = tolower(*p);
	    }
	}
	return HAX_OK;
    } else if ((c == 't') && (strncmp(argv[1], "toupper", length) == 0)
	    && (length >= 3)) {
	char *p;

	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " toupper string\"", (char *) NULL);
	    return HAX_ERROR;
	}
	Hax_SetResult(interp, argv[2], HAX_VOLATILE);
	for (p = interp->result; *p != 0; p++) {
	    if (islower(*p)) {
		*p = toupper(*p);
	    }
	}
	return HAX_OK;
    } else if ((c == 't') && (strncmp(argv[1], "trim", length) == 0)
	    && (length == 4)) {
	char *trimChars;
	char *p, *checkPtr;

	left = right = 1;

	trim:
	if (argc == 4) {
	    trimChars = argv[3];
	} else if (argc == 3) {
	    trimChars = (char *) " \t\n\r";
	} else {
	    Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		    " ", argv[1], " string ?chars?\"", (char *) NULL);
	    return HAX_ERROR;
	}
	p = argv[2];
	if (left) {
	    for (c = *p; c != 0; p++, c = *p) {
		for (checkPtr = trimChars; *checkPtr != c; checkPtr++) {
		    if (*checkPtr == 0) {
			goto doneLeft;
		    }
		}
	    }
	}
	doneLeft:
	Hax_SetResult(interp, p, HAX_VOLATILE);
	if (right) {
	    char *donePtr;

	    p = interp->result + strlen(interp->result) - 1;
	    donePtr = &interp->result[-1];
	    for (c = *p; p != donePtr; p--, c = *p) {
		for (checkPtr = trimChars; *checkPtr != c; checkPtr++) {
		    if (*checkPtr == 0) {
			goto doneRight;
		    }
		}
	    }
	    doneRight:
	    p[1] = 0;
	}
	return HAX_OK;
    } else if ((c == 't') && (strncmp(argv[1], "trimleft", length) == 0)
	    && (length > 4)) {
	left = 1;
	argv[1] = (char *) "trimleft";
	goto trim;
    } else if ((c == 't') && (strncmp(argv[1], "trimright", length) == 0)
	    && (length > 4)) {
	right = 1;
	argv[1] = (char *) "trimright";
	goto trim;
    } else {
	Hax_AppendResult(interp, "bad option \"", argv[1],
		"\": should be compare, first, index, last, length, match, ",
		"range, tolower, toupper, trim, trimleft, or trimright",
		(char *) NULL);
	return HAX_ERROR;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movq %rsi, %rbx
cmpl $0x1, %edx
jg 0xa224
movq (%r14), %rdx
leaq 0x9655(%rip), %rsi      # 0x13860
leaq 0xa0d3(%rip), %rcx      # 0x142e5
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
jmp 0xa7d9
movl %edx, %ebp
movq 0x8(%r14), %r15
movzbl (%r15), %r13d
movq %r15, %rdi
callq 0x41d0
movq %rax, %r12
leal -0x66(%r13), %eax
cmpl $0xe, %eax
ja 0xa282
leaq 0x9dd7(%rip), %rcx      # 0x14020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq %r12d, %rdx
leaq 0xa605(%rip), %rsi      # 0x14861
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xa7b4
cmpl $0x4, %ebp
jne 0xa6b5
movl $0x0, 0x8(%rsp)
jmp 0xa30b
cmpl $0x63, %r13d
jne 0xa7b4
movslq %r12d, %rdx
leaq 0xa066(%rip), %rsi      # 0x142fc
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xa7b4
cmpl $0x4, %ebp
jne 0xa6f7
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x4330
testl %eax, %eax
jle 0xa88d
leaq 0x9e42(%rip), %rax      # 0x1410d
jmp 0xa8a7
movslq %r12d, %r13
leaq 0xa075(%rip), %rsi      # 0x1434f
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x2, %r12d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa559
movb $0x1, %al
movl %eax, 0x8(%rsp)
cmpl $0x4, %ebp
jne 0xa649
movq %rbx, 0x18(%rsp)
movq 0x10(%r14), %r15
movb (%r15), %bpl
movq %r15, %rdi
callq 0x41d0
movq 0x18(%r14), %r13
movslq %eax, %r12
pushq $-0x1
popq %rbx
xorl %r14d, %r14d
movb (%r13,%r14), %al
testb %al, %al
je 0xa62a
cmpb %bpl, %al
jne 0xa35f
leaq (%r14,%r13), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x40c0
testl %eax, %eax
jne 0xa35f
cmpb $0x0, 0x8(%rsp)
je 0xa898
movl %r14d, %ebx
incq %r14
jmp 0xa32c
movslq %r12d, %r13
leaq 0xa048(%rip), %rsi      # 0x143b6
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x3, %r12d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa5b3
cmpl $0x3, %ebp
jne 0xa65f
movq 0x10(%r14), %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x4500
movq (%rbx), %rbx
movsbq (%rbx), %r14
testq %r14, %r14
je 0xa8aa
callq 0x4660
movq (%rax), %rax
testb $0x1, 0x1(%rax,%r14,2)
je 0xa3d6
callq 0x4650
movq (%rax), %rax
movb (%rax,%r14,4), %al
movb %al, (%rbx)
incq %rbx
jmp 0xa3ab
movslq %r12d, %rdx
leaq 0x9f9a(%rip), %rsi      # 0x1437f
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xa7b4
cmpl $0x4, %ebp
jne 0xa69f
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x4480
testl %eax, %eax
leaq 0x99d5(%rip), %rax      # 0x13de9
leaq 0x9cf2(%rip), %rcx      # 0x1410d
cmoveq %rax, %rcx
movq %rcx, (%rbx)
jmp 0xa8aa
movslq %r12d, %rdx
leaq 0x8f9c(%rip), %rsi      # 0x133cd
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xa7b4
cmpl $0x4, %ebp
jne 0xa6cb
movq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x44d0
testl %eax, %eax
jne 0xa7d9
movq 0x10(%rsp), %r15
xorl %ebp, %ebp
testq %r15, %r15
js 0xa7dc
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x41d0
cmpq %rax, %r15
jae 0xa7dc
movb (%r14,%r15), %al
movq (%rbx), %rcx
movb %al, (%rcx)
movq (%rbx), %rax
movb $0x0, 0x1(%rax)
jmp 0xa7dc
movslq %r12d, %rdx
leaq 0x8ce9(%rip), %rsi      # 0x13190
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xa7b4
cmpl $0x5, %ebp
jne 0xa6e1
movq 0x10(%r14), %rdi
callq 0x41d0
movq %rax, %r15
movq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x44d0
pushq $0x1
popq %rbp
testl %eax, %eax
jne 0xa7dc
movq 0x20(%r14), %r12
cmpb $0x65, (%r12)
jne 0xa515
movq %r12, %rdi
callq 0x41d0
leaq 0x8c5a(%rip), %rsi      # 0x1315c
movq %r12, %rdi
movq %rax, %rdx
callq 0x40c0
testl %eax, %eax
je 0xa8b1
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x44d0
testl %eax, %eax
je 0xa8ba
movq %rbx, %rdi
callq 0x42d0
movq 0x20(%r14), %rdx
leaq 0x99ff(%rip), %rsi      # 0x13f3f
leaq 0x8d68(%rip), %rcx      # 0x132af
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
jmp 0xa7dc
cmpl $0x2, %r12d
setge %r12b
leaq 0x8e74(%rip), %rsi      # 0x133dc
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb %r12b, %al
cmpb $0x1, %al
jne 0xa7b4
cmpl $0x3, %ebp
jne 0xa70d
movq (%rbx), %rbx
movq 0x10(%r14), %rdi
callq 0x41d0
leaq 0x9ddc(%rip), %rsi      # 0x1437b
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x45f0
jmp 0xa7dc
cmpl $0x3, %r12d
setge 0x8(%rsp)
leaq 0x9e0c(%rip), %rsi      # 0x143cf
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb 0x8(%rsp), %al
cmpb $0x1, %al
jne 0xa675
cmpl $0x3, %ebp
jne 0xa723
movq 0x10(%r14), %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x4500
movq (%rbx), %rbx
movsbq (%rbx), %r14
testq %r14, %r14
je 0xa8aa
callq 0x4660
movq (%rax), %rax
testb $0x2, 0x1(%rax,%r14,2)
je 0xa625
callq 0x4040
movq (%rax), %rax
movb (%rax,%r14,4), %al
movb %al, (%rbx)
incq %rbx
jmp 0xa5fa
movl %ebx, %edx
movq 0x18(%rsp), %rax
movq (%rax), %rdi
leaq 0x8cd8(%rip), %rsi      # 0x13313
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x45f0
jmp 0xa7dc
movq (%r14), %rdx
leaq 0x920d(%rip), %rsi      # 0x13860
leaq 0x9cfa(%rip), %rcx      # 0x14354
jmp 0xa212
movq (%r14), %rdx
leaq 0x91f7(%rip), %rsi      # 0x13860
leaq 0x9d4e(%rip), %rcx      # 0x143be
jmp 0xa212
leaq 0x9d6c(%rip), %rsi      # 0x143e8
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
movl %r12d, %ecx
xorl $0x4, %ecx
orl %eax, %ecx
jne 0xa739
xorl %r12d, %r12d
xorl %eax, %eax
jmp 0xa7a0
movq (%r14), %rdx
leaq 0x91b7(%rip), %rsi      # 0x13860
leaq 0x9cd5(%rip), %rcx      # 0x14385
jmp 0xa212
movq (%r14), %rdx
leaq 0x91a1(%rip), %rsi      # 0x13860
leaq 0x9c58(%rip), %rcx      # 0x1431e
jmp 0xa212
movq (%r14), %rdx
leaq 0x918b(%rip), %rsi      # 0x13860
leaq 0x9c5a(%rip), %rcx      # 0x14336
jmp 0xa212
movq (%r14), %rdx
leaq 0x9175(%rip), %rsi      # 0x13860
leaq 0x9caa(%rip), %rcx      # 0x1439c
jmp 0xa212
movq (%r14), %rdx
leaq 0x915f(%rip), %rsi      # 0x13860
leaq 0x9bfc(%rip), %rcx      # 0x14304
jmp 0xa212
movq (%r14), %rdx
leaq 0x9149(%rip), %rsi      # 0x13860
leaq 0x9c4d(%rip), %rcx      # 0x1436b
jmp 0xa212
movq (%r14), %rdx
leaq 0x9133(%rip), %rsi      # 0x13860
leaq 0x9ca3(%rip), %rcx      # 0x143d7
jmp 0xa212
leaq 0x9cc3(%rip), %rsi      # 0x14403
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x5, %r12d
setge %cl
andb %al, %cl
movl %ecx, 0x18(%rsp)
jne 0xa78d
cmpl $0x5, %r12d
setge %r12b
leaq 0x9cff(%rip), %rsi      # 0x14472
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
testb %r12b, %al
je 0xa7b4
movl 0x18(%rsp), %r12d
movl %r12d, %eax
xorb $0x1, %al
movq 0x8(%rsp), %r15
movq %r15, 0x8(%r14)
cmpl $0x3, %ebp
je 0xa7ed
cmpl $0x4, %ebp
jne 0xa865
movq 0x18(%r14), %r15
jmp 0xa7f4
leaq 0x8f62(%rip), %rsi      # 0x1371d
leaq 0x9c4a(%rip), %rcx      # 0x1440c
leaq 0x9c7d(%rip), %r8       # 0x14446
movq %rbx, %rdi
movq %r15, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9bf9(%rip), %r15      # 0x143ed
movq 0x10(%r14), %rsi
testb %al, %al
je 0xa83f
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x4500
xorl %ebp, %ebp
testb %r12b, %r12b
jne 0xa7dc
movq (%rbx), %rbx
movq %rbx, %rdi
callq 0x41d0
movq %rax, %rcx
subq $0x1, %rcx
jb 0xa85c
movb (%rbx,%rcx), %dl
movq %r15, %rsi
movb (%rsi), %dil
cmpb %dl, %dil
je 0xa83a
incq %rsi
testb %dil, %dil
jne 0xa828
jmp 0xa85c
movq %rcx, %rax
jmp 0xa81c
movb (%rsi), %al
testb %al, %al
je 0xa7fc
movq %r15, %rcx
movb (%rcx), %dl
cmpb %al, %dl
je 0xa857
incq %rcx
testb %dl, %dl
jne 0xa848
jmp 0xa7fc
incq %rsi
jmp 0xa83f
movb $0x0, (%rbx,%rax)
jmp 0xa7dc
movq (%r14), %rdx
andq $0x0, (%rsp)
leaq 0x8fec(%rip), %rsi      # 0x13860
leaq 0xa389(%rip), %rcx      # 0x14c04
leaq 0x9b70(%rip), %r9       # 0x143f2
movq %rbx, %rdi
movq %r15, %r8
jmp 0xa7d2
jns 0xa8a0
leaq 0x9876(%rip), %rax      # 0x1410c
jmp 0xa8a7
movl %r14d, %edx
jmp 0xa62c
leaq 0x9542(%rip), %rax      # 0x13de9
movq %rax, (%rbx)
xorl %ebp, %ebp
jmp 0xa7dc
leaq -0x1(%r15), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
testq %rax, %rax
jns 0xa8cc
andq $0x0, 0x10(%rsp)
xorl %eax, %eax
movq 0x20(%rsp), %r12
cmpq %r15, %r12
jl 0xa8e1
decq %r15
movq %r15, 0x20(%rsp)
movq %r15, %r12
xorl %ebp, %ebp
cmpq %rax, %r12
jl 0xa7dc
movq 0x10(%r14), %r15
movb 0x1(%r15,%r12), %r13b
movb $0x0, 0x1(%r15,%r12)
movq 0x10(%r14), %rsi
addq 0x10(%rsp), %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x4500
movb %r13b, 0x1(%r15,%r12)
jmp 0xa7dc