let compute_entry_point kf ~library =
  clear_call_stack ();
  Kf_state.mark_as_called kf;
  Value_parameters.feedback "Analyzing a%scomplete application starting at %a"
    (if library then "n in" else " ")
    Kernel_function.pretty_name kf;

  Separate.prologue();

  let initial_state_globals =
    if Db.Value.globals_use_supplied_state () then (
      let r = Db.Value.globals_state () in
      Value_parameters.feedback "Initial state supplied by user";
      Value_parameters.debug "@[<hov 0>Values of globals@\n%a@]"
        Db.Value.pretty_state_without_null r;
      r)
    else (
      Value_parameters.feedback "Computing initial state";
      let r = Db.Value.globals_state () in
      Value_parameters.feedback "Initial state computed";
      Value_parameters.result
        "@[<hov 0>Values of globals at initialization@\n%a@]"
        Db.Value.pretty_state_without_null r;
      r
    ) in
  Db.Value.update_table Kglobal initial_state_globals;

  Mark_noresults.run();

  let with_formals = match Db.Value.fun_get_args () with
    | None -> initial_state_formals kf initial_state_globals
    | Some actuals ->
        let formals = Kernel_function.get_formals kf in
        if (List.length formals) <> List.length actuals then
          raise Db.Value.Incorrect_number_of_arguments;
        let treat_one_formal f a =
          (), a, Builtins.offsetmap_of_value ~typ:f.vtype a
        in
        actualize_formals
          kf
          initial_state_globals
          (List.map2 treat_one_formal formals actuals)
  in
  Db.Value.Call_Value_Callbacks.apply (with_formals, [ kf, Kglobal ]);
  let result =
    compute_with_initial_state kf ~call_kinstr:Kglobal with_formals
  in
  Value_parameters.feedback "done for function %a"
    Kernel_function.pretty_name kf;
  Separate.epilogue();
  result