// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxParse.c
// Function: Hax_ParseVar
char *
Hax_ParseVar(
    Hax_Interp *interp,			/* Context for looking up variable. */
    char *string,		/* String containing variable name.
					 * First character must be "$". */
    char **termPtr			/* If non-NULL, points to word to fill
					 * in with character just after last
					 * one in the variable specifier. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    char *name1, *name1End, c, *result;
    char *name2;
#define NUM_CHARS 200
    char copyStorage[NUM_CHARS];
    ParseValue pv;
    const char *ellipsis = "";		/* Used in setting errorInfo variable;
					 * set to "..." to indicate that not
					 * all of offending command is included
					 * in errorInfo.  "" means that the
					 * command is all there. */

    /*
     * There are three cases:
     * 1. The $ sign is followed by an open curly brace.  Then the variable
     *    name is everything up to the next close curly brace, and the
     *    variable is a scalar variable.
     * 2. The $ sign is not followed by an open curly brace.  Then the
     *    variable name is everything up to the next character that isn't
     *    a letter, digit, or underscore.  If the following character is an
     *    open parenthesis, then the information between parentheses is
     *    the array element name, which can include any of the substitutions
     *    permissible between quotes.
     * 3. The $ sign is followed by something that isn't a letter, digit,
     *    or underscore:  in this case, there is no variable name, and "$"
     *    is returned.
     */

    name2 = NULL;
    string++;
    if (*string == '{') {
	string++;
	name1 = string;
	while (*string != '}') {
	    if (*string == 0) {
		Hax_SetResult(interp,
			(char *) "missing close-brace for variable name",
			HAX_STATIC);
		if (termPtr != 0) {
		    *termPtr = string;
		}
		return NULL;
	    }
	    string++;
	}
	name1End = string;
	string++;
    } else {
	name1 = string;
	while (isalnum(*string) || (*string == '_')) {
	    string++;
	}
	if (string == name1) {
	    if (termPtr != 0) {
		*termPtr = string;
	    }
	    return (char *) "$";
	}
	name1End = string;
	if (*string == '(') {
	    char *end;

	    /*
	     * Perform substitutions on the array element name, just as
	     * is done for quotes.
	     */

	    pv.buffer = pv.next = copyStorage;
	    pv.end = copyStorage + NUM_CHARS - 1;
	    pv.expandProc = HaxExpandParseValue;
	    pv.clientData = (ClientData) NULL;
	    if (HaxParseQuotes(interp, string+1, ')', 0, &end, &pv)
		    != HAX_OK) {
		char msg[100];
		int n = (int) (string - name1);
		if (n > sizeof(msg)) {
			n = sizeof(msg);
			ellipsis = " ...";
		}
		sprintf(msg, "\n    (parsing index for array \"%.*s%s\")",
			n, name1, ellipsis);
		Hax_AddErrorInfo(interp, msg);
		result = NULL;
		name2 = pv.buffer;
		if (termPtr != 0) {
		    *termPtr = end;
		}
		goto done;
	    }
	    string = end;
	    name2 = pv.buffer;
	}
    }
    if (termPtr != 0) {
	*termPtr = string;
    }

    if (((Interp *) interp)->noEval) {
	return (char *) "";
    }
    c = *name1End;
    *name1End = 0;
    result = Hax_GetVar2(interp, name1, name2, HAX_LEAVE_ERR_MSG);
    *name1End = c;

    done:
    if ((name2 != NULL) && (pv.buffer != copyStorage)) {
	ckfree(memoryp, pv.buffer);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movq 0x280(%rdi), %r12
cmpb $0x7b, 0x1(%rsi)
jne 0xfaf3
addq $0x2, %r13
movq %r13, %rbx
movzbl (%rbx), %eax
cmpl $0x7d, %eax
je 0xfc21
testl %eax, %eax
je 0xfbf9
incq %rbx
jmp 0xfada
leaq 0x1(%r13), %rax
movq %rax, (%rsp)
callq 0x4640
movq (%rax), %rax
incq %r13
movl $0x1, %ebp
movsbq (%r13), %rcx
incq %r13
decq %rbp
cmpq $0x5f, %rcx
je 0xfb0b
movzwl (%rax,%rcx,2), %edx
andl $0x8, %edx
jne 0xfb0b
leaq -0x1(%r13), %rbx
testq %rbp, %rbp
je 0xfc29
cmpb $0x28, %cl
jne 0xfc41
movq %r12, 0x8(%rsp)
leaq 0x40(%rsp), %rax
leaq 0x18(%rsp), %r9
movq %rax, 0x8(%r9)
movq %rax, (%r9)
leaq 0x107(%rsp), %rax
movq %rax, 0x10(%r9)
movq 0xc474(%rip), %rax      # 0x1bfd8
movq %rax, 0x18(%r9)
movq $0x0, 0x20(%r9)
xorl %r12d, %r12d
leaq 0x10(%rsp), %r8
movq %r15, %rdi
movq %r13, %rsi
movl $0x29, %edx
xorl %ecx, %ecx
callq 0x4470
testl %eax, %eax
je 0xfc4c
negl %ebp
cmpl $0x65, %ebp
leaq 0x5778(%rip), %rax      # 0x15316
leaq 0x738e(%rip), %r8       # 0x16f33
cmovaeq %rax, %r8
cmpl $0x64, %ebp
movl $0x64, %edx
cmovbl %ebp, %edx
leaq 0x7653(%rip), %rsi      # 0x1720e
leaq 0x110(%rsp), %r13
movq %r13, %rdi
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x45d0
movq %r15, %rdi
movq %r13, %rsi
callq 0x4400
testq %r14, %r14
je 0xfbe9
movq 0x10(%rsp), %rax
movq %rax, (%r14)
movq 0x18(%rsp), %rbp
movl $0x6, %r12d
movq %rbx, %rax
jmp 0xfc56
leaq 0x75e6(%rip), %rsi      # 0x171e6
xorl %r13d, %r13d
movq %r15, %rdi
xorl %edx, %edx
callq 0x44e0
testq %r14, %r14
je 0xfcdf
movq %rbx, (%r14)
xorl %r13d, %r13d
jmp 0xfcdf
leaq 0x1(%rbx), %rax
xorl %ebp, %ebp
jmp 0xfc6a
leaq 0x75dc(%rip), %r13      # 0x1720c
testq %r14, %r14
je 0xfcdf
movq %rbx, (%r14)
jmp 0xfcdf
xorl %ebp, %ebp
movq %rbx, %rax
movq (%rsp), %r13
jmp 0xfc6a
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rbp
cmpl $0x6, %r12d
je 0xfca6
testl %r12d, %r12d
jne 0xfcdf
movq (%rsp), %r13
movq 0x8(%rsp), %r12
testq %r14, %r14
je 0xfc72
movq %rax, (%r14)
cmpl $0x0, 0x194(%r15)
je 0xfc85
leaq 0x72b0(%rip), %r13      # 0x16f33
jmp 0xfcdf
movb (%rbx), %r14b
movb $0x0, (%rbx)
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0x200, %ecx            # imm = 0x200
callq 0x44a0
movq %rax, %r13
movb %r14b, (%rbx)
jmp 0xfcae
xorl %r13d, %r13d
movq 0x8(%rsp), %r12
testq %rbp, %rbp
setne %al
movq 0x18(%rsp), %rsi
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rsi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xfcdf
leaq 0x7499(%rip), %rdx      # 0x1716b
movq %r12, %rdi
movl $0x4c2, %ecx            # imm = 0x4C2
callq 0x4280
movq %r13, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq