let finalize_pdg pdg from_opt =
    debug2 "try to finalize_pdg";
    let last_state =
      try Some (Pdg_state.get_last_state (get_states pdg))
      with Not_found ->
        let ret =
          try Kernel_function.find_return (get_kf pdg)
          with Kernel_function.No_Statement ->
            Pdg_parameters.abort "No return in a declaration"
        in
        Pdg_parameters.warning ~once:true ~source:(fst (Stmt.loc ret))
          "no final state. Probably unreachable...";
        None
    in
    (match from_opt with
    | None -> () (* defined function : retres already processed. *)
    | Some froms -> (* undefined function : add output 0 *)
      (* TODO : also add the nodes for the other from ! *)
      let state = match last_state with Some s -> s | None -> assert false in
      let process_out out  (default, from_out) s =
        add_from pdg state s out (default, from_out)
      in
      let from_table = froms.Function_Froms.deps_table in
      let new_state =
        try Lmap_bitwise.From_Model.fold process_out from_table state
        with Lmap_bitwise.From_Model.Cannot_fold -> (* TOP in from_table *)
          process_out Locations.Zone.top (falseLocations.Zone.top) state
      in
      if not (Kernel_function.returns_void pdg.fct) then begin
        let from0 = froms.Function_Froms.deps_return in
        ignore
          (create_fun_output_node
             pdg
             (Some new_state)
             (Lmap_bitwise.From_Model.LOffset.collapse from0))
      end;
      store_last_state pdg new_state);
    let init_state = process_other_inputs pdg in
    store_init_state pdg init_state;
    add_ctrl_dpds pdg ;
    debug2 "finalize_pdg ok";
    let states = get_states pdg in
    PdgTypes.Pdg.make pdg.fct pdg.graph states pdg.index