// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxVar.c
// Function: Hax_ArrayCmd
int
Hax_ArrayCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    int length;
    char c;
    Var *varPtr;
    Hax_HashEntry *hPtr;
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;

    if (argc < 3) {
	Hax_AppendResult(interp, "wrong # args: should be \"",
		argv[0], " option arrayName ?arg ...?\"", (char *) NULL);
	return HAX_ERROR;
    }

    /*
     * Locate the array variable (and it better be an array).
     */

    if (iPtr->varFramePtr == NULL) {
	hPtr = Hax_FindHashEntry(&iPtr->globalTable, argv[2]);
    } else {
	hPtr = Hax_FindHashEntry(&iPtr->varFramePtr->varTable, argv[2]);
    }
    if (hPtr == NULL) {
	notArray:
	Hax_AppendResult(interp, "\"", argv[2], "\" isn't an array",
		(char *) NULL);
	return HAX_ERROR;
    }
    varPtr = (Var *) Hax_GetHashValue(hPtr);
    if (varPtr->flags & VAR_UPVAR) {
	varPtr = (Var *) Hax_GetHashValue(varPtr->value.upvarPtr);
    }
    if (!(varPtr->flags & VAR_ARRAY)) {
	goto notArray;
    }

    /*
     * Dispatch based on the option.
     */

    c = argv[1][0];
    length = strlen(argv[1]);
    if ((c == 'a') && (strncmp(argv[1], "anymore", length) == 0)) {
	ArraySearch *searchPtr;

	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " anymore arrayName searchId\"", (char *) NULL);
	    return HAX_ERROR;
	}
	searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]);
	if (searchPtr == NULL) {
	    return HAX_ERROR;
	}
	while (1) {
	    Var *varPtr2;

	    if (searchPtr->nextEntry != NULL) {
		varPtr2 = (Var *) Hax_GetHashValue(searchPtr->nextEntry);
		if (!(varPtr2->flags & VAR_UNDEFINED)) {
		    break;
		}
	    }
	    searchPtr->nextEntry = Hax_NextHashEntry(&searchPtr->search);
	    if (searchPtr->nextEntry == NULL) {
		interp->result = (char *) "0";
		return HAX_OK;
	    }
	}
	interp->result = (char *) "1";
	return HAX_OK;
    } else if ((c == 'd') && (strncmp(argv[1], "donesearch", length) == 0)) {
	ArraySearch *searchPtr, *prevPtr;

	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " donesearch arrayName searchId\"", (char *) NULL);
	    return HAX_ERROR;
	}
	searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]);
	if (searchPtr == NULL) {
	    return HAX_ERROR;
	}
	if (varPtr->searchPtr == searchPtr) {
	    varPtr->searchPtr = searchPtr->nextPtr;
	} else {
	    for (prevPtr = varPtr->searchPtr; ; prevPtr = prevPtr->nextPtr) {
		if (prevPtr->nextPtr == searchPtr) {
		    prevPtr->nextPtr = searchPtr->nextPtr;
		    break;
		}
	    }
	}
	ckfree(memoryp, (char *) searchPtr);
    } else if ((c == 'n') && (strncmp(argv[1], "names", length) == 0)
	    && (length >= 2)) {
	Hax_HashSearch search;
	Var *varPtr2;

	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " names arrayName\"", (char *) NULL);
	    return HAX_ERROR;
	}
	for (hPtr = Hax_FirstHashEntry(varPtr->value.tablePtr, &search);
		hPtr != NULL; hPtr = Hax_NextHashEntry(&search)) {
	    varPtr2 = (Var *) Hax_GetHashValue(hPtr);
	    if (varPtr2->flags & VAR_UNDEFINED) {
		continue;
	    }
	    Hax_AppendElement(interp,
		    Hax_GetHashKey(varPtr->value.tablePtr, hPtr), 0);
	}
    } else if ((c == 'n') && (strncmp(argv[1], "nextelement", length) == 0)
	    && (length >= 2)) {
	ArraySearch *searchPtr;
	Hax_HashEntry *hPtr;

	if (argc != 4) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " nextelement arrayName searchId\"",
		    (char *) NULL);
	    return HAX_ERROR;
	}
	searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]);
	if (searchPtr == NULL) {
	    return HAX_ERROR;
	}
	while (1) {
	    Var *varPtr2;

	    hPtr = searchPtr->nextEntry;
	    if (hPtr == NULL) {
		hPtr = Hax_NextHashEntry(&searchPtr->search);
		if (hPtr == NULL) {
		    return HAX_OK;
		}
	    } else {
		searchPtr->nextEntry = NULL;
	    }
	    varPtr2 = (Var *) Hax_GetHashValue(hPtr);
	    if (!(varPtr2->flags & VAR_UNDEFINED)) {
		break;
	    }
	}
	interp->result = Hax_GetHashKey(varPtr->value.tablePtr, hPtr);
    } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0)
	    && (length >= 2)) {
	Hax_HashSearch search;
	Var *varPtr2;
	int size;

	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " size arrayName\"", (char *) NULL);
	    return HAX_ERROR;
	}
	size = 0;
	for (hPtr = Hax_FirstHashEntry(varPtr->value.tablePtr, &search);
		hPtr != NULL; hPtr = Hax_NextHashEntry(&search)) {
	    varPtr2 = (Var *) Hax_GetHashValue(hPtr);
	    if (varPtr2->flags & VAR_UNDEFINED) {
		continue;
	    }
	    size++;
	}
	sprintf(interp->result, "%d", size);
    } else if ((c == 's') && (strncmp(argv[1], "startsearch", length) == 0)
	    && (length >= 2)) {
	ArraySearch *searchPtr;

	if (argc != 3) {
	    Hax_AppendResult(interp, "wrong # args: should be \"",
		    argv[0], " startsearch arrayName\"", (char *) NULL);
	    return HAX_ERROR;
	}
	searchPtr = (ArraySearch *) ckalloc(memoryp, sizeof(ArraySearch));
	if (varPtr->searchPtr == NULL) {
	    searchPtr->id = 1;
	    Hax_AppendResult(interp, "s-1-", argv[2], (char *) NULL);
	} else {
	    char string[20];

	    searchPtr->id = varPtr->searchPtr->id + 1;
	    sprintf(string, "%d", searchPtr->id);
	    Hax_AppendResult(interp, "s-", string, "-", argv[2],
		    (char *) NULL);
	}
	searchPtr->varPtr = varPtr;
	searchPtr->nextEntry = Hax_FirstHashEntry(varPtr->value.tablePtr,
		&searchPtr->search);
	searchPtr->nextPtr = varPtr->searchPtr;
	varPtr->searchPtr = searchPtr;
    } else {
	Hax_AppendResult(interp, "bad option \"", argv[1],
		"\": should be anymore, donesearch, names, nextelement, ",
		"size, or startsearch", (char *) NULL);
	return HAX_ERROR;
    }
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r15
movq %rsi, %rbx
cmpl $0x2, %edx
jg 0x12e58
movq (%r15), %rdx
leaq 0x1a11(%rip), %rsi      # 0x14860
leaq 0x33bf(%rip), %rcx      # 0x16215
jmp 0x12eb9
movl %edx, %ebp
movq 0x280(%rbx), %r14
movq 0xc8(%rbx), %rax
leaq 0x40(%rax), %rcx
leaq 0xa8(%rbx), %rdx
testq %rax, %rax
cmovneq %rcx, %rdx
leaq 0x68(%rbx), %rdi
cmovneq %rax, %rdi
movq 0x10(%r15), %rsi
callq *(%rdx)
testq %rax, %rax
je 0x12ea7
movq 0x18(%rax), %rcx
movl 0x20(%rcx), %eax
testb $0x2, %al
je 0x12ea3
movq 0x28(%rcx), %rax
movq 0x18(%rax), %rcx
movl 0x20(%rcx), %eax
testb $0x1, %al
jne 0x12edc
movq 0x10(%r15), %rdx
leaq 0x13fd(%rip), %rsi      # 0x142af
leaq 0x3379(%rip), %rcx      # 0x16232
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
movl $0x1, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x8(%rsp)
movq %rcx, (%rsp)
movq 0x8(%r15), %r13
movzbl (%r13), %r14d
movq %r13, %rdi
callq 0x41d0
movq %rax, %r12
cmpl $0x6d, %r14d
jg 0x12f7d
cmpl $0x61, %r14d
je 0x13024
cmpl $0x64, %r14d
jne 0x13279
movslq %r12d, %rdx
leaq 0x334b(%rip), %rsi      # 0x16268
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
jne 0x13279
cmpl $0x4, %ebp
jne 0x132cf
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x133a6
testq %rax, %rax
je 0x12ec6
movq 0x18(%rbx), %rcx
cmpq %rax, %rcx
je 0x1337b
movq 0x8(%rsp), %rdi
movq %rcx, %rbx
movq 0x30(%rcx), %rcx
cmpq %rax, %rcx
jne 0x12f68
addq $0x30, %rbx
jmp 0x13384
cmpl $0x6e, %r14d
je 0x130a2
cmpl $0x73, %r14d
jne 0x13279
movslq %r12d, %r14
leaq 0x333d(%rip), %rsi      # 0x162d8
movq %r13, %rdi
movq %r14, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x2, %r12d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x13131
cmpl $0x3, %ebp
jne 0x132a3
movq (%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0x10(%rsp), %rsi
callq 0x43e0
xorl %ebp, %ebp
movl $0x0, %r14d
testq %rax, %rax
je 0x1300b
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
movq 0x18(%rax), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x1, %eax
adcl $0x0, %r14d
movq %r15, %rdi
callq 0x4390
testq %rax, %rax
jne 0x12fed
movq (%rbx), %rdi
leaq 0x12fe(%rip), %rsi      # 0x14313
movl %r14d, %edx
xorl %eax, %eax
callq 0x45e0
jmp 0x12ecb
movslq %r12d, %rdx
leaq 0x3215(%rip), %rsi      # 0x16243
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
jne 0x13279
cmpl $0x4, %ebp
jne 0x132e5
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x133a6
testq %rax, %rax
je 0x12ec6
movq %rax, %r14
movq %rax, %r15
addq $0x10, %r15
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x13085
movq 0x18(%rax), %rax
testb $0x4, 0x20(%rax)
je 0x1336f
movq %r15, %rdi
callq 0x4390
movq %rax, 0x28(%r14)
testq %rax, %rax
jne 0x13072
leaq 0x1d4c(%rip), %rax      # 0x14de9
jmp 0x13376
movslq %r12d, %r14
leaq 0x31e7(%rip), %rsi      # 0x16293
movq %r13, %rdi
movq %r14, %rdx
callq 0x40c0
testl %eax, %eax
sete %al
cmpl $0x2, %r12d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x131d8
cmpl $0x3, %ebp
jne 0x132b9
movq (%rsp), %r14
movq 0x28(%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0x43e0
testq %rax, %rax
je 0x1339f
leaq 0x10(%rsp), %r15
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
jne 0x1311f
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x13112
movq (%rax), %rax
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x4050
movq %r15, %rdi
callq 0x4390
testq %rax, %rax
jne 0x130f7
jmp 0x1339f
cmpl $0x2, %r12d
movq %r14, %rdx
setge %r14b
leaq 0x320b(%rip), %rsi      # 0x1634e
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
sete %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x13279
cmpl $0x3, %ebp
jne 0x132fb
leaq 0x3058(%rip), %rdx      # 0x161c3
movl $0x38, %esi
movq 0x8(%rsp), %rdi
movl $0x65e, %ecx            # imm = 0x65E
callq 0x44d0
movq %rax, %r12
movq (%rsp), %r14
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x13327
movl (%rax), %edx
incl %edx
movl %edx, (%r12)
leaq 0x1171(%rip), %rsi      # 0x14313
leaq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x45e0
movq 0x10(%r15), %r8
leaq 0x314f(%rip), %rsi      # 0x1630b
leaq 0x3146(%rip), %rcx      # 0x16309
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4510
jmp 0x13346
cmpl $0x2, %r12d
movq %r14, %rdx
setge %r14b
leaq 0x30c1(%rip), %rsi      # 0x162ab
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
sete %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x13279
cmpl $0x4, %ebp
jne 0x13311
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x133a6
testq %rax, %rax
je 0x12ec6
movq %rax, %r15
movq %rax, %r12
addq $0x10, %r12
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x13244
movq $0x0, 0x28(%r15)
jmp 0x13255
movq %r12, %rdi
callq 0x4390
testq %rax, %rax
je 0x1339f
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
jne 0x13231
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x13376
movq (%rax), %rax
jmp 0x13376
leaq 0x149d(%rip), %rsi      # 0x1471d
leaq 0x3087(%rip), %rcx      # 0x1630e
leaq 0x30b7(%rip), %r8       # 0x16345
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4510
jmp 0x12ec6
movq (%r15), %rdx
leaq 0x15b3(%rip), %rsi      # 0x14860
leaq 0x3029(%rip), %rcx      # 0x162dd
jmp 0x12eb9
movq (%r15), %rdx
leaq 0x159d(%rip), %rsi      # 0x14860
leaq 0x2fcf(%rip), %rcx      # 0x16299
jmp 0x12eb9
movq (%r15), %rdx
leaq 0x1587(%rip), %rsi      # 0x14860
leaq 0x2f93(%rip), %rcx      # 0x16273
jmp 0x12eb9
movq (%r15), %rdx
leaq 0x1571(%rip), %rsi      # 0x14860
leaq 0x2f55(%rip), %rcx      # 0x1624b
jmp 0x12eb9
movq (%r15), %rdx
leaq 0x155b(%rip), %rsi      # 0x14860
leaq 0x2fe2(%rip), %rcx      # 0x162ee
jmp 0x12eb9
movq (%r15), %rdx
leaq 0x1545(%rip), %rsi      # 0x14860
leaq 0x2f95(%rip), %rcx      # 0x162b7
jmp 0x12eb9
movl $0x1, (%r12)
movq 0x10(%r15), %rdx
leaq 0x2fcc(%rip), %rsi      # 0x16306
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4510
movq %r14, 0x8(%r12)
movq 0x28(%r14), %rdi
movq %r12, %rsi
addq $0x10, %rsi
callq 0x43e0
movq %rax, 0x28(%r12)
movq 0x18(%r14), %rax
movq %rax, 0x30(%r12)
movq %r12, 0x18(%r14)
jmp 0x1339f
leaq 0x1dc3(%rip), %rax      # 0x15139
movq %rax, (%rbx)
jmp 0x1339f
addq $0x18, %rbx
movq 0x8(%rsp), %rdi
movq 0x30(%rax), %rcx
movq %rcx, (%rbx)
leaq 0x2e31(%rip), %rdx      # 0x161c3
movq %rax, %rsi
movl $0x60b, %ecx            # imm = 0x60B
callq 0x4280
xorl %ebp, %ebp
jmp 0x12ecb