'Set the return value into the given state'

def set_return_val(self, state, val, is_fp=None, size=None, stack_base=None):

    ty = (self.func_ty.returnty if (self.func_ty is not None) else None)
    try:
        betterval = self._standardize_value(val, ty, state, None)
    except AttributeError:
        raise ValueError(("Can't    fit    value    %s    into    a    return    value" % repr(val)))
    if (self.ret_val is not None):
        loc = self.ret_val
    elif (is_fp is not None):
        loc = (self.FP_RETURN_VAL if is_fp else self.RETURN_VAL)
    elif (ty is not None):
        loc = (self.FP_RETURN_VAL if isinstance(ty, SimTypeFloat) else self.RETURN_VAL)
    else:
        loc = (self.FP_RETURN_VAL if self.is_fp_value(val) else self.RETURN_VAL)
    if (loc is None):
        raise NotImplementedError("This    SimCC    doesn't    know    how    to    store    this    value    -    should    be    implemented")
    loc.set_value(state, betterval, endness='Iend_BE', stack_base=stack_base)
