def compute_interval_overlaps(A, B, min_overlap=0, is_sorted=False):
    """
    Given two lists, A and B, of interval tuples in the form (name, start, end)
    return a list of tuples of the form:

    (A_name, B_name, overlap_start, overlap_end)

    for every pair of intervals that overlaps by at least <min_overlap>
    """
    overlaps = []
    if not is_sorted:
        A = sorted(A, key=lambda x: x[1])
        B = sorted(B, key=lambda x: x[1])
    A_ptr = 0
    B_ptr = 0
    if B[B_ptr][1] <= A[A_ptr][2]:
        while B[B_ptr][1] <= A[A_ptr][2]:
            overlap_start = max(A[A_ptr][1], B[B_ptr][1])
            overlap_end = min(A[A_ptr][2], B[B_ptr][2])
            if overlap_end - overlap_start >= min_overlap:
                overlaps.append((A[A_ptr][0], B[B_ptr][0], overlap_start,
                    overlap_end))
            if B_ptr < len(B) - 1:
                B_ptr += 1
            else:
                break
        B_ptr -= 1
    while True:
        if A_ptr < len(A) - 1:
            A_ptr += 1
        else:
            break
        while A[A_ptr][1] > B[B_ptr][2]:
            if B_ptr < len(B) - 1:
                B_ptr += 1
            else:
                break
        if B[B_ptr][1] <= A[A_ptr][2]:
            while B[B_ptr][1] <= A[A_ptr][2]:
                overlap_start = max(A[A_ptr][1], B[B_ptr][1])
                overlap_end = min(A[A_ptr][2], B[B_ptr][2])
                if overlap_end - overlap_start >= min_overlap:
                    overlaps.append((A[A_ptr][0], B[B_ptr][0],
                        overlap_start, overlap_end))
                if B_ptr < len(B) - 1:
                    B_ptr += 1
                else:
                    break
            B_ptr -= 1
    return overlaps
