// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rcx, %r14
movq %rsi, %rdi
cmpl $0x1, %edx
jg 0xaaeb
movq (%r14), %rdx
leaq 0x9d8b(%rip), %rsi      # 0x14860
leaq 0xa835(%rip), %rcx      # 0x15311
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
jmp 0xb0fa
movl %edx, %ebp
movq %rdi, 0x10(%rsp)
movq 0x8(%r14), %r15
movzbl (%r15), %ebx
movq %r15, %rdi
callq 0x41d0
movq %rax, %r12
leal -0x66(%rbx), %eax
cmpl $0xe, %eax
ja 0xab4d
leaq 0xa538(%rip), %rcx      # 0x1504c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq %r12d, %rdx
leaq 0xad6a(%rip), %rsi      # 0x15891
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xb0d3
cmpl $0x4, %ebp
jne 0xafd2
movl $0x0, 0x2c(%rsp)
jmp 0xabda
cmpl $0x63, %ebx
jne 0xb0d3
movslq %r12d, %rdx
leaq 0xa7c8(%rip), %rsi      # 0x15328
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xb0d3
cmpl $0x4, %ebp
jne 0xb018
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x4320
testl %eax, %eax
movq 0x10(%rsp), %rcx
jle 0xb1dd
leaq 0xa59f(%rip), %rax      # 0x15139
jmp 0xb215
movslq %r12d, %r13
leaq 0xa7d2(%rip), %rsi      # 0x1537b
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 0xae76
movb $0x1, %al
movl %eax, 0x2c(%rsp)
cmpl $0x4, %ebp
jne 0xaf69
movq 0x18(%r14), %r13
movb (%r13), %bl
testb %bl, %bl
je 0xb00b
movq 0x10(%r14), %r14
movb (%r14), %r12b
movq %r14, %rdi
callq 0x41d0
movslq %eax, %r15
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
xorl %ebp, %ebp
cmpb %r12b, %bl
jne 0xac2f
movq %r13, %rsi
addq %rbp, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x40c0
testl %eax, %eax
jne 0xac2f
cmpb $0x0, 0x2c(%rsp)
je 0xb1e8
movl %ebp, 0x18(%rsp)
movb 0x1(%r13,%rbp), %bl
incq %rbp
testb %bl, %bl
jne 0xac06
jmp 0xb1ec
movslq %r12d, %r13
leaq 0xa798(%rip), %rsi      # 0x153e2
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 0xaed4
cmpl $0x3, %ebp
jne 0xaf7f
movq 0x10(%r14), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq $-0x1, %rdx
callq 0x44f0
movq (%rbx), %r14
movb (%r14), %bpl
xorl %r15d, %r15d
testb %bpl, %bpl
je 0xb100
callq 0x4650
movq %rax, %rbx
incq %r14
movq (%rbx), %rax
movsbq %bpl, %r12
testb $0x1, 0x1(%rax,%r12,2)
je 0xacc9
callq 0x4640
movq (%rax), %rax
movb (%rax,%r12,4), %al
movb %al, -0x1(%r14)
movb (%r14), %bpl
incq %r14
testb %bpl, %bpl
jne 0xacaa
jmp 0xb100
movslq %r12d, %rdx
leaq 0xa6c8(%rip), %rsi      # 0x153ab
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xb0d3
cmpl $0x4, %ebp
jne 0xafbf
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x4470
testl %eax, %eax
leaq 0xa0d7(%rip), %rax      # 0x14de9
leaq 0xa420(%rip), %rcx      # 0x15139
cmoveq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, (%rax)
jmp 0xb218
movslq %r12d, %rdx
leaq 0x9699(%rip), %rsi      # 0x143cd
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xb0d3
cmpl $0x4, %ebp
jne 0xafe5
movq 0x18(%r14), %rsi
leaq 0x20(%rsp), %rdx
movq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x44c0
movl $0x1, %r15d
testl %eax, %eax
jne 0xb100
movq 0x20(%rsp), %rbx
xorl %r15d, %r15d
testq %rbx, %rbx
js 0xb100
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x41d0
cmpq %rax, %rbx
jae 0xb100
movb (%r14,%rbx), %al
movq (%r12), %rcx
movb %al, (%rcx)
movq (%r12), %rax
movb $0x0, 0x1(%rax)
jmp 0xb100
movslq %r12d, %rdx
leaq 0x93d8(%rip), %rsi      # 0x14190
movq %r15, %rdi
callq 0x40c0
testl %eax, %eax
jne 0xb0d3
cmpl $0x5, %ebp
jne 0xaff8
movq 0x10(%r14), %rdi
callq 0x41d0
movq %rax, %r12
movq 0x18(%r14), %rsi
leaq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rdi
callq 0x44c0
movl $0x1, %r15d
testl %eax, %eax
jne 0xb100
movq 0x20(%r14), %r13
cmpb $0x65, (%r13)
jne 0xae2b
movq %r13, %rdi
callq 0x41d0
leaq 0x9344(%rip), %rsi      # 0x1415c
movq %r13, %rdi
movq %rax, %rdx
callq 0x40c0
testl %eax, %eax
je 0xb220
leaq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x44c0
testl %eax, %eax
je 0xb22a
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x42d0
movq 0x20(%r14), %rdx
leaq 0xa0e2(%rip), %rsi      # 0x14f3f
leaq 0x944b(%rip), %rcx      # 0x142af
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
jmp 0xb100
cmpl $0x2, %r12d
setge %bl
leaq 0x9558(%rip), %rsi      # 0x143dc
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb %bl, %al
cmpb $0x1, %al
jne 0xb0d3
cmpl $0x3, %ebp
jne 0xb02b
movq 0x10(%rsp), %rax
movq (%rax), %rbx
movq 0x10(%r14), %rdi
callq 0x41d0
leaq 0xa4e8(%rip), %rsi      # 0x153a7
xorl %r15d, %r15d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x45e0
jmp 0xb100
cmpl $0x3, %r12d
setge %bl
leaq 0xa519(%rip), %rsi      # 0x153fb
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb %bl, %al
cmpb $0x1, %al
jne 0xaf95
cmpl $0x3, %ebp
jne 0xb03e
movq 0x10(%r14), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq $-0x1, %rdx
callq 0x44f0
movq (%rbx), %r14
movb (%r14), %bpl
xorl %r15d, %r15d
testb %bpl, %bpl
je 0xb100
callq 0x4650
movq %rax, %rbx
incq %r14
movq (%rbx), %rax
movsbq %bpl, %r12
testb $0x2, 0x1(%rax,%r12,2)
je 0xaf59
callq 0x4040
movq (%rax), %rax
movb (%rax,%r12,4), %al
movb %al, -0x1(%r14)
movb (%r14), %bpl
incq %r14
testb %bpl, %bpl
jne 0xaf3a
jmp 0xb100
movq (%r14), %rdx
leaq 0x98ed(%rip), %rsi      # 0x14860
leaq 0xa406(%rip), %rcx      # 0x15380
jmp 0xb04f
movq (%r14), %rdx
leaq 0x98d7(%rip), %rsi      # 0x14860
leaq 0xa45a(%rip), %rcx      # 0x153ea
jmp 0xb04f
leaq 0xa478(%rip), %rsi      # 0x15414
movq %r15, %rdi
movq %r13, %rdx
callq 0x40c0
movl %r12d, %ecx
xorl $0x4, %ecx
orl %eax, %ecx
jne 0xb059
xorl %r13d, %r13d
xorl %eax, %eax
jmp 0xb0ba
movq (%r14), %rdx
leaq 0x9897(%rip), %rsi      # 0x14860
leaq 0xa3e1(%rip), %rcx      # 0x153b1
jmp 0xb04f
movq (%r14), %rdx
leaq 0x9884(%rip), %rsi      # 0x14860
leaq 0xa367(%rip), %rcx      # 0x1534a
jmp 0xb04f
movq (%r14), %rdx
leaq 0x9871(%rip), %rsi      # 0x14860
leaq 0xa36c(%rip), %rcx      # 0x15362
jmp 0xb04f
movq (%r14), %rdx
leaq 0x985e(%rip), %rsi      # 0x14860
leaq 0xa3bf(%rip), %rcx      # 0x153c8
jmp 0xb04f
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
jmp 0xb1ec
movq (%r14), %rdx
leaq 0x983e(%rip), %rsi      # 0x14860
leaq 0xa307(%rip), %rcx      # 0x15330
jmp 0xb04f
movq (%r14), %rdx
leaq 0x982b(%rip), %rsi      # 0x14860
leaq 0xa35b(%rip), %rcx      # 0x15397
jmp 0xb04f
movq (%r14), %rdx
leaq 0x9818(%rip), %rsi      # 0x14860
leaq 0xa3b4(%rip), %rcx      # 0x15403
movq 0x10(%rsp), %rdi
jmp 0xaadc
leaq 0xa3cf(%rip), %rsi      # 0x1542f
movq %r15, %rdi
movq %rsi, 0x18(%rsp)
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x5, %r12d
setge %bl
andb %al, %bl
jne 0xb0a9
cmpl $0x5, %r12d
setge %r12b
leaq 0xa40f(%rip), %rsi      # 0x1549e
movq %r15, %rdi
movq %rsi, 0x18(%rsp)
movq %r13, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
testb %r12b, %al
je 0xb0d3
movl %ebx, %r13d
movl %r13d, %eax
xorb $0x1, %al
movq 0x18(%rsp), %r15
movq %r15, 0x8(%r14)
cmpl $0x3, %ebp
movq 0x10(%rsp), %rbx
je 0xb112
cmpl $0x4, %ebp
jne 0xb1b2
movq 0x18(%r14), %r12
jmp 0xb119
leaq 0x9643(%rip), %rsi      # 0x1471d
leaq 0xa357(%rip), %rcx      # 0x15438
leaq 0xa38a(%rip), %r8       # 0x15472
movq 0x10(%rsp), %rdi
movq %r15, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4510
movl $0x1, %r15d
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa300(%rip), %r12      # 0x15419
movq 0x10(%r14), %rsi
testb %al, %al
jne 0xb154
movb (%rsi), %al
testb %al, %al
je 0xb154
movb (%r12), %cl
leaq 0x1(%r12), %rdx
movq %rdx, %rdi
movl %ecx, %r8d
cmpb %al, %cl
je 0xb14a
testb %r8b, %r8b
je 0xb154
movb (%rdi), %r8b
incq %rdi
cmpb %al, %r8b
jne 0xb13a
movb 0x1(%rsi), %al
incq %rsi
testb %al, %al
jne 0xb130
movq %rbx, %rdi
movq $-0x1, %rdx
callq 0x44f0
xorl %r15d, %r15d
testb %r13b, %r13b
jne 0xb100
movq (%rbx), %rbx
movq %rbx, %rdi
callq 0x41d0
xorl %r15d, %r15d
testq %rax, %rax
je 0xb1a7
movb (%r12), %cl
incq %r12
movb -0x1(%rbx,%rax), %dl
movq %r12, %rsi
movl %ecx, %edi
cmpb %dl, %cl
je 0xb1a2
testb %dil, %dil
je 0xb1a9
movb (%rsi), %dil
incq %rsi
cmpb %dl, %dil
jne 0xb192
decq %rax
jne 0xb185
xorl %eax, %eax
movb $0x0, (%rbx,%rax)
jmp 0xb100
movq (%r14), %rdx
movq $0x0, (%rsp)
leaq 0x969c(%rip), %rsi      # 0x14860
leaq 0xaa69(%rip), %rcx      # 0x15c34
leaq 0xa24c(%rip), %r9       # 0x1541e
movq %rbx, %rdi
movq %r15, %r8
jmp 0xb0f3
jns 0xb20e
leaq 0x9f52(%rip), %rax      # 0x15138
jmp 0xb215
movl %ebp, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x9118(%rip), %rsi      # 0x14313
xorl %r15d, %r15d
movl 0x18(%rsp), %edx
xorl %eax, %eax
callq 0x45e0
jmp 0xb100
leaq 0x9bd4(%rip), %rax      # 0x14de9
movq %rax, (%rcx)
xorl %r15d, %r15d
jmp 0xb100
leaq -0x1(%r12), %rax
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
testq %rax, %rax
jns 0xb23f
movq $0x0, 0x20(%rsp)
xorl %eax, %eax
movq 0x30(%rsp), %rbx
cmpq %r12, %rbx
movq 0x10(%rsp), %rdi
jl 0xb259
decq %r12
movq %r12, 0x30(%rsp)
movq %r12, %rbx
xorl %r15d, %r15d
cmpq %rax, %rbx
jl 0xb100
movq 0x10(%r14), %r12
movb 0x1(%r12,%rbx), %bpl
movb $0x0, 0x1(%r12,%rbx)
movq 0x10(%r14), %rsi
addq 0x20(%rsp), %rsi
movq $-0x1, %rdx
callq 0x44f0
movb %bpl, 0x1(%r12,%rbx)
jmp 0xb100