import re


def camel_case_to_lower(name):
    # type: (str) -> str
    """
    Convert a string written in CamelCase to lower case, with underscores inserted before capitals.
    :param name: CamelCase string
    :return: camel_case string returned as lower case
    """
    return re.sub("([^A-Z])([A-Z][A-Za-z]*)", r"\1_\2", name).lower()