// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxVar.c
// Function: Hax_SetVar2
char *
Hax_SetVar2(
    Hax_Interp *interp,		/* Command interpreter in which variable is
				 * to be looked up. */
    char *part1,		/* If part2 is NULL, this is name of scalar
				 * variable.  Otherwise it is name of array. */
    char *part2,		/* Name of an element within array, or NULL. */
    char *newValue,		/* New value for variable. */
    int flags			/* Various flags that tell how to set value:
				 * any of HAX_GLOBAL_ONLY, HAX_APPEND_VALUE,
				 * HAX_LIST_ELEMENT, and HAX_NO_SPACE, or
				 * HAX_LEAVE_ERR_MSG . */)
{
    Hax_HashEntry *hPtr;
    Var *varPtr = NULL;
				/* Initial value only used to stop compiler
				 * from complaining; not really needed. */
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int length, newPtr, listFlags;
    Var *arrayPtr = NULL;

    /*
     * Lookup the first name.
     */

    if ((flags & HAX_GLOBAL_ONLY) || (iPtr->varFramePtr == NULL)) {
	hPtr = Hax_CreateHashEntry(interp, &iPtr->globalTable, part1, &newPtr);
    } else {
	hPtr = Hax_CreateHashEntry(interp, &iPtr->varFramePtr->varTable,
		part1, &newPtr);
    }
    if (!newPtr) {
	varPtr = (Var *) Hax_GetHashValue(hPtr);
	if (varPtr->flags & VAR_UPVAR) {
	    hPtr = varPtr->value.upvarPtr;
	    varPtr = (Var *) Hax_GetHashValue(hPtr);
	}
    }

    /*
     * If this is an array reference, then create a new array (if
     * needed), remember any traces on the array, and lookup the
     * element within the array.
     */

    if (part2 != NULL) {
	if (newPtr) {
	    varPtr = NewVar(interp, 0);
	    Hax_SetHashValue(hPtr, varPtr);
	    varPtr->flags = VAR_ARRAY;
	    varPtr->value.tablePtr = (Hax_HashTable *)
		    ckalloc(memoryp, sizeof(Hax_HashTable));
	    Hax_InitHashTable(varPtr->value.tablePtr, HAX_STRING_KEYS);
	} else {
	    if (varPtr->flags & VAR_UNDEFINED) {
		varPtr->flags = VAR_ARRAY;
		varPtr->value.tablePtr = (Hax_HashTable *)
			ckalloc(memoryp, sizeof(Hax_HashTable));
		Hax_InitHashTable(varPtr->value.tablePtr, HAX_STRING_KEYS);
	    } else if (!(varPtr->flags & VAR_ARRAY)) {
		if (flags & HAX_LEAVE_ERR_MSG) {
		    VarErrMsg(interp, part1, part2, (char *) "set",
			(char *) needArray);
		}
		return NULL;
	    }
	    arrayPtr = varPtr;
	}
	hPtr = Hax_CreateHashEntry(interp, varPtr->value.tablePtr, part2,
	                           &newPtr);
    }

    /*
     * Compute how many bytes will be needed for newValue (leave space
     * for a separating space between list elements).
     */

    if (flags & HAX_LIST_ELEMENT) {
	length = Hax_ScanElement(newValue, &listFlags) + 1;
    } else {
	length = strlen(newValue);
    }

    /*
     * If the variable doesn't exist then create a new one.  If it
     * does exist then clear its current value unless this is an
     * append operation.
     */

    if (newPtr) {
	varPtr = NewVar(interp, length);
	Hax_SetHashValue(hPtr, varPtr);
	if ((arrayPtr != NULL) && (arrayPtr->searchPtr != NULL)) {
	    DeleteSearches(interp, arrayPtr);
	}
    } else {
	varPtr = (Var *) Hax_GetHashValue(hPtr);
	if (varPtr->flags & VAR_ARRAY) {
	    if (flags & HAX_LEAVE_ERR_MSG) {
		VarErrMsg(interp, part1, part2, (char *) "set",
		    (char *) isArray);
	    }
	    return NULL;
	}
	if (!(flags & HAX_APPEND_VALUE) || (varPtr->flags & VAR_UNDEFINED)) {
	    varPtr->valueLength = 0;
	}
    }

    /*
     * Make sure there's enough space to hold the variable's
     * new value.  If not, enlarge the variable's space.
     */

    if ((length + varPtr->valueLength) >= varPtr->valueSpace) {
	Var *newVarPtr;
	int newSize;

	newSize = 2*varPtr->valueSpace;
	if (newSize <= (length + varPtr->valueLength)) {
	    newSize += length;
	}
	newVarPtr = NewVar(interp, newSize);
	newVarPtr->valueLength = varPtr->valueLength;
	newVarPtr->upvarUses = varPtr->upvarUses;
	newVarPtr->tracePtr = varPtr->tracePtr;
	newVarPtr->searchPtr = varPtr->searchPtr;
	newVarPtr->flags = varPtr->flags;
	strcpy(newVarPtr->value.string, varPtr->value.string);
	Hax_SetHashValue(hPtr, newVarPtr);
	ckfree(memoryp, (char *) varPtr);
	varPtr = newVarPtr;
    }

    /*
     * Append the new value to the variable, either as a list
     * element or as a string.
     */

    if (flags & HAX_LIST_ELEMENT) {
	if ((varPtr->valueLength > 0) && !(flags & HAX_NO_SPACE)) {
	    ((char *)varPtr->value.string)[varPtr->valueLength] = ' ';
	    varPtr->valueLength++;
	}
	varPtr->valueLength += Hax_ConvertElement(newValue,
		(char *)varPtr->value.string + varPtr->valueLength, listFlags);
	((char *)varPtr->value.string)[varPtr->valueLength] = 0;
    } else {
	strcpy(((char *)varPtr->value.string) + varPtr->valueLength, newValue);
	varPtr->valueLength += length;
    }
    varPtr->flags &= ~VAR_UNDEFINED;

    /*
     * Invoke any write traces for the variable.
     */

    if ((varPtr->tracePtr != NULL)
	    || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) {
	char *msg;

	msg = CallTraces(iPtr, arrayPtr, hPtr, part1, part2,
		(flags & HAX_GLOBAL_ONLY) | HAX_TRACE_WRITES);
	if (msg != NULL) {
	    VarErrMsg(interp, part1, part2, (char *) "set", (char *) msg);
	    return NULL;
	}

	/*
	 * Watch out!  The variable could have gotten re-allocated to
	 * a larger size.  Fortunately the hash table entry will still
	 * be around.
	 */

	varPtr = (Var *) Hax_GetHashValue(hPtr);
    }
    return varPtr->value.string;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x68(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x19d0f
movq -0x48(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
jne 0x19d36
movq -0x48(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
addq $0x68, %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq *%rax
movq %rax, -0x38(%rbp)
jmp 0x19d62
movq -0x48(%rbp), %rax
movq 0xc8(%rax), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq 0xc8(%rcx), %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq *%rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x19d9d
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x19d9b
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x19d9d
cmpq $0x0, -0x20(%rbp)
je 0x19ed5
cmpl $0x0, -0x58(%rbp)
je 0x19e0d
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x1a1e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x50(%rbp), %rdi
movl $0x50, %esi
leaq 0x5acb(%rip), %rdx      # 0x1f8af
movl $0x182, %ecx            # imm = 0x182
callq 0x44c0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rdi
xorl %esi, %esi
callq 0x4590
jmp 0x19eaf
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x19e5d
movq -0x40(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x50(%rbp), %rdi
movl $0x50, %esi
leaq 0x5a78(%rip), %rdx      # 0x1f8af
movl $0x188, %ecx            # imm = 0x188
callq 0x44c0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rdi
xorl %esi, %esi
callq 0x4590
jmp 0x19ea7
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x19ea5
movl -0x2c(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x19e98
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x99dc(%rip), %r8       # 0x23868
leaq 0x355e(%rip), %rcx      # 0x1d3f1
callq 0x19900
movq $0x0, -0x8(%rbp)
jmp 0x1a1c5
jmp 0x19ea7
movq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rsi
movq -0x20(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq *%rax
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x19ef5
movq -0x28(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x4100
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x19f01
movq -0x28(%rbp), %rdi
callq 0x41b0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x19f44
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x1a1e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
cmpq $0x0, -0x68(%rbp)
je 0x19f42
movq -0x68(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x19f42
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1a2a0
jmp 0x19fbe
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x19f98
movl -0x2c(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x19f8b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x98f9(%rip), %r8       # 0x23878
leaq 0x346b(%rip), %rcx      # 0x1d3f1
callq 0x19900
movq $0x0, -0x8(%rbp)
jmp 0x1a1c5
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x19fb2
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x19fbc
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
jmp 0x19fbe
movl -0x54(%rbp), %eax
movq -0x40(%rbp), %rcx
addl (%rcx), %eax
movq -0x40(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jl 0x1a093
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl -0x54(%rbp), %ecx
movq -0x40(%rbp), %rdx
addl (%rdx), %ecx
cmpl %ecx, %eax
jg 0x19ff9
movl -0x54(%rbp), %eax
addl -0x74(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x1a1e0
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x70(%rbp), %rdi
addq $0x28, %rdi
movq -0x40(%rbp), %rsi
addq $0x28, %rsi
callq 0x40d0
movq -0x70(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x582e(%rip), %rdx      # 0x1f8af
movl $0x1d1, %ecx            # imm = 0x1D1
callq 0x4260
movq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1a107
movq -0x40(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x1a0cd
movl -0x2c(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x1a0cd
movq -0x40(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
movb $0x20, 0x28(%rax,%rcx)
movq -0x40(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x28, %rsi
movq -0x40(%rbp), %rax
movslq (%rax), %rax
addq %rax, %rsi
movl -0x5c(%rbp), %edx
callq 0x4150
movl %eax, %ecx
movq -0x40(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
movb $0x0, 0x28(%rax,%rcx)
jmp 0x1a12d
movq -0x40(%rbp), %rdi
addq $0x28, %rdi
movq -0x40(%rbp), %rax
movslq (%rax), %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x40d0
movl -0x54(%rbp), %ecx
movq -0x40(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl 0x20(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x20(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1a157
cmpq $0x0, -0x68(%rbp)
je 0x1a1b9
movq -0x68(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1a1b9
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
movl -0x2c(%rbp), %r9d
andl $0x1, %r9d
orl $0x20, %r9d
callq 0x199a0
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x1a1ad
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x80(%rbp), %r8
leaq 0x3253(%rip), %rcx      # 0x1d3f1
callq 0x19900
movq $0x0, -0x8(%rbp)
jmp 0x1a1c5
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)