// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxVar.c
// Function: CallTraces
static char *
CallTraces(
    Interp *iPtr,			/* Interpreter containing variable. */
    Var *arrayPtr,			/* Pointer to array variable that
					 * contains the variable, or NULL if
					 * the variable isn't an element of an
					 * array. */
    Hax_HashEntry *hPtr,		/* Hash table entry corresponding to
					 * variable whose traces are to be
					 * invoked. */
    char *part1, char *part2,		/* Variable's two-part name. */
    int flags				/* Flags to pass to trace procedures:
					 * indicates what's happening to
					 * variable, plus other stuff like
					 * HAX_GLOBAL_ONLY and
					 * HAX_INTERP_DESTROYED. */)
{
    Var *varPtr;
    VarTrace *tracePtr;
    ActiveVarTrace active;
    char *result;
    int savedArrayFlags = 0;		/* (Initialization not needed except
					 * to prevent compiler warning) */

    /*
     * If there are already similar trace procedures active for the
     * variable, don't call them again.
     */

    varPtr = (Var *) Hax_GetHashValue(hPtr);
    if (varPtr->flags & VAR_TRACE_ACTIVE) {
	return NULL;
    }
    varPtr->flags |= VAR_TRACE_ACTIVE;

    /*
     * Invoke traces on the array containing the variable, if relevant.
     */

    result = NULL;
    active.nextPtr = iPtr->activeTracePtr;
    iPtr->activeTracePtr = &active;
    if (arrayPtr != NULL) {
	savedArrayFlags = arrayPtr->flags;
	arrayPtr->flags |= VAR_ELEMENT_ACTIVE;
	for (tracePtr = arrayPtr->tracePtr;  tracePtr != NULL;
		tracePtr = active.nextTracePtr) {
	    active.nextTracePtr = tracePtr->nextPtr;
	    if (!(tracePtr->flags & flags)) {
		continue;
	    }
	    result = (*tracePtr->traceProc)(tracePtr->clientData,
		    (Hax_Interp *) iPtr, part1, part2, flags);
	    if (result != NULL) {
		if (flags & HAX_TRACE_UNSETS) {
		    result = NULL;
		} else {
		    goto done;
		}
	    }
	}
    }

    /*
     * Invoke traces on the variable itself.
     */

    if (flags & HAX_TRACE_UNSETS) {
	flags |= HAX_TRACE_DESTROYED;
    }
    for (tracePtr = varPtr->tracePtr; tracePtr != NULL;
	    tracePtr = active.nextTracePtr) {
	active.nextTracePtr = tracePtr->nextPtr;
	if (!(tracePtr->flags & flags)) {
	    continue;
	}
	result = (*tracePtr->traceProc)(tracePtr->clientData,
		(Hax_Interp *) iPtr, part1, part2, flags);
	if (result != NULL) {
	    if (flags & HAX_TRACE_UNSETS) {
		result = NULL;
	    } else {
		goto done;
	    }
	}
    }

    /*
     * Restore the variable's flags, remove the record of our active
     * traces, and then return.  Remember that the variable could have
     * been re-allocated during the traces, but its hash entry won't
     * change.
     */

    done:
    if (arrayPtr != NULL) {
	arrayPtr->flags = savedArrayFlags;
    }
    varPtr = (Var *) Hax_GetHashValue(hPtr);
    varPtr->flags &= ~VAR_TRACE_ACTIVE;
    iPtr->activeTracePtr = active.nextPtr;
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r13
movq 0x18(%rdx), %rcx
movl 0x20(%rcx), %eax
testb $0x20, %al
jne 0x10f2b
movl %r9d, %r15d
movq %r8, %r12
movq %rdi, %rbp
movq %rdx, 0x30(%rsp)
orl $0x20, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x20(%rcx)
movq 0xd0(%rdi), %rax
leaq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %rcx, 0xd0(%rdi)
testq %rsi, %rsi
movq %rsi, 0x28(%rsp)
je 0x10f3a
movl 0x20(%rsi), %eax
movl %eax, 0x4(%rsp)
orl $0x10, %eax
movl %eax, 0x20(%rsi)
movq 0x10(%rsi), %rcx
movl %r15d, %ebx
andl $0x40, %ebx
testq %rcx, %rcx
je 0x10f33
movq %rcx, %rax
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
testl %r15d, 0x10(%rax)
je 0x10eeb
movq 0x8(%rax), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movl %r15d, %r8d
callq *(%rax)
testl %ebx, %ebx
jne 0x10f24
movq %rax, %r14
testq %rax, %rax
jne 0x10fa6
movq 0x18(%rsp), %rcx
jmp 0x10eeb
xorl %r14d, %r14d
jmp 0x10fd0
movq %rbp, 0x8(%rsp)
jmp 0x10f4d
movq %rbp, 0x8(%rsp)
movl %r15d, %ebx
andl $0x40, %ebx
movl $0x0, 0x4(%rsp)
movl %r15d, %ebp
andl $0x40, %ebp
addl %ebp, %ebp
orl %r15d, %ebp
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
xorl %r14d, %r14d
testq %rcx, %rcx
je 0x10fa1
movq %rcx, %rax
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
testl %ebp, 0x10(%rax)
je 0x10f64
movq 0x8(%rax), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movl %ebp, %r8d
callq *(%rax)
testl %ebx, %ebx
jne 0x10f97
testq %rax, %rax
jne 0x10f9e
movq 0x18(%rsp), %rcx
jmp 0x10f64
movq %rax, %r14
movq 0x8(%rsp), %rbp
movq 0x28(%rsp), %rcx
testq %rcx, %rcx
movq 0x30(%rsp), %rax
je 0x10fbc
movl 0x4(%rsp), %edx
movl %edx, 0x20(%rcx)
movq 0x18(%rax), %rax
andl $-0x21, 0x20(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0xd0(%rbp)
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq