// File: /workspace/github_c_makefile_star2_O2/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 0x11e31
movq (%r15), %rdx
leaq 0x1a38(%rip), %rsi      # 0x13860
leaq 0x33b6(%rip), %rcx      # 0x151e5
jmp 0x11e92
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 0x11e80
movq 0x18(%rax), %rcx
movl 0x20(%rcx), %eax
testb $0x2, %al
je 0x11e7c
movq 0x28(%rcx), %rax
movq 0x18(%rax), %rcx
movl 0x20(%rcx), %eax
testb $0x1, %al
jne 0x11eb3
movq 0x10(%r15), %rdx
leaq 0x1424(%rip), %rsi      # 0x132af
leaq 0x3370(%rip), %rcx      # 0x15202
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %rbx
movl %ebx, %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 $0x73, %r14d
je 0x12065
cmpl $0x64, %r14d
je 0x11f76
cmpl $0x6e, %r14d
je 0x11fe0
cmpl $0x61, %r14d
jne 0x12217
movslq %r12d, %rdx
leaq 0x3311(%rip), %rsi      # 0x15213
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
jne 0x12217
cmpl $0x4, %ebp
jne 0x1229d
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x1235e
testq %rax, %rax
je 0x11e9f
movq %rax, %r14
movq %rax, %r15
addq $0x10, %r15
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x11f59
movq 0x18(%rax), %rax
testb $0x4, 0x20(%rax)
je 0x12327
movq %r15, %rdi
callq 0x43a0
movq %rax, 0x28(%r14)
testq %rax, %rax
jne 0x11f46
leaq 0x1e78(%rip), %rax      # 0x13de9
jmp 0x1232e
movslq %r12d, %rdx
leaq 0x32b8(%rip), %rsi      # 0x15238
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
jne 0x12217
cmpl $0x4, %ebp
jne 0x12287
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x1235e
testq %rax, %rax
je 0x11e9f
movq 0x18(%rbx), %rcx
cmpq %rax, %rcx
je 0x12333
movq 0x8(%rsp), %rdi
movq %rcx, %rbx
movq 0x30(%rcx), %rcx
cmpq %rax, %rcx
jne 0x11fcb
addq $0x30, %rbx
jmp 0x1233c
movslq %r12d, %r14
leaq 0x3279(%rip), %rsi      # 0x15263
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 0x120d4
cmpl $0x3, %ebp
jne 0x12241
movq (%rsp), %r14
movq 0x28(%r14), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x43f0
testq %rax, %rax
je 0x12357
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
jne 0x1205b
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x1204e
movq (%rax), %rax
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x4050
movq %r15, %rdi
callq 0x43a0
jmp 0x1202a
movslq %r12d, %r14
leaq 0x3239(%rip), %rsi      # 0x152a8
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 0x12176
cmpl $0x3, %ebp
jne 0x12257
movq (%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x43f0
xorl %ebp, %ebp
testq %rax, %rax
je 0x1226d
movq 0x18(%rax), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x1, %eax
adcl $0x0, %ebp
movq %r14, %rdi
callq 0x43a0
jmp 0x120b1
cmpl $0x2, %r12d
movq %r14, %rdx
setge %r14b
leaq 0x3195(%rip), %rsi      # 0x1527b
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
sete %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x12217
cmpl $0x4, %ebp
jne 0x122b3
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x1235e
testq %rax, %rax
je 0x11e9f
movq %rax, %r15
movq %rax, %r12
addq $0x10, %r12
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x12141
andq $0x0, 0x28(%r15)
jmp 0x12152
movq %r12, %rdi
callq 0x43a0
testq %rax, %rax
je 0x12357
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
jne 0x12131
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x1232e
movq (%rax), %rax
jmp 0x1232e
cmpl $0x2, %r12d
movq %r14, %rdx
setge %r14b
leaq 0x3196(%rip), %rsi      # 0x1531e
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
sete %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x12217
cmpl $0x3, %ebp
jne 0x122c9
leaq 0x2fe7(%rip), %rdx      # 0x15193
pushq $0x38
popq %rsi
movq 0x8(%rsp), %rdi
movl $0x65e, %ecx            # imm = 0x65E
callq 0x44e0
movq %rax, %r12
movq (%rsp), %r14
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x122df
movl (%rax), %edx
incl %edx
movl %edx, (%r12)
leaq 0x1132(%rip), %rsi      # 0x13313
leaq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x45f0
movq 0x10(%r15), %r8
leaq 0x30e0(%rip), %rsi      # 0x152db
leaq 0x30d7(%rip), %rcx      # 0x152d9
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4520
jmp 0x122fe
leaq 0x14ff(%rip), %rsi      # 0x1371d
leaq 0x30b9(%rip), %rcx      # 0x152de
leaq 0x30e9(%rip), %r8       # 0x15315
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4520
jmp 0x11e9f
movq (%r15), %rdx
leaq 0x1615(%rip), %rsi      # 0x13860
leaq 0x3017(%rip), %rcx      # 0x15269
jmp 0x11e92
movq (%r15), %rdx
leaq 0x15ff(%rip), %rsi      # 0x13860
leaq 0x3045(%rip), %rcx      # 0x152ad
jmp 0x11e92
movq (%rbx), %rdi
leaq 0x109c(%rip), %rsi      # 0x13313
xorl %ebx, %ebx
movl %ebp, %edx
xorl %eax, %eax
callq 0x45f0
jmp 0x11ea2
movq (%r15), %rdx
leaq 0x15cf(%rip), %rsi      # 0x13860
leaq 0x2fab(%rip), %rcx      # 0x15243
jmp 0x11e92
movq (%r15), %rdx
leaq 0x15b9(%rip), %rsi      # 0x13860
leaq 0x2f6d(%rip), %rcx      # 0x1521b
jmp 0x11e92
movq (%r15), %rdx
leaq 0x15a3(%rip), %rsi      # 0x13860
leaq 0x2fc3(%rip), %rcx      # 0x15287
jmp 0x11e92
movq (%r15), %rdx
leaq 0x158d(%rip), %rsi      # 0x13860
leaq 0x2fe4(%rip), %rcx      # 0x152be
jmp 0x11e92
movl $0x1, (%r12)
movq 0x10(%r15), %rdx
leaq 0x2fe4(%rip), %rsi      # 0x152d6
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4520
movq %r14, 0x8(%r12)
movq 0x28(%r14), %rdi
movq %r12, %rsi
addq $0x10, %rsi
callq 0x43f0
movq %rax, 0x28(%r12)
movq 0x18(%r14), %rax
movq %rax, 0x30(%r12)
movq %r12, 0x18(%r14)
jmp 0x12357
leaq 0x1ddf(%rip), %rax      # 0x1410d
movq %rax, (%rbx)
jmp 0x12357
addq $0x18, %rbx
movq 0x8(%rsp), %rdi
movq 0x30(%rax), %rcx
movq %rcx, (%rbx)
leaq 0x2e49(%rip), %rdx      # 0x15193
movq %rax, %rsi
movl $0x60b, %ecx            # imm = 0x60B
callq 0x4280
xorl %ebx, %ebx
jmp 0x11ea2