// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r15
movq %rsi, %rbx
cmpl $0x2, %edx
jg 0x13694
movq (%r15), %rdx
leaq 0x21e9(%rip), %rsi      # 0x15874
leaq 0x3e7f(%rip), %rcx      # 0x17511
jmp 0x136f5
movl %edx, %ebp
movq 0x280(%rbx), %r12
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 0x136e3
movq 0x18(%rax), %r14
testb $0x2, 0x20(%r14)
je 0x136dc
movq 0x28(%r14), %rax
movq 0x18(%rax), %r14
testb $0x1, 0x20(%r14)
jne 0x13716
movq 0x10(%r15), %rdx
leaq 0x1bc1(%rip), %rsi      # 0x152af
leaq 0x3e39(%rip), %rcx      # 0x1752e
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x18(%rsp)
movq 0x8(%r15), %r13
movzbl (%r13), %r12d
movq %r13, %rdi
callq 0x41d0
cmpl $0x6d, %r12d
jg 0x1377f
cmpl $0x61, %r12d
je 0x13821
cmpl $0x64, %r12d
jne 0x13b5d
movq %rax, 0x8(%rsp)
movslq %eax, %rdx
leaq 0x3e0f(%rip), %rsi      # 0x17564
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
je 0x13a54
cmpl $0x73, %r12d
movq 0x8(%rsp), %rax
je 0x13793
cmpl $0x6e, %r12d
je 0x13859
jmp 0x13b5d
cmpl $0x6e, %r12d
je 0x13859
cmpl $0x73, %r12d
jne 0x13b5d
movslq %eax, %rdx
leaq 0x3e37(%rip), %rsi      # 0x175d4
movq %r13, %rdi
movq %rax, %r12
movq %rdx, 0x10(%rsp)
callq 0x40c0
movq %r12, %rdx
testl %eax, %eax
sete %al
cmpl $0x2, %edx
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x138ef
cmpl $0x3, %ebp
jne 0x13aa0
movq 0x28(%r14), %rdi
leaq 0x20(%rsp), %rsi
callq 0x43d0
xorl %r14d, %r14d
testq %rax, %rax
je 0x13808
leaq 0x20(%rsp), %r15
movq 0x18(%rax), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x1, %eax
adcl $0x0, %r14d
movq %r15, %rdi
callq 0x4380
testq %rax, %rax
jne 0x137ea
movq (%rbx), %rdi
leaq 0x1b01(%rip), %rsi      # 0x15313
movl %r14d, %edx
xorl %eax, %eax
callq 0x45d0
jmp 0x13bbb
movq %rax, 0x8(%rsp)
movslq %eax, %rdx
leaq 0x3d0f(%rip), %rsi      # 0x1753f
movq %r13, %rdi
callq 0x40c0
testl %eax, %eax
je 0x13ab6
cmpl $0x73, %r12d
movq 0x8(%rsp), %rax
je 0x13793
cmpl $0x6e, %r12d
jne 0x1373c
movq %rax, 0x8(%rsp)
movslq %eax, %rdx
leaq 0x3d27(%rip), %rsi      # 0x1758f
movq %r13, %rdi
movq %rdx, 0x10(%rsp)
callq 0x40c0
movq 0x8(%rsp), %rdx
testl %eax, %eax
sete %al
cmpl $0x2, %edx
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x13993
cmpl $0x3, %ebp
jne 0x13b3b
movq 0x28(%r14), %rdi
leaq 0x20(%rsp), %rsi
callq 0x43d0
testq %rax, %rax
je 0x13bbb
leaq 0x20(%rsp), %r15
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
jne 0x138dd
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x138d0
movq (%rax), %rax
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x4050
movq %r15, %rdi
callq 0x4380
testq %rax, %rax
jne 0x138b5
jmp 0x13bbb
cmpl $0x2, %edx
setge %r12b
leaq 0x3d4d(%rip), %rsi      # 0x1764a
movq %r13, %rdi
movq 0x10(%rsp), %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb %r12b, %al
cmpb $0x1, %al
jne 0x13b5d
cmpl $0x3, %ebp
jne 0x13b9d
leaq 0x3b95(%rip), %rdx      # 0x174bf
movl $0x38, %esi
movq 0x18(%rsp), %rdi
movl $0x65e, %ecx            # imm = 0x65E
callq 0x44c0
movq %rax, %r12
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x13c0e
movl (%rax), %edx
incl %edx
movl %edx, (%r12)
leaq 0x19b6(%rip), %rsi      # 0x15313
leaq 0x20(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x45d0
movq 0x10(%r15), %r8
leaq 0x3c90(%rip), %rsi      # 0x17607
leaq 0x3c87(%rip), %rcx      # 0x17605
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4500
jmp 0x13c2d
cmpl $0x2, %edx
setge 0x7(%rsp)
leaq 0x3c05(%rip), %rsi      # 0x175a7
movq %r13, %rdi
movq 0x10(%rsp), %rdx
callq 0x40c0
testl %eax, %eax
sete %al
andb 0x7(%rsp), %al
cmpb $0x1, %al
jne 0x13b4e
cmpl $0x4, %ebp
jne 0x13be6
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13c9f
testq %rax, %rax
je 0x13c59
movq %rax, %r15
movq %rax, %r12
addq $0x10, %r12
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x13a02
movq $0x0, 0x28(%r15)
jmp 0x13a0f
movq %r12, %rdi
callq 0x4380
testq %rax, %rax
je 0x13a22
movq 0x18(%rax), %rcx
testb $0x4, 0x20(%rcx)
movl $0xc, %ecx
je 0x13a29
xorl %ecx, %ecx
jmp 0x13a29
movl $0x1, %ecx
xorl %eax, %eax
testl %ecx, %ecx
je 0x139ef
cmpl $0xc, %ecx
jne 0x13c63
movq 0x28(%r14), %rcx
addq $0x20, %rax
cmpl $0x1, 0x3c(%rcx)
jne 0x13a47
movq (%rax), %rax
movq %rax, (%rbx)
xorl %eax, %eax
movb $0x1, %r14b
jmp 0x13c68
cmpl $0x4, %ebp
jne 0x13b87
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13c9f
testq %rax, %rax
je 0x13702
movq 0x18(%r14), %rcx
cmpq %rax, %rcx
je 0x13c76
movq 0x18(%rsp), %rdi
movq %rcx, %r14
movq 0x30(%rcx), %rcx
cmpq %rax, %rcx
jne 0x13a8b
addq $0x30, %r14
jmp 0x13c7f
movq (%r15), %rdx
leaq 0x1dca(%rip), %rsi      # 0x15874
leaq 0x3b28(%rip), %rcx      # 0x175d9
jmp 0x13bae
cmpl $0x4, %ebp
jne 0x13bd0
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13c9f
testq %rax, %rax
je 0x13702
movq %rax, %r14
movq %rax, %r15
addq $0x10, %r15
leaq 0x24a1(%rip), %r12      # 0x15f8d
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x13b04
movq 0x18(%rax), %rax
movl $0x4, %ecx
testb $0x4, 0x20(%rax)
je 0x13b1f
movq %r15, %rdi
callq 0x4380
movq %rax, 0x28(%r14)
xorl %ecx, %ecx
testq %rax, %rax
jne 0x13b1f
movq %r12, (%rbx)
movl $0x1, %ecx
testl %ecx, %ecx
je 0x13aec
cmpl $0x4, %ecx
jne 0x13bc9
leaq 0x27fa(%rip), %rax      # 0x1632d
movq %rax, (%rbx)
jmp 0x13bc9
movq (%r15), %rdx
leaq 0x1d2f(%rip), %rsi      # 0x15874
leaq 0x3a49(%rip), %rcx      # 0x17595
jmp 0x13bae
cmpl $0x73, %r12d
movq 0x8(%rsp), %rax
je 0x13793
leaq 0x1bb9(%rip), %rsi      # 0x1571d
leaq 0x3a9f(%rip), %rcx      # 0x1760a
leaq 0x3acf(%rip), %r8       # 0x17641
movq %rbx, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x4500
jmp 0x13702
movq (%r15), %rdx
leaq 0x1ce3(%rip), %rsi      # 0x15874
leaq 0x39d7(%rip), %rcx      # 0x1756f
jmp 0x136f5
movq (%r15), %rdx
leaq 0x1ccd(%rip), %rsi      # 0x15874
leaq 0x3a3c(%rip), %rcx      # 0x175ea
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %eax
cmpl $0x3, %ebp
jne 0x13707
xorl %eax, %eax
jmp 0x13707
movq (%r15), %rdx
leaq 0x1c9a(%rip), %rsi      # 0x15874
leaq 0x3966(%rip), %rcx      # 0x17547
jmp 0x136f5
movq (%r15), %rdx
leaq 0x1c84(%rip), %rsi      # 0x15874
leaq 0x39bc(%rip), %rcx      # 0x175b3
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %eax
jmp 0x13c68
movl $0x1, (%r12)
movq 0x10(%r15), %rdx
leaq 0x39e1(%rip), %rsi      # 0x17602
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4500
movq %r14, 0x8(%r12)
movq 0x28(%r14), %rdi
movq %r12, %rsi
addq $0x10, %rsi
callq 0x43d0
movq %rax, 0x28(%r12)
movq 0x18(%r14), %rax
movq %rax, 0x30(%r12)
movq %r12, 0x18(%r14)
jmp 0x13bbb
movl $0x1, %eax
xorl %r14d, %r14d
jmp 0x13c68
xorl %r14d, %r14d
xorl %eax, %eax
testb %r14b, %r14b
je 0x13707
jmp 0x13bc9
addq $0x18, %r14
movq 0x18(%rsp), %rdi
movq 0x30(%rax), %rcx
movq %rcx, (%r14)
leaq 0x3832(%rip), %rdx      # 0x174bf
movq %rax, %rsi
movl $0x60b, %ecx            # imm = 0x60B
callq 0x4280
jmp 0x13bc9