// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %r9, %r12
movq %r8, 0x20(%rsp)
movl %ecx, %ebx
movq %rdx, %rbp
movq %rsi, %rdx
movq %rdi, %r13
testb $0x1, %bl
jne 0x127ed
movq 0xc8(%r13), %rsi
testq %rsi, %rsi
je 0x127ed
leaq 0x48(%rsi), %rax
jmp 0x127f8
leaq 0x68(%r13), %rsi
leaq 0xb0(%r13), %rax
movq 0x280(%r13), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x1c(%rsp), %r14
movq %r13, %rdi
movq %r14, %rcx
callq *(%rax)
movq %rax, %r15
cmpl $0x0, (%r14)
je 0x1288d
testq %rbp, %rbp
je 0x1293a
movq %r12, 0x8(%rsp)
movq 0x280(%r13), %rdi
leaq 0x398d(%rip), %r12      # 0x161c3
movl $0x30, %esi
movq %r12, %rdx
movl $0x825, %ecx            # imm = 0x825
callq 0x44d0
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)
movq %r14, 0x18(%r15)
movl $0x1, 0x20(%r14)
movl $0x50, %esi
movq 0x10(%rsp), %rdi
movq %r12, %rdx
movl $0x374, %ecx            # imm = 0x374
jmp 0x128ed
movq 0x18(%r15), %r14
testb $0x2, 0x20(%r14)
je 0x128a0
movq 0x28(%r14), %r15
movq 0x18(%r15), %r14
testq %rbp, %rbp
je 0x1298f
movl 0x20(%r14), %eax
testb $0x4, %al
movq %r12, 0x8(%rsp)
jne 0x128cf
testb $0x1, %al
jne 0x12900
leaq 0x3aef(%rip), %rax      # 0x163b0
movq %rax, (%r13)
movl $0x1, %eax
jmp 0x129ce
movl $0x1, 0x20(%r14)
leaq 0x38e5(%rip), %rdx      # 0x161c3
movl $0x50, %esi
movq 0x10(%rsp), %rdi
movl $0x37a, %ecx            # imm = 0x37A
callq 0x44d0
movq %rax, 0x28(%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x45a0
movq 0x28(%r14), %rsi
leaq 0x1c(%rsp), %r12
movq %r13, %rdi
movq %rbp, %rdx
movq %r12, %rcx
callq *0x48(%rsi)
movq %rax, %r15
cmpl $0x0, (%r12)
je 0x1298a
cmpq $0x0, 0x18(%r14)
movq 0x8(%rsp), %r12
je 0x1293a
movq 0x280(%r13), %rdi
movq %r14, %rsi
callq 0x12301
movq 0x280(%r13), %rdi
leaq 0x387b(%rip), %rdx      # 0x161c3
movl $0x30, %esi
movl $0x825, %ecx            # imm = 0x825
callq 0x44d0
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 0x12993
movq 0x8(%rsp), %r12
movq 0x18(%r15), %r14
leaq 0x3829(%rip), %rdx      # 0x161c3
movl $0x20, %esi
movq 0x10(%rsp), %rdi
movl $0x394, %ecx            # imm = 0x394
callq 0x44d0
movq 0x20(%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 $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq