// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %r8, 0x10(%rsp)
movl %ecx, %ebx
movq %rdx, %rbp
movq %rsi, %rdx
movq %rdi, %r13
testb $0x1, %bl
jne 0x12fea
movq 0xc8(%r13), %rsi
testq %rsi, %rsi
je 0x12fea
leaq 0x48(%rsi), %rax
jmp 0x12ff5
leaq 0x68(%r13), %rsi
leaq 0xb0(%r13), %rax
movq 0x280(%r13), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x4(%rsp), %r14
movq %r13, %rdi
movq %r14, %rcx
callq *(%rax)
movq %rax, %r15
movl (%r14), %eax
testl %eax, %eax
je 0x1301d
xorl %r14d, %r14d
jmp 0x13030
movq 0x18(%r15), %r14
testb $0x2, 0x20(%r14)
je 0x13030
movq 0x28(%r14), %r15
movq 0x18(%r15), %r14
testq %rbp, %rbp
je 0x1310c
testl %eax, %eax
je 0x130a5
movq 0x280(%r13), %rdi
leaq 0x4474(%rip), %rdx      # 0x174bf
movl $0x30, %esi
movl $0x825, %ecx            # imm = 0x825
callq 0x44c0
movq %rax, %r14
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, (%r14)
xorl %eax, %eax
movl %eax, 0x8(%r14)
movb $0x0, 0x28(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movl %eax, 0x20(%r14)
movq %r14, 0x18(%r15)
movl $0x1, 0x20(%r14)
movl $0x50, %esi
movq 0x8(%rsp), %rdi
leaq 0x4421(%rip), %rdx      # 0x174bf
movl $0x374, %ecx            # imm = 0x374
jmp 0x130e4
movl 0x20(%r14), %eax
testb $0x4, %al
jne 0x130c6
testb $0x1, %al
jne 0x130f7
leaq 0x45f4(%rip), %rax      # 0x176ac
movq %rax, (%r13)
movl $0x1, %eax
jmp 0x131b9
movl $0x1, 0x20(%r14)
leaq 0x43ea(%rip), %rdx      # 0x174bf
movl $0x50, %esi
movq 0x8(%rsp), %rdi
movl $0x37a, %ecx            # imm = 0x37A
callq 0x44c0
movq %rax, 0x28(%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x4590
movq 0x28(%r14), %rsi
leaq 0x4(%rsp), %rcx
movq %r13, %rdi
movq %rbp, %rdx
callq *0x48(%rsi)
movq %rax, %r15
cmpl $0x0, 0x4(%rsp)
je 0x1317a
testq %rbp, %rbp
je 0x1312a
cmpq $0x0, 0x18(%r14)
je 0x1312a
movq %r13, %rdi
movq %r14, %rsi
callq 0x12a8e
movq 0x280(%r13), %rdi
leaq 0x4387(%rip), %rdx      # 0x174bf
movl $0x30, %esi
movl $0x825, %ecx            # imm = 0x825
callq 0x44c0
movq %rax, %r14
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, (%r14)
movl $0x0, 0x8(%r14)
movb $0x0, 0x28(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movl $0x4, 0x20(%r14)
movq %r14, 0x18(%r15)
jmp 0x1317e
movq 0x18(%r15), %r14
leaq 0x433a(%rip), %rdx      # 0x174bf
movl $0x20, %esi
movq 0x8(%rsp), %rdi
movl $0x394, %ecx            # imm = 0x394
callq 0x44c0
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
movq %r12, 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