<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_stylemap_names( family_name, style_name, is_bold=False, is_italic=False, linked_style=None ):
 """Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value of `styleMapStyleName` can be either "regular", "bold", "italic" or "bold italic", depending on the values of `is_bold` and `is_italic`. The `styleMapFamilyName` is a combination of the `family_name` and the `linked_style`. If `linked_style` is unset or set to 'Regular', the linked style is equal to the style_name with the last occurrences of the strings 'Regular', 'Bold' and 'Italic' stripped from it. """


    styleMapStyleName = (
        " ".join(
            s for s in ("bold" if is_bold else "", "italic" if is_italic else "") if s
        )
        or "regular"
    )
    if not linked_style or linked_style == "Regular":
        linked_style = _get_linked_style(style_name, is_bold, is_italic)
    if linked_style:
        styleMapFamilyName = (family_name or "") + " " + linked_style
    else:
        styleMapFamilyName = family_name
    return styleMapFamilyName, styleMapStyleName