// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x30(%rbp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0xc1c1
testl %eax, %eax
je 0xc538
cmpl $0x64, %eax
jne 0xc54f
leaq 0x1e741(%rip), %rsi     # 0x2ac74
jmp 0xc675
movq 0x18(%r15), %rax
cmpq $0x0, 0x8(%rax)
je 0xc66e
movq $0x0, 0x8(%rax)
movq (%r15), %r13
testq %r13, %r13
jne 0xc564
movq 0x8(%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movq (%r15), %r13
movl 0x14(%r15), %r12d
movl $0x58, %eax
cmpb $0x3a, (%r13)
jne 0xc58e
cmpb $0x3a, 0x1(%r13)
jne 0xc58e
decl %r12d
cmpb $0x3a, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0xc57b
movl $0x60, %eax
movq (%rbx,%rax), %rdx
movq (%r14), %rsi
testq %rsi, %rsi
movq %rdx, -0x40(%rbp)
jne 0xc5af
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq -0x40(%rbp), %rdx
movq (%r14), %rsi
cmpb $0x3a, (%rsi)
jne 0xc5df
cmpb $0x3a, 0x1(%rsi)
jne 0xc5df
movl 0x14(%r14), %edx
decl %edx
cmpb $0x3a, 0x1(%rsi)
leaq 0x1(%rsi), %rsi
je 0xc5be
movq %rbx, %rdi
callq 0x7508
movq %rax, %r14
movq 0x60(%rbx), %rcx
movq -0x40(%rbp), %rdx
jmp 0xc5e3
movq -0x30(%rbp), %rcx
incl 0x10(%r14)
movl 0x8(%rdx), %eax
cmpl 0x8(%rcx), %eax
jge 0xc621
leaq 0x1e6fb(%rip), %rsi     # 0x2acf1
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6923
movl 0x10(%r14), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r14)
movq %r14, %rsi
movl $0x1, %r14d
cmpl $0x1, %eax
jg 0xc688
movq %rbx, %rdi
jmp 0xc667
movq %r14, -0x38(%rbp)
movq %rcx, -0x30(%rbp)
cmpq %rcx, %rdx
je 0xc69a
movq %rbx, %rdi
movq %r15, %rsi
movq -0x38(%rbp), %r12
movq %r12, %rdx
callq 0x876e
movq 0x18(%r15), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl 0x10(%r12), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r12)
xorl %r14d, %r14d
cmpl $0x1, %eax
jg 0xc688
movq %rbx, %rdi
movq %r12, %rsi
callq 0x758c
jmp 0xc688
leaq 0x1e65e(%rip), %rsi     # 0x2acd3
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6923
movl $0x1, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r12d, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %r14
cmpq $0x0, (%r14)
jne 0xc6b5
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
cmpl %r12d, 0x14(%r14)
jne 0xc6e0
movq (%r14), %rdi
testq %rdi, %rdi
jne 0xc6d0
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%r14), %rdi
movq %r13, %rsi
movq -0x48(%rbp), %rdx
callq 0x6390
testl %eax, %eax
je 0xc70a
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc1c1
testl %eax, %eax
movq -0x40(%rbp), %rcx
jne 0xc62e
movq 0x18(%r14), %rax
cmpq %rcx, 0x8(%rax)
jne 0xc62e
movq (%rax), %r14
jmp 0xc6a5
leaq 0x1e641(%rip), %rsi     # 0x2ad52
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7508
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0xc73d
movq %rbx, %rdi
callq 0x758c
movq %r14, (%rbx)
movq -0x38(%rbp), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
jmp 0xc611