def get_parser_options(fast: bool = False, preproc: bool = False) -> int:
  """Set and retrieve parser options based on user input.

  Args:
      fast (bool, optional): Flag for ultra-fast parsing at the expense of accuracy. Defaults to False.
      preproc (bool, optional): Include preprocessor macros in parsing. Defaults to False.

  Returns:
      An integer bitfield representing the selected options.
  """

  # clang.cindex.TranslationUnit does not have all latest flags
  CXTranslationUnit_None = 0x0
  CXTranslationUnit_DetailedPreprocessingRecord = 0x01
  CXTranslationUnit_Incomplete = 0x02
  CXTranslationUnit_PrecompiledPreamble = 0x04
  CXTranslationUnit_CacheCompletionResults = 0x08
  CXTranslationUnit_ForSerialization = 0x10
  CXTranslationUnit_CXXChainedPCH = 0x20
  CXTranslationUnit_SkipFunctionBodies = 0x40
  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100
  CXTranslationUnit_KeepGoing = 0x200
  CXTranslationUnit_SingleFileParse = 0x400
  CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800
  CXTranslationUnit_IncludeAttributedTypes = 0x1000
  CXTranslationUnit_VisitImplicitAttributes = 0x2000
  CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000
  CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000

  default_parser_options = (CXTranslationUnit_VisitImplicitAttributes  # only way to get class methods parsed correctly
                            | CXTranslationUnit_CacheCompletionResults  # potentially speeds up parsing of large baselines
                            | CXTranslationUnit_SkipFunctionBodies  # skips parsing inside of functions, much faster
                            | CXTranslationUnit_LimitSkipFunctionBodiesToPreamble  # only skips function preambles
                            | CXTranslationUnit_RetainExcludedConditionalBlocks  # keep includes inside ifdef blocks
                            | CXTranslationUnit_KeepGoing)  # don't stop on errors

  # Don't parse include files recursively - major speedup
  if fast:
    default_parser_options |= CXTranslationUnit_SingleFileParse

  # Needed to parse preprocessor macros
  if preproc:
    default_parser_options |= CXTranslationUnit_DetailedPreprocessingRecord

  return default_parser_options