def register_car(registration, company, plate):
    """
    Registers a new car.

    NOTE: this function should not modify the registration dictionary that is
    given, instead it should create a new dictionary.
    NOTE: this function should not introduce duplicates in the registration
    system. Specifically, if a car is already registered with the given
    company it should return an identical registration information. If the car
    is registered with a different company it should remove the first
    registration.
    NOTE: if the company is not listed in the dictionary, it should not
    introduce it. Instead it should just return an identical registration.

    E.g., register_car({'Stark Industries': ['IRNMN']}, 'Stark Industries',
                       'JARVIS')
    is {'Stark Industries': ['IRNMN', 'JARVIS']}
    E.g., register_car({'Stark Industries': ['IRNMN']}, 'Wayne Enterprises',
                       'IMBTMN')
    is {'Stark Industries': ['IRNMN']}

    :param registration: preexisting registration information
    :param company: company to register the car for
    :param plate: license plate of the car to register
    :return: new registration information dictionary with added registration
    :rtype: dict
    """
    my_output_dict = {**registration}
    my_company_list = []
    my_plate_list = []
    my_dual_list = []

    for my_key, my_value in registration.items():
        my_company_list.append(my_key)
        my_plate_list.append(my_value)
        my_dual_list.append([my_key, my_value])

    my_plate_list = [x for sub in my_plate_list for x in sub]

    if company in my_company_list and plate not in my_plate_list:
        my_output_dict[company].append(plate)
    elif company in my_company_list and plate in my_plate_list:
        for my_list_item in my_dual_list:
            if my_list_item[0] == company:
                my_list_item[1].append(plate)
        for my_list_item in my_dual_list:
            if plate in my_list_item[1] and my_list_item[0] != company:
                my_list_item[1].remove(plate)

    for my_row in my_dual_list:
        my_output_dict[my_row[0]] = list(set(my_row[1]))
    return my_output_dict