// File: /workspace/github_c_makefile_star2_O0/msteveb[P]autosetup/./jimsh0.c
// Function: Jim_SetVariableLink
int Jim_SetVariableLink(Jim_Interp *interp, Jim_Obj *nameObjPtr,
    Jim_Obj *targetNameObjPtr, Jim_CallFrame *targetCallFrame)
{
    const char *varName;
    const char *targetName;
    Jim_CallFrame *framePtr;
    Jim_VarVal *vv;
    int len;
    int varnamelen;


    switch (SetVariableFromAny(interp, nameObjPtr)) {
        case JIM_DICT_SUGAR:

            Jim_SetResultFormatted(interp, "bad variable name \"%#s\": upvar won't create a scalar variable that looks like an array element", nameObjPtr);
            return JIM_ERR;

        case JIM_OK:
            vv = nameObjPtr->internalRep.varValue.vv;

            if (vv->linkFramePtr == NULL) {
                Jim_SetResultFormatted(interp, "variable \"%#s\" already exists", nameObjPtr);
                return JIM_ERR;
            }


            vv->linkFramePtr = NULL;
            break;
    }



    varName = Jim_GetString(nameObjPtr, &varnamelen);

    if (varName[0] == ':' && varName[1] == ':') {
        while (*varName == ':') {
            varName++;
            varnamelen--;
        }

        framePtr = interp->topFramePtr;
    }
    else {
        framePtr = interp->framePtr;
    }

    targetName = Jim_GetString(targetNameObjPtr, &len);
    if (targetName[0] == ':' && targetName[1] == ':') {
        while (*targetName == ':') {
            targetName++;
            len--;
        }
        targetNameObjPtr = Jim_NewStringObj(interp, targetName, len);
        targetCallFrame = interp->topFramePtr;
    }
    Jim_IncrRefCount(targetNameObjPtr);

    if (framePtr->level < targetCallFrame->level) {
        Jim_SetResultFormatted(interp,
            "bad variable name \"%#s\": upvar won't create namespace variable that refers to procedure variable",
            nameObjPtr);
        Jim_DecrRefCount(interp, targetNameObjPtr);
        return JIM_ERR;
    }


    if (framePtr == targetCallFrame) {
        Jim_Obj *objPtr = targetNameObjPtr;


        while (1) {
            if (Jim_Length(objPtr) == varnamelen && memcmp(Jim_String(objPtr), varName, varnamelen) == 0) {
                Jim_SetResultString(interp, "can't upvar from variable to itself", -1);
                Jim_DecrRefCount(interp, targetNameObjPtr);
                return JIM_ERR;
            }
            if (SetVariableFromAny(interp, objPtr) != JIM_OK)
                break;
            vv = objPtr->internalRep.varValue.vv;
            if (vv->linkFramePtr != targetCallFrame)
                break;
            objPtr = vv->objPtr;
        }
    }


    Jim_SetVariable(interp, nameObjPtr, targetNameObjPtr);

    nameObjPtr->internalRep.varValue.vv->linkFramePtr = targetCallFrame;
    Jim_DecrRefCount(interp, targetNameObjPtr);
    return JIM_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd9d0
movl %eax, %ecx
movl %ecx, -0x64(%rbp)
testl %eax, %eax
je 0xe07c
jmp 0xe050
movl -0x64(%rbp), %eax
subl $0x64, %eax
jne 0xe0c1
jmp 0xe05a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2cdae(%rip), %rsi     # 0x3ae17
movb $0x0, %al
callq 0x6b40
movl $0x1, -0x4(%rbp)
jmp 0xe34d
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xe0b5
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2cdd4(%rip), %rsi     # 0x3ae76
movb $0x0, %al
callq 0x6b40
movl $0x1, -0x4(%rbp)
jmp 0xe34d
movq -0x48(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x89b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0xe11e
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0xe11e
jmp 0xe0ed
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0xe110
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xe0ed
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xe12a
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x89b0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0xe199
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0xe199
jmp 0xe156
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0xe179
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xe156
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x7990
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xe1f7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2cccf(%rip), %rsi     # 0x3ae94
movb $0x0, %al
callq 0x6b40
movq -0x20(%rbp), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0xe1eb
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7a10
movl $0x1, -0x4(%rbp)
jmp 0xe34d
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0xe306
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0xc700
cmpl -0x50(%rbp), %eax
jne 0xe2c4
movq -0x58(%rbp), %rdi
callq 0x7960
movq %rax, %rdi
movq -0x30(%rbp), %rsi
movslq -0x50(%rbp), %rdx
callq 0x62c0
cmpl $0x0, %eax
jne 0xe2c4
jmp 0xe243
movq -0x10(%rbp), %rdi
leaq 0x2cca7(%rip), %rsi     # 0x3aef5
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0xe28e
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0xe2b8
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7a10
movl $0x1, -0x4(%rbp)
jmp 0xe34d
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xd9d0
cmpl $0x0, %eax
je 0xe2d8
jmp 0xe304
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x28(%rbp), %rax
je 0xe2f4
jmp 0xe304
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xe20d
jmp 0xe306
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x8df0
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0xe346
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7a10
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)