import ipaddress


def ip_subtract(ip, val):
    """Subtract an integer to an IP address.

    Args:
        ip (str): An IP address in string format that is able to be converted by `ipaddress` library.
        val (int): An integer of which the IP address should be subtracted by.

    Returns:
        str: IP address formatted string with the newly subtracted IP address.

    Example:
        >>> from netutils.ip import ip_subtract
        >>> ip_subtract("10.100.100.100", 200)
        '10.100.99.156'
        >>>
    """
    return str(ipaddress.ip_address(ip) - val)