// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
testb $0x1, %bpl
jne 0x12256
movq 0xc8(%r15), %rdi
testq %rdi, %rdi
je 0x12256
leaq 0x40(%rdi), %rax
jmp 0x12261
leaq 0x68(%r15), %rdi
leaq 0xa8(%r15), %rax
movq %r14, %rsi
callq *(%rax)
testq %rax, %rax
je 0x122af
movq %rax, %r13
movq 0x18(%rax), %r12
testb $0x2, 0x20(%r12)
je 0x12283
movq 0x28(%r12), %r13
movq 0x18(%r13), %r12
testq %rbx, %rbx
je 0x122da
movl 0x20(%r12), %eax
testb $0x4, %al
jne 0x122af
testb $0x1, %al
jne 0x122e7
btl $0x9, %ebp
jae 0x123ae
leaq 0x5214(%rip), %rcx      # 0x174ba
leaq 0x53ff(%rip), %r8       # 0x176ac
jmp 0x122c7
btl $0x9, %ebp
jae 0x123ae
leaq 0x51fa(%rip), %rcx      # 0x174ba
leaq 0x53d4(%rip), %r8       # 0x1769b
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x123d5
jmp 0x123ae
movq %rbx, 0x8(%rsp)
movq %r12, %rbx
xorl %r12d, %r12d
jmp 0x12307
movq 0x28(%r12), %rdi
movq %rbx, %rsi
callq *0x40(%rdi)
testq %rax, %rax
je 0x123a8
movq %rax, %r13
movq %rbx, 0x8(%rsp)
movq 0x18(%rax), %rbx
cmpq $0x0, 0x10(%rbx)
je 0x1235b
movl %ebp, %r9d
andl $0x1, %r9d
orl $0x10, %r9d
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %r14, 0x10(%rsp)
movq 0x8(%rsp), %r14
movq %r14, %r8
callq 0x12455
movq %rax, %r12
testq %rax, %rax
je 0x1236a
leaq 0x5174(%rip), %rcx      # 0x174ba
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %r12, %r8
callq 0x123d5
jmp 0x1236e
testq %r12, %r12
je 0x12378
cmpq $0x0, 0x10(%r12)
jne 0x1230e
jmp 0x12378
movq 0x18(%r13), %rbx
testq %r12, %r12
movq 0x10(%rsp), %r14
jne 0x123ae
testb $0x7, 0x20(%rbx)
je 0x123a2
btl $0x9, %ebp
jae 0x123ae
leaq 0x512f(%rip), %rcx      # 0x174ba
leaq 0x5309(%rip), %r8       # 0x1769b
movq %r15, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
jmp 0x122d0
addq $0x28, %rbx
jmp 0x123b0
btl $0x9, %ebp
jb 0x123c2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50f1(%rip), %rcx      # 0x174ba
leaq 0x52f1(%rip), %r8       # 0x176c1
jmp 0x122c7