// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxVar.c
// Function: HaxDeleteVars
void
HaxDeleteVars(
    Interp *iPtr,		/* Interpreter to which variables belong. */
    Hax_HashTable *tablePtr	/* Hash table containing variables to
				 * delete. */)
{
    Hax_Memoryp *memoryp = iPtr->memoryp;
    Hax_HashSearch search;
    Hax_HashEntry *hPtr;
    Var *varPtr;
    int flags, globalFlag;

    flags = HAX_TRACE_UNSETS;
    if (tablePtr == &iPtr->globalTable) {
	flags |= HAX_INTERP_DESTROYED | HAX_GLOBAL_ONLY;
    }
    for (hPtr = Hax_FirstHashEntry(tablePtr, &search); hPtr != NULL;
	    hPtr = Hax_NextHashEntry(&search)) {
	varPtr = (Var *) Hax_GetHashValue(hPtr);

	/*
	 * For global/upvar variables referenced in procedures, free up the
	 * local space and then decrement the reference count on the
	 * variable referred to.  If there are no more references to the
	 * global/upvar and it is undefined and has no traces set, then
	 * follow on and delete the referenced variable too.
	 */

	globalFlag = 0;
	if (varPtr->flags & VAR_UPVAR) {
	    hPtr = varPtr->value.upvarPtr;
	    ckfree(memoryp, (char *) varPtr);
	    varPtr = (Var *) Hax_GetHashValue(hPtr);
	    varPtr->upvarUses--;
	    if ((varPtr->upvarUses != 0) || !(varPtr->flags & VAR_UNDEFINED)
		    || (varPtr->tracePtr != NULL)) {
		continue;
	    }
	    globalFlag = HAX_GLOBAL_ONLY;
	}

	/*
	 * Invoke traces on the variable that is being deleted, then
	 * free up the variable's space (no need to free the hash entry
	 * here, unless we're dealing with a global variable:  the
	 * hash entries will be deleted automatically when the whole
	 * table is deleted).
	 */

	if (varPtr->tracePtr != NULL) {
	    (void) CallTraces(iPtr, (Var *) NULL, hPtr,
		    Hax_GetHashKey(tablePtr, hPtr), (char *) NULL,
		    flags | globalFlag);
	    while (varPtr->tracePtr != NULL) {
		VarTrace *tracePtr = varPtr->tracePtr;
		varPtr->tracePtr = tracePtr->nextPtr;
		ckfree(memoryp, (char *) tracePtr);
	    }
	}
	if (varPtr->flags & VAR_ARRAY) {
	    DeleteArray(iPtr, Hax_GetHashKey(tablePtr, hPtr), varPtr,
		    flags | globalFlag);
	}
	if (globalFlag) {
	    Hax_DeleteHashEntry((Hax_Interp *) iPtr, hPtr);
	}
	ckfree(memoryp, (char *) varPtr);
    }
    Hax_DeleteHashTable((Hax_Interp *) iPtr, tablePtr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x40, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
addq $0x68, %rcx
cmpq %rcx, %rax
jne 0x1c545
movl -0x44(%rbp), %eax
orl $0x101, %eax            # imm = 0x101
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x43c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x1c729
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1c5f1
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x3311(%rip), %rdx      # 0x1f8af
movl $0x758, %ecx            # imm = 0x758
callq 0x4260
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x1c5e5
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1c5e5
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c5ea
jmp 0x1c717
movl $0x1, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c699
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x3c(%rax)
jne 0x1c628
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x1c634
movq -0x38(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rcx
movl -0x44(%rbp), %r9d
orl -0x48(%rbp), %r9d
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
callq 0x199a0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c697
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq 0x3224(%rip), %rdx      # 0x1f8af
movl $0x771, %ecx            # imm = 0x771
callq 0x4260
jmp 0x1c655
jmp 0x1c699
movq -0x40(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1c6eb
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x3c(%rax)
jne 0x1c6c8
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x1c6d4
movq -0x38(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x44(%rbp), %ecx
orl -0x48(%rbp), %ecx
callq 0x1a820
cmpl $0x0, -0x48(%rbp)
je 0x1c6fe
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x42d0
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x31a2(%rip), %rdx      # 0x1f8af
movl $0x77b, %ecx            # imm = 0x77B
callq 0x4260
leaq -0x30(%rbp), %rdi
callq 0x4370
movq %rax, -0x38(%rbp)
jmp 0x1c556
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x41f0
addq $0x80, %rsp
popq %rbp
retq
nop