def ref2var(ref, c=None, cf=None):
    """Convenient wrapper to streamline the conversions
    between ``var_ref_t`` and ``lvar_t``

    :param c: a :class:`controlFlowinator` object, optional
    :type c: :class:`controlFlowinator`
    :param cf: a decompilation object (usually the result of ``decompile``), optional
    :type cf: a :class:`cfunc_t` object
    :param ref: a reference to a variable in the pseudocode
    :type ref: :class:`var_ref_t`
    :return: a :class:`lvar_t` object
    :rtype: :class:`lvar_t`
    """
    if not c and not cf:
        raise RuntimeError(
            'Need c or cf parameters. None was passed to ref2var')
    if not cf and c:
        cf = c.cf
    return cf.lvars[ref.v.idx]
