let init_file_names () =
  (* Intermediate functions for error display or fresh name of file
     generation *)

  let err= ref false in
  let dispErr mesg f =
    Aorai_option.error "Error. File '%s' %s.\n" f mesg;
    err:=true
  in
  let freshname pre suf =
    let rec fn p s n =
      if not (Sys.file_exists (p^(string_of_int n)^s)) then (p^(string_of_int n)^s)
      else fn p s (n+1)
    in
    let name =
      if not (Sys.file_exists (pre^suf)) then pre^suf
      else fn pre suf 0
    in name
  in

  (* c_file name is given and has to point out a valid file. *)
  c_file := List.hd (Parameters.Files.get ());
  if (!c_file=""then dispErr ": invalid C file name" !c_file;
  if (not (Sys.file_exists !c_file)) then dispErr "not found" !c_file;

  (* The output C file has to be a valid file name if it is used. *)
  output_c_file := (Aorai_option.Output_C_File.get ()) ;
  if (!output_c_file=""then output_c_file:=freshname ((Filename.chop_extension !c_file)^"_annot"".c";
  (*   else if Sys.file_exists !output_c_file then dispErr "already exists" !output_c_file; *)

  if Aorai_option.Dot.get () then
    dot_file:=freshname (Filename.chop_extension !c_file) ".dot";

  if Aorai_option.Ya.get () = "" then
    if Aorai_option.Buchi.get () = "" then begin
      (* ltl_file name is given and has to point out a valid file. *)
      ltl_file := Aorai_option.Ltl_File.get ();
      if (!ltl_file=""then dispErr ": invalid LTL file name" !ltl_file;
      if (not (Sys.file_exists !ltl_file)) then dispErr "not found" !ltl_file;

      (* The LTL file is always used. *)
      (* The promela file can be given or not. *)
      if Aorai_option.To_Buchi.get () <> "" then begin
        ltl_tmp_file:=
          freshname
          (Filename.chop_extension
             (Aorai_option.promela_file ())) ".ltl";
        promela_file:= Aorai_option.promela_file ();
          toBeRemoved:=(!ltl_tmp_file)::!toBeRemoved
      end else begin
        ltl_tmp_file:=
          Extlib.temp_file_cleanup_at_exit
          (Filename.basename !c_file) ".ltl";
        promela_file:=
          freshname (Filename.chop_extension !ltl_tmp_file) ".promela";
        toBeRemoved:=(!promela_file)::!toBeRemoved;
          toBeRemoved:=(!ltl_tmp_file)::!toBeRemoved
      end
    end else begin
      if Aorai_option.To_Buchi.get () <> "" &&
        Aorai_option.Ltl_File.get () <> ""
      then begin
        Aorai_option.error
          "Error. '-buchi' option is incompatible with '-to-buchi' and '-ltl' options.";
        err:=true
      end;
      (* The promela file is used only if the process does not terminate after
         LTL generation. *)

      promela_file := Aorai_option.promela_file ();
    end
  else begin
    ya_file := Aorai_option.Ya.get ();
    if (!ya_file=""then dispErr ": invalid Ya file name" !ya_file;
    if (not (Sys.file_exists !ya_file)) then dispErr "not found" !ya_file
  end;
  root := Kernel_function.get_name (fst (Globals.entry_point ()));
  display_status ();
  !err