High-quality seeding for LFSR generators.
    
    The LFSR generator components discard a certain number of their lower bits
    when generating each output. The significant bits of their state must not
    all be zero. We must ensure that when seeding the generator.
    
    In case generators are seeded from an incrementing input (such as a system
    timer), and between increments only the lower bits may change, we would
    also like the lower bits of the input to change the initial state, and not
    just be discarded. So we do basic manipulation of the seed input value to
    ensure that all bits of the seed input affect the initial state.

def lfsr_next_one_seed(seed_iter, min_value_shift):
    """High-quality seeding for LFSR generators.
    
    The LFSR generator components discard a certain number of their lower bits
    when generating each output. The significant bits of their state must not
    all be zero. We must ensure that when seeding the generator.
    
    In case generators are seeded from an incrementing input (such as a system
    timer), and between increments only the lower bits may change, we would
    also like the lower bits of the input to change the initial state, and not
    just be discarded. So we do basic manipulation of the seed input value to
    ensure that all bits of the seed input affect the initial state.
    """
    try:
        seed = seed_iter.next()
    except StopIteration:
        return 0xFFFFFFFF
    else:
        if seed is None:
            return 0xFFFFFFFF
        else:
            seed = int(seed) & 0xFFFFFFFF
            working_seed = (seed ^ (seed << 16)) & 0xFFFFFFFF

            min_value = 1 << min_value_shift
            if working_seed < min_value:
                working_seed = (seed << 24) & 0xFFFFFFFF
                if working_seed < min_value:
                    working_seed ^= 0xFFFFFFFF
            return working_seed