// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, %r15
movq %rsi, %rbx
cmpl $0x2, %edx
jle 0x140c4
movl %edx, %ebp
movq 0x8(%r15), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x4200
movl %eax, %ecx
movl $0x1, %eax
cmpl $-0x1, %ecx
je 0x140e7
movslq %ecx, %rax
movl %ecx, %edx
notl %edx
addl %ebp, %edx
movq 0x20(%rsp), %rsi
leaq 0x68(%rbx), %rdi
testq %rsi, %rsi
cmovneq %rsi, %rdi
movq %rdi, 0x18(%rsp)
testb $0x1, %dl
jne 0x140bc
testl %edx, %edx
jle 0x140f6
incq %rax
subl %ecx, %ebp
incl %ebp
leaq (%r15,%rax,8), %r14
addq $0x8, %r14
leaq 0xc(%rsp), %r15
movq -0x8(%r14), %rdx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rcx
callq *0x48(%rsi)
movq %rax, %r13
cmpl $0x0, 0xc(%rsp)
je 0x14010
movq 0x280(%rbx), %rdi
movl $0x30, %esi
leaq 0x34f6(%rip), %rdx      # 0x174bf
movl $0x825, %ecx            # imm = 0x825
callq 0x44c0
movq %rax, %r12
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, (%r12)
xorl %eax, %eax
movl %eax, 0x8(%r12)
movb $0x0, 0x28(%r12)
movl %eax, 0x20(%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r12)
movb $0x4, 0x20(%r12)
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%r13)
jmp 0x14031
movq 0x18(%r13), %r12
testb $0x2, 0x20(%r12)
jne 0x14023
movq %r13, 0x10(%rsp)
jmp 0x14031
movq 0x28(%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rax), %r12
movq 0xc8(%rbx), %rsi
movq (%r14), %rdx
movq %rbx, %rdi
movq %r15, %r13
movq %r15, %rcx
callq *0x48(%rsi)
cmpl $0x0, 0xc(%rsp)
je 0x140fa
movq %rax, %r15
movq 0x280(%rbx), %rdi
movl $0x30, %esi
leaq 0x3457(%rip), %rdx      # 0x174bf
movl $0x825, %ecx            # imm = 0x825
callq 0x44c0
movq %rax, %rcx
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, (%rcx)
xorl %eax, %eax
movl %eax, 0x8(%rcx)
movl %eax, 0x20(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx)
movb $0x2, 0x20(%rcx)
movq 0x10(%rsp), %rdx
movq %rdx, 0x28(%rcx)
incl 0x8(%r12)
movq %rcx, 0x18(%r15)
addl $-0x2, %ebp
addq $0x10, %r14
cmpl $0x2, %ebp
movq %r13, %r15
jg 0x13f9a
jmp 0x140e7
leaq (%r15,%rax,8), %r15
addq $0x8, %r15
movq (%r15), %rdx
leaq 0x17a6(%rip), %rsi      # 0x15874
leaq 0x3592(%rip), %rcx      # 0x17667
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x140e7
movq (%r14), %rdx
leaq 0x1dbf(%rip), %rsi      # 0x15ec3
leaq 0x354b(%rip), %rcx      # 0x17656
jmp 0x140d5