// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxVar.c
// Function: Hax_GetVar2
char *
Hax_GetVar2(
    Hax_Interp *interp,		/* Command interpreter in which variable is
				 * to be looked up. */
    char *part1,		/* Name of array (if part2 is NULL) or
				 * name of variable. */
    char *part2,		/* If non-null, gives name of element in
				 * array. */
    int flags			/* OR-ed combination of HAX_GLOBAL_ONLY
				 * or HAX_LEAVE_ERR_MSG bits. */)
{
    Hax_HashEntry *hPtr;
    Var *varPtr;
    Interp *iPtr = (Interp *) interp;
    Var *arrayPtr = NULL;

    /*
     * Lookup the first name.
     */

    if ((flags & HAX_GLOBAL_ONLY) || (iPtr->varFramePtr == NULL)) {
	hPtr = Hax_FindHashEntry(&iPtr->globalTable, part1);
    } else {
	hPtr = Hax_FindHashEntry(&iPtr->varFramePtr->varTable, part1);
    }
    if (hPtr == NULL) {
	if (flags & HAX_LEAVE_ERR_MSG) {
	    VarErrMsg(interp, part1, part2, (char *) "read",
		(char *) noSuchVar);
	}
	return NULL;
    }
    varPtr = (Var *) Hax_GetHashValue(hPtr);
    if (varPtr->flags & VAR_UPVAR) {
	hPtr = varPtr->value.upvarPtr;
	varPtr = (Var *) Hax_GetHashValue(hPtr);
    }

    /*
     * If this is an array reference, then remember the traces on the array
     * and lookup the element within the array.
     */

    if (part2 != NULL) {
	if (varPtr->flags & VAR_UNDEFINED) {
	    if (flags & HAX_LEAVE_ERR_MSG) {
		VarErrMsg(interp, part1, part2, (char *) "read",
		    (char *) noSuchVar);
	    }
	    return NULL;
	} else if (!(varPtr->flags & VAR_ARRAY)) {
	    if (flags & HAX_LEAVE_ERR_MSG) {
		VarErrMsg(interp, part1, part2, (char *) "read",
		    (char *) needArray);
	    }
	    return NULL;
	}
	arrayPtr = varPtr;
	hPtr = Hax_FindHashEntry(varPtr->value.tablePtr, part2);
	if (hPtr == NULL) {
	    if (flags & HAX_LEAVE_ERR_MSG) {
		VarErrMsg(interp, part1, part2, (char *) "read",
		    (char *) noSuchElement);
	    }
	    return NULL;
	}
	varPtr = (Var *) Hax_GetHashValue(hPtr);
    }

    /*
     * Invoke any traces that have been set for the variable.
     */

    if ((varPtr->tracePtr != NULL)
	    || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) {
	char *msg;

	msg = CallTraces(iPtr, arrayPtr, hPtr, part1, part2,
		(flags & HAX_GLOBAL_ONLY) | HAX_TRACE_READS);
	if (msg != NULL) {
	    VarErrMsg(interp, part1, part2, (char *) "read", msg);
	    return NULL;
	}

	/*
	 * Watch out!  The variable could have gotten re-allocated to
	 * a larger size.  Fortunately the hash table entry will still
	 * be around.
	 */

	varPtr = (Var *) Hax_GetHashValue(hPtr);
    }
    if (varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR|VAR_ARRAY)) {
	if (flags & HAX_LEAVE_ERR_MSG) {
	    VarErrMsg(interp, part1, part2, (char *) "read",
		(char *) noSuchVar);
	}
	return NULL;
    }
    return varPtr->value.string;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, (%rsp)
movq %rsi, %r14
movq %rdi, %r15
testb $0x1, %bl
jne 0x11b61
movq 0xc8(%r15), %rdi
testq %rdi, %rdi
je 0x11b61
leaq 0x40(%rdi), %rax
jmp 0x11b6c
leaq 0x68(%r15), %rdi
leaq 0xa8(%r15), %rax
movq %r14, %rsi
callq *(%rax)
testq %rax, %rax
je 0x11c43
movq %rax, %r12
movq 0x18(%rax), %r13
testb $0x2, 0x20(%r13)
je 0x11b91
movq 0x28(%r13), %r12
movq 0x18(%r12), %r13
movl %ebx, %ebp
andl $0x1, %ebp
cmpq $0x0, (%rsp)
je 0x11bca
movl 0x20(%r13), %eax
testb $0x4, %al
jne 0x11c43
testb $0x1, %al
jne 0x11bd9
btl $0x9, %ebx
jae 0x11c66
leaq 0x4600(%rip), %rcx      # 0x161be
leaq 0x47eb(%rip), %r8       # 0x163b0
jmp 0x11c57
cmpq $0x0, 0x10(%r13)
movq %r13, %rax
je 0x11c3d
xorl %r13d, %r13d
jmp 0x11c02
movq 0x28(%r13), %rdi
movq (%rsp), %rsi
callq *0x40(%rdi)
testq %rax, %rax
je 0x11c7d
movq %rax, %r12
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x11c02
cmpq $0x0, 0x10(%r13)
je 0x11c3d
orl $0x10, %ebp
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq (%rsp), %r8
movl %ebp, %r9d
callq 0x11d13
testq %rax, %rax
je 0x11c38
leaq 0x4595(%rip), %rcx      # 0x161be
movq %r15, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
movq %rax, %r8
jmp 0x11c61
movq 0x18(%r12), %rax
testb $0x7, 0x20(%rax)
je 0x11c77
btl $0x9, %ebx
jae 0x11c66
leaq 0x456e(%rip), %rcx      # 0x161be
leaq 0x4748(%rip), %r8       # 0x1639f
movq %r15, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
callq 0x11c93
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x28, %rax
jmp 0x11c68
btl $0x9, %ebx
jae 0x11c66
leaq 0x4534(%rip), %rcx      # 0x161be
leaq 0x4734(%rip), %r8       # 0x163c5
jmp 0x11c57