def extract_bits(source, positions):
    """Get information from the source data based on bit positions.
    
    This function will extract each bit sequentially, meaning that as
    bits are removed, they will offset the position of later bits. The
    result will affect the osition of all existing and added bits on
    each iteration.
    
    Args:
        source (int): Data to extract information from.
        positions (list): Ordered integers indicating the locations of
            bits to extract. Extraction will cascade and affect the
            location of later bits.
        
    Returns:
        source (int): Source after extraction.
        extracted (int): Data that was extracted.
    
    """
    length = source.bit_length()
    positions_length = len(positions) - 1
    extracted = 0
    for i, position in enumerate(positions):
        bottom_mask = 2 ** position - 1
        top_mask = 2 ** (length - i + 1) - 1 - 2 ** position ^ bottom_mask
        prize_bit = (2 ** position & source) >> position
        extracted |= prize_bit << positions_length - i
        source = (top_mask & source) >> 1 | source & bottom_mask
    return source, extracted
