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 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
  if not (Db.Value.is_reachable initial_state_globals) then begin
    Value_parameters.result "Value analysis not started because globals initialization is not computable.";
    None, initial_state_globals, Locations.Location_Bits.Top_Param.empty
  end else begin
    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)
            (fun _ _ -> ())
    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 kf;
    Separate.epilogue();
    result
  end