def intersect_intervals(inter1_min, inter1_max, inter2_min, inter2_max):
    """Compute intersection of intervals

    Computes intersections of intervals `(inter1_min, inter1_max)` and
    `(inter2_min, inter2_max)`. Basically, the output is `(max(inter1_min,
    inter2_min), min(inter1_max, inter2_max))` but optimized for better
    execution speed.
    """
    if inter1_min <= inter2_min:
        res_min = inter2_min
    else:
        res_min = inter1_min

    if inter1_max <= inter2_max:
        res_max = inter1_max
    else:
        res_max = inter2_max

    return res_min, res_max