def ParseConfig(options):
  """Constructs a frontend/backend dict based on --opt arguments.

  Args:
    options: The result of OptionParser().parse_args().

  Returns:
    A simple dict containing keys 'frontend_opt', 'frontend_attr',
    'backend_opt', and 'backend_attr', each mapped to a valid string
    value.  The result is a function of the --opt command-line
    arguments, with defaults in place when there are too few --opt
    arguments.
  """
  configs = dict(O0f={'frontend_opt': '-O0', 'frontend_attr': 'O0f'},
                 O3f={'frontend_opt': '-O3', 'frontend_attr': 'O3f'},
                 O0b={'backend_opt': '-translate-fast',
                      'backend_attr': 'O0b'},
                 O2b={'backend_opt': '-O2', 'backend_attr': 'O2b'},
                 O0b_sz={'backend_opt': '-translate-fast --use-sz',
                         'backend_attr': 'O0b_sz'},
                 O2b_sz={'backend_opt': '-O2 --use-sz',
                         'backend_attr': 'O2b_sz'},
                 )
  result = {}
  # Default is pnacl-clang -O3, pnacl-translate -O2
  for attr in ['O3f', 'O2b'] + options.opt_attributes:
    if attr in configs:
      result.update(configs[attr])
  return result