<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def base64_decodestring(instr):
    '''
    Decode a base64-encoded string using the "legacy" Python interface.
    '''
    b = salt.utils.stringutils.to_bytes(instr)
    try:
        # PY3
        decoded = base64.decodebytes(b)
    except AttributeError:
        # PY2
        decoded = base64.decodestring(b)
    try:
        return salt.utils.stringutils.to_unicode(
            decoded,
            encoding='utf8' if salt.utils.platform.is_windows() else None
        )
    except UnicodeDecodeError:
        return decoded