let export ~file ?pp_edge_fun cfg =
  Kernel.Unicode.without_unicode
    (fun () ->
      let edge_txt = match pp_edge_fun with
        | None ->
          (fun e -> match  (edge_type e) with
            | Ecase (_::_) -> Pretty_utils.sfprintf "%a" EL.pretty (edge_type e)
            | _ -> ""
          )
        | Some pp -> (fun e -> Pretty_utils.sfprintf "%a" pp e)
      in
      let module P = Printer (struct let edge_txt = edge_txt endin
      let module GPrint = Graph.Graphviz.Dot(Pin
      (* [JS 2011/03/11] open_out and output_graph (and close_out?) may raise
      exception. Should be caught. *)

      let oc = open_out file in
      GPrint.output_graph oc (cfg_graph cfg, edge_txt);
      close_out oc
    ) ()