from typing import Set
import re


def extract_cpu_flags(cpuinfo: str) -> Set[str]:
    """
    Extract CPU flags from /proc/cpuinfo string

    :return: Set of CPU flags for which given cpuinfo string indicates support
    :rtype: set
    """

    # Prepare cpuinfo str
    lines = [line.strip() for line in cpuinfo.split('\n')]

    # Get lines defining flags
    flag_lines = []
    flag_line_expression = re.compile(r'^(flags)(\s*:\s*)(.*)$', re.MULTILINE)
    for match in re.findall(flag_line_expression, '\n'.join(lines)):
        flag_lines += [' '.join(match[2].split())]

    # There could be different flags in different flag lines.
    # We add all flags from all flag lines to set in order to
    # get maximum number of flags supported.
    flags = set()
    for line in flag_lines:
        for flag in line.split(' '):
            flags.add(flag)

    return flags