// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxVar.c
// Function: Hax_TraceVar2
int
Hax_TraceVar2(
    Hax_Interp *interp,		/* Interpreter in which variable is
				 * to be traced. */
    char *part1,		/* Name of scalar variable or array. */
    char *part2,		/* Name of element within array;  NULL means
				 * trace applies to scalar variable or array
				 * as-a-whole. */
    int flags,			/* OR-ed collection of bits, including any
				 * of HAX_TRACE_READS, HAX_TRACE_WRITES,
				 * HAX_TRACE_UNSETS, and HAX_GLOBAL_ONLY. */
    Hax_VarTraceProc *proc,	/* Procedure to call when specified ops are
				 * invoked upon varName. */
    ClientData clientData	/* Arbitrary argument to pass to proc. */)
{
    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;
    VarTrace *tracePtr;
    int newPtr;

    /*
     * Locate the variable, making a new (undefined) one if necessary.
     */

    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 the trace is to be on an array element, make sure that the
     * variable is an array variable.  If the variable doesn't exist
     * then define it as an empty array.  Then find the specific
     * array element.
     */

    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)) {
		iPtr->result = (char *) needArray;
		return HAX_ERROR;
	    }
	}
	hPtr = Hax_CreateHashEntry(interp, varPtr->value.tablePtr, part2,
			&newPtr);
    }

    if (newPtr) {
	if ((part2 != NULL) && (varPtr->searchPtr != NULL)) {
	    DeleteSearches(interp, varPtr);
	}
	varPtr = NewVar(interp, 0);
	varPtr->flags = VAR_UNDEFINED;
	Hax_SetHashValue(hPtr, varPtr);
    } else {
	varPtr = (Var *) Hax_GetHashValue(hPtr);
    }

    /*
     * Set up trace information.
     */

    tracePtr = (VarTrace *) ckalloc(memoryp, sizeof(VarTrace));
    tracePtr->traceProc = proc;
    tracePtr->clientData = clientData;
    tracePtr->flags = flags &
	    (HAX_TRACE_READS|HAX_TRACE_WRITES|HAX_TRACE_UNSETS);
    tracePtr->nextPtr = varPtr->tracePtr;
    varPtr->tracePtr = tracePtr;
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r13
movq %r8, %rbp
movl %ecx, %ebx
movq %rdx, 0x8(%rsp)
movq %rsi, %rdx
movq %rdi, %r12
testb $0x1, %bl
jne 0x1186b
movq 0xc8(%r12), %rsi
testq %rsi, %rsi
je 0x1186b
leaq 0x48(%rsi), %rax
jmp 0x11878
leaq 0x68(%r12), %rsi
leaq 0xb0(%r12), %rax
movq 0x280(%r12), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x4(%rsp), %r14
movq %r12, %rdi
movq %r14, %rcx
callq *(%rax)
movq %rax, %r15
cmpl $0x0, (%r14)
je 0x118bf
cmpq $0x0, 0x8(%rsp)
je 0x1195f
movq %r12, %rdi
xorl %esi, %esi
callq 0x11371
movq %rax, %r14
movq %rax, 0x18(%r15)
movl $0x374, %ecx            # imm = 0x374
jmp 0x11902
movq 0x18(%r15), %r14
testb $0x2, 0x20(%r14)
je 0x118d2
movq 0x28(%r14), %r15
movq 0x18(%r15), %r14
cmpq $0x0, 0x8(%rsp)
je 0x11979
movl 0x20(%r14), %eax
movl $0x37a, %ecx            # imm = 0x37A
testb $0x4, %al
jne 0x11902
testb $0x1, %al
jne 0x1192c
leaq 0x3a8a(%rip), %rax      # 0x15380
movq %rax, (%r12)
pushq $0x1
popq %rax
jmp 0x119b1
movl $0x1, 0x20(%r14)
leaq 0x3882(%rip), %rdx      # 0x15193
pushq $0x50
popq %rsi
movq 0x10(%rsp), %rdi
callq 0x44e0
movq %rax, 0x28(%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x45b0
movq 0x28(%r14), %rsi
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
movq 0x8(%rsp), %rdx
callq *0x48(%rsi)
movq %rax, %r15
leaq 0x4(%rsp), %rax
cmpl $0x0, (%rax)
je 0x11979
cmpq $0x0, 0x18(%r14)
je 0x1195f
movq %r12, %rdi
movq %r14, %rsi
callq 0x113bb
movq %r12, %rdi
xorl %esi, %esi
callq 0x11371
movq %rax, %r14
movl $0x4, 0x20(%rax)
movq %rax, 0x18(%r15)
jmp 0x1197d
movq 0x18(%r15), %r14
leaq 0x380f(%rip), %rdx      # 0x15193
pushq $0x20
popq %rsi
movq 0x10(%rsp), %rdi
movl $0x394, %ecx            # imm = 0x394
callq 0x44e0
movq %rbp, (%rax)
movq %r13, 0x8(%rax)
andl $0x70, %ebx
movl %ebx, 0x10(%rax)
movq 0x10(%r14), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x10(%r14)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq