let main _fmt =
  if Wp_parameters.BuiltinWhyFile.get () then begin
    Logic_builtin.init ();
    Logic_env.Builtins.apply ();
    Why_ops.builtin_why_file ()
  end
  else if Wp_parameters.Cfg.get () || Wp_parameters.is_on () then begin
    Ast.compute ();
    let with_bot = Wp_parameters.Bottom.get () in
    let do_dot = Wp_parameters.Dot.get ()  in
    let fct_names = Wp_parameters.Functions.get () in
    let all = Cilutil.StringSet.is_empty fct_names in
    let do_cfg kf (fct_names, cfgs) = 
      let kf_name = Kernel_function.get_name kf in
      match kf.fundec with
      | Declaration _ -> 
          if not all && Cilutil.StringSet.mem kf_name fct_names then 
            Wp_parameters.warning "ignore %s (declaration only)@." kf_name;
          fct_names, cfgs
      | Definition _ ->
          if all || Cilutil.StringSet.mem kf_name fct_names then
            begin
              let fct_names = Cilutil.StringSet.remove kf_name fct_names in
              let cfgs = 
                try
                  let cfg = Cil2cfg.create kf in
                  let _ = if do_dot then ignore (dot_cfg cfg) in
                  let annots = get_annots (get_behav_option ()) cfg in
                  let _ = if do_dot then dot_lannots cfg annots in
                    (cfg, annots)::cfgs
                with ex -> process_ex ex; cfgs
              in fct_names, cfgs
            end 
          else fct_names, cfgs
    in let fct_names, cfg_annots = 
      Globals.Functions.fold do_cfg (fct_names,[]) in
      if not all && not (Cilutil.StringSet.is_empty fct_names) then
         Wp_parameters.warning "haven't found functions %a@."
            Cilutil.StringSet.pretty fct_names;
    let why_file = match get_model_option () with 
      | None -> 
          Wp_parameters.warning "the model is not set; no WP computation";
          None
      | Some m -> why_file m with_bot do_dot cfg_annots 
    in
    if Wp_parameters.Proof.get () then match why_file with
    | Some why_file -> prove why_file
    | None -> ();
  end