Instance CompSpecs : compspecs.Definition Vprog : varspecs.Definition release2_spec := DECLARE _release2 release2_spec.Definition freelock2_spec := DECLARE _freelock2 (freelock2_spec _).Definition spawn_spec := DECLARE _spawn spawn_spec.(* One might think it should just return an unknown number, but in fact it needs to follow a known hash
   function at the logic level to be useful. *)

Definition tentry := Tstruct _entry noattr.Instance hf1 : hash_fun := { size := 16384; hash i := (i * 654435761) mod 16384 }.Definition v_R (h : list hist_el) (v : Z) := emp.(* Entries are no longer consecutive. *)
Definition wf_hists h := Forall (fun x => (ordered_hist (fst x) /\ Forall int_op (map snd (fst x))) /\
  (ordered_hist (snd x) /\ Forall int_op (map snd (snd x)))) h.Definition make_map h :=
  map (fun hs => (make_int (value_of_hist (fst hs)), make_int (value_of_hist (snd hs)))) h.Definition atomic_entry sh pk pv gk gv hk hv :=
  atomic_loc_hist sh pk gk 0 k_R hk * atomic_loc_hist sh pv gv 0 v_R hv.Definition atomic_entries sh entries ghosts hists := fold_right sepcon emp
  (map (fun x => let '((pk, pv), (gk, gv), (hk, hv)) := x in atomic_entry sh pk pv gk gv hk hv)
    (combine (combine entries ghosts) hists)).Definition f_lock_pred tsh sh entries ghosts p t locksp lockt resultsp res :=
  selflock (f_lock_inv sh entries ghosts p t locksp lockt resultsp res) tsh lockt.

Lemma update_entries_hist : forall sh entries ghosts h i hk hv pki pvi gki gvi (Hlen : Zlength entries = Zlength h) (Hleng : Zlength ghosts = Zlength entries) (Hpi : Znth i entries (Vundef, Vundef) = (pki, pvi)) (Hgi : Znth i ghosts (Vundef, Vundef) = (gki, gvi)) (Hi : 0 <= i < Zlength entries), atomic_entries sh entries ghosts (upd_Znth i h (hk, hv)) = fold_right sepcon emp (upd_Znth i (map (fun x => let '((pk, pv), (gk, gv), (hk, hv)) := x in atomic_loc_hist sh pk gk 0 k_R hk * atomic_loc_hist sh pv gv 0 v_R hv) (combine (combine entries ghosts) h)) (atomic_loc_hist sh pki gki 0 k_R hk * atomic_loc_hist sh pvi gvi 0 v_R hv)).