// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rsi, %rbx
cmpl $0x2, %edx
jle 0x137c7
movl %edx, %r14d
movq 0x8(%r12), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x4200
movl $0x1, %ecx
cmpl $-0x1, %eax
je 0x137eb
movslq %eax, %rcx
movl %eax, %edx
notl %edx
addl %r14d, %edx
movq 0x20(%rsp), %rsi
leaq 0x68(%rbx), %rdi
testq %rsi, %rsi
cmovneq %rsi, %rdi
movq %rdi, 0x18(%rsp)
testb $0x1, %dl
jne 0x137bf
testl %edx, %edx
jle 0x137bb
incq %rcx
subl %eax, %r14d
incl %r14d
leaq (%r12,%rcx,8), %r15
addq $0x8, %r15
leaq 0xc(%rsp), %r12
movq -0x8(%r15), %rdx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rcx
callq *0x48(%rsi)
movq %rax, %r13
cmpl $0x0, 0xc(%rsp)
je 0x13714
movq 0x280(%rbx), %rdi
movl $0x30, %esi
leaq 0x2aee(%rip), %rdx      # 0x161c3
movl $0x825, %ecx            # imm = 0x825
callq 0x44d0
movq %rax, %rbp
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, (%rbp)
movl $0x0, 0x8(%rbp)
movb $0x0, 0x28(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbp)
movl $0x4, 0x20(%rbp)
movq %r13, 0x10(%rsp)
movq %rbp, 0x18(%r13)
jmp 0x13732
movq 0x18(%r13), %rbp
testb $0x2, 0x20(%rbp)
jne 0x13725
movq %r13, 0x10(%rsp)
jmp 0x13732
movq 0x28(%rbp), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rax), %rbp
movq 0xc8(%rbx), %rsi
movq (%r15), %rdx
movq %rbx, %rdi
movq %r12, %r13
movq %r12, %rcx
callq *0x48(%rsi)
cmpl $0x0, 0xc(%rsp)
je 0x137fc
movq %rax, %r12
movq 0x280(%rbx), %rdi
movl $0x30, %esi
leaq 0x2a5a(%rip), %rdx      # 0x161c3
movl $0x825, %ecx            # imm = 0x825
callq 0x44d0
movabsq $0x800000000, %rcx      # imm = 0x800000000
movq %rcx, (%rax)
movl $0x0, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0x2, 0x20(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x28(%rax)
incl 0x8(%rbp)
movq %rax, 0x18(%r12)
addl $-0x2, %r14d
addq $0x10, %r15
cmpl $0x2, %r14d
movq %r13, %r12
jg 0x136a6
xorl %ecx, %ecx
jmp 0x137eb
leaq (%r12,%rcx,8), %r12
addq $0x8, %r12
movq (%r12), %rdx
leaq 0x108e(%rip), %rsi      # 0x14860
leaq 0x2b92(%rip), %rcx      # 0x1636b
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
movl $0x1, %ecx
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdx
leaq 0x1519(%rip), %rsi      # 0x14d1f
leaq 0x2b4d(%rip), %rcx      # 0x1635a
jmp 0x137d9