// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
callq 0xc1a3
testl %eax, %eax
je 0xc51d
cmpl $0x64, %eax
jne 0xc534
leaq 0x1f7b4(%rip), %rsi     # 0x2bccc
jmp 0xc5c2
movq 0x18(%r15), %rax
cmpq $0x0, 0x8(%rax)
je 0xc5bb
movq $0x0, 0x8(%rax)
cmpq $0x0, (%r15)
jne 0xc544
movq 0x8(%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movl 0x14(%r15), %ebx
movq (%r15), %r13
movl $0x58, %eax
cmpb $0x3a, (%r13)
jne 0xc577
cmpb $0x3a, 0x1(%r13)
jne 0xc577
movl $0x60, %eax
cmpb $0x3a, (%r13)
jne 0xc577
decl %ebx
cmpb $0x3a, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0xc56a
movq %r14, -0x30(%rbp)
movq (%r14,%rax), %r14
cmpq $0x0, (%r12)
jne 0xc591
movq 0x8(%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
movq (%r12), %rax
cmpb $0x3a, (%rax)
jne 0xc5f5
cmpb $0x3a, 0x1(%rax)
jne 0xc5f5
movl 0x14(%r12), %edx
cmpb $0x3a, (%rax)
jne 0xc5da
leaq 0x1(%rax), %rsi
decl %edx
cmpb $0x3a, 0x1(%rax)
movq %rsi, %rax
je 0xc5aa
jmp 0xc5dd
leaq 0x1f769(%rip), %rsi     # 0x2bd2b
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x692d
movl $0x1, %r14d
jmp 0xc677
movq %rax, %rsi
movq -0x30(%rbp), %rdi
callq 0x7516
movq %rax, %r12
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x38(%rbp)
incl 0x10(%r12)
movl 0x8(%r14), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xc634
leaq 0x1f73b(%rip), %rsi     # 0x2bd49
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x692d
movl 0x10(%r12), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r12)
movl $0x1, %r14d
jmp 0xc667
cmpq %rcx, %r14
je 0xc689
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x871b
movq 0x18(%r15), %rax
movq -0x38(%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 0xc677
movq %rbx, %rdi
movq %r12, %rsi
callq 0x759a
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ebx, %rax
movq %rax, -0x40(%rbp)
movq %r12, %r14
cmpq $0x0, (%r14)
jne 0xc6a3
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
cmpl %ebx, 0x14(%r14)
jne 0xc6cc
cmpq $0x0, (%r14)
jne 0xc6b9
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%r14), %rdi
movq %r13, %rsi
movq -0x40(%rbp), %rdx
callq 0x6390
testl %eax, %eax
je 0xc6f7
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0xc1a3
testl %eax, %eax
jne 0xc639
movq 0x18(%r14), %rax
movq -0x38(%rbp), %rcx
cmpq %rcx, 0x8(%rax)
jne 0xc639
movq (%rax), %r14
jmp 0xc693
leaq 0x1f6ac(%rip), %rsi     # 0x2bdaa
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
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 0xc72e
movq %rbx, %rdi
callq 0x759a
movq %r14, (%rbx)
jmp 0xc61f