def restrict_to_range(x: int, lower_bound: int, upper_bound: int):
    """
    Takes an integer x and restricts its range by the following:
    - If x is above the upper_bound, make x the upper_bound.
    - If x is below the lower_bound, make x the lower_bound.
    - Otherwise leave x the same.
    """
    return min(max(x, lower_bound), upper_bound)