def _translate_gcc_doc(s):
    """
    Map lines describing architectures from
    https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/x86-Options.html#x86-Options
    to list of flags in /proc/cpuinfo

    >>> flags = _translate_gcc_doc('Intel Core 2 CPU with 64-bit extensions, '
    ... 'MMX, SSE, SSE2, SSE3 and SSSE3 instruction set support.')
    >>> sorted(flags)
    ['lm', 'mmx', 'pni', 'sse', 'sse2', 'ssse3']
    """
    flags = set(str(s).split('with', 1)[1].split('instruction set', 1)[0].
        rstrip('.').replace(',', ' ').replace('and', ' ').replace(
        '64-bit extensions', 'lm').replace('.', '_').lower().split())
    for gcc, linux in [('bmi', 'bmi1'), ('adcx', 'adx'), ('pclmul',
        'pclmulqdq'), ('rdrnd', 'rdrand'), ('prefetchw', '3dnowprefetch'),
        ('sha', 'sha_ni'), ('sse3', 'pni'), ('xsaves', None)]:
        if gcc in flags:
            flags.remove(gcc)
            if linux:
                flags.add(linux)
    return flags
