// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxVar.c
// Function: Hax_UpvarCmd
int
Hax_UpvarCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Interp *iPtr = (Interp *) interp;
    int result;
    CallFrame *framePtr;
    Var *varPtr = NULL;
    Hax_HashTable *upVarTablePtr;
    Hax_HashEntry *hPtr, *hPtr2;
    int newPtr;
    Var *upVarPtr;

    if (argc < 3) {
	upvarSyntax:
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" ?level? otherVar localVar ?otherVar localVar ...?\"",
		(char *) NULL);
	return HAX_ERROR;
    }

    /*
     * Find the hash table containing the variable being referenced.
     */

    result = HaxGetFrame(interp, argv[1], &framePtr);
    if (result == -1) {
	return HAX_ERROR;
    }
    argc -= result+1;
    argv += result+1;
    if (framePtr == NULL) {
	upVarTablePtr = &iPtr->globalTable;
    } else {
	upVarTablePtr = &framePtr->varTable;
    }

    if ((argc & 1) != 0) {
	goto upvarSyntax;
    }

    /*
     * Iterate over all the pairs of (local variable, other variable)
     * names.  For each pair, create a hash table entry in the upper
     * context (if the name wasn't there already), then associate it
     * with a new local variable.
     */

    while (argc > 0) {
        hPtr = Hax_CreateHashEntry(interp, upVarTablePtr, argv[0], &newPtr);
        if (newPtr) {
            upVarPtr = NewVar(interp, 0);
            upVarPtr->flags |= VAR_UNDEFINED;
            Hax_SetHashValue(hPtr, upVarPtr);
        } else {
            upVarPtr = (Var *) Hax_GetHashValue(hPtr);
	    if (upVarPtr->flags & VAR_UPVAR) {
		hPtr = upVarPtr->value.upvarPtr;
		upVarPtr = (Var *) Hax_GetHashValue(hPtr);
	    }
        }

        hPtr2 = Hax_CreateHashEntry(interp, &iPtr->varFramePtr->varTable,
                    argv[1], &newPtr);
        if (!newPtr) {
            Hax_AppendResult((Hax_Interp *) iPtr, "variable \"", argv[1],
                "\" already exists", (char *) NULL);
            return HAX_ERROR;
        }
        varPtr = NewVar(interp, 0);
        varPtr->flags |= VAR_UPVAR;
        varPtr->value.upvarPtr = hPtr;
        upVarPtr->upvarUses++;
        Hax_SetHashValue(hPtr2, varPtr);

        argc -= 2;
        argv += 2;
    }
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rsi, %r14
pushq $0x1
popq %r15
cmpl $0x2, %edx
jle 0x12676
movl %edx, %ebx
movq 0x8(%r12), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x4200
cmpl $-0x1, %eax
je 0x12695
movslq %eax, %rsi
notl %eax
addl %ebx, %eax
movq 0x10(%rsp), %rcx
leaq 0x68(%r14), %rdx
testq %rcx, %rcx
cmovneq %rcx, %rdx
movq %rdx, 0x8(%rsp)
testb $0x1, %al
jne 0x1266e
incq %rsi
leaq (%r12,%rsi,8), %r15
addq $0x8, %r15
movq %rsp, %r12
testl %eax, %eax
jle 0x126a7
movl %eax, 0x4(%rsp)
movq -0x8(%r15), %rdx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rcx
callq *0x48(%rsi)
movq %rax, %r13
cmpl $0x0, (%rsp)
je 0x12610
movq %r14, %rdi
xorl %esi, %esi
callq 0x11371
movq %rax, %rbx
orb $0x4, 0x20(%rax)
movq %rax, 0x18(%r13)
jmp 0x12622
movq 0x18(%r13), %rbx
testb $0x2, 0x20(%rbx)
je 0x12622
movq 0x28(%rbx), %r13
movq 0x18(%r13), %rbx
movq 0xc8(%r14), %rsi
movq (%r15), %rdx
movq %r14, %rdi
movq %r12, %rbp
movq %r12, %rcx
callq *0x48(%rsi)
cmpl $0x0, (%rsp)
je 0x126ac
movq %rax, %r12
movq %r14, %rdi
xorl %esi, %esi
callq 0x11371
orb $0x2, 0x20(%rax)
movq %r13, 0x28(%rax)
incl 0x8(%rbx)
movq %rax, 0x18(%r12)
movl 0x4(%rsp), %eax
addl $-0x2, %eax
addq $0x10, %r15
movq %rbp, %r12
jmp 0x125d2
leaq (%r12,%rsi,8), %r12
addq $0x8, %r12
movq (%r12), %rdx
leaq 0x11df(%rip), %rsi      # 0x13860
leaq 0x2cb3(%rip), %rcx      # 0x1533b
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x12695
movq (%r15), %rdx
leaq 0x1669(%rip), %rsi      # 0x13d1f
leaq 0x2c6d(%rip), %rcx      # 0x1532a
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4520
pushq $0x1
popq %r15
jmp 0x12695