// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x1c320
jmp 0x1c2ef
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x1673(%rip), %rsi      # 0x1d974
leaq 0x374f(%rip), %rcx      # 0x1fa57
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0x4(%rbp)
jmp 0x1c4f6
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x40(%rbp), %rdx
callq 0x41e0
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
jne 0x1c34a
movl $0x1, -0x4(%rbp)
jmp 0x1c4f6
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1c385
movq -0x30(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x50(%rbp)
jmp 0x1c38d
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1c39d
jmp 0x1c2ef
jmp 0x1c39f
cmpl $0x0, -0x1c(%rbp)
jle 0x1c4ef
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
leaq -0x64(%rbp), %rcx
callq *%rax
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x1c3fa
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x1a1e0
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl 0x20(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x20(%rax)
movq -0x70(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1c42f
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1c42d
movq -0x70(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x1c42f
movq -0x30(%rbp), %rax
movq 0xc8(%rax), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq 0xc8(%rcx), %rsi
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rdx
leaq -0x64(%rbp), %rcx
callq *%rax
movq %rax, -0x60(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0x1c494
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1961(%rip), %rsi      # 0x1ddd9
leaq 0x35c7(%rip), %rcx      # 0x1fa46
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0x4(%rbp)
jmp 0x1c4f6
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x1a1e0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x20(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x20(%rax)
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x70(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
jmp 0x1c39f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop