Instance CompSpecs : compspecs.Definition Vprog : varspecs.Definition acquire_spec := DECLARE _acquire acquire_spec.Definition release_spec := DECLARE _release release_spec.Definition makelock_spec := DECLARE _makelock (makelock_spec _).Definition freelock_spec := DECLARE _freelock (freelock_spec _).Definition spawn_spec := DECLARE _spawn spawn_spec.Definition freelock2_spec := DECLARE _freelock2 (freelock2_spec _).Definition release2_spec := DECLARE _release2 release2_spec.Instance sum_ghost : Ghost :=
  { G := nat; valid g := True; Join_G a b c := c = (a + b)%nat }.Instance ctr_ghost : Ghost := ref_PCM sum_ghost.Definition ghost_ref g n := ghost_reference(P := sum_ghost) g n.Definition ghost_part g sh n := ghost_part(P := sum_ghost) g sh n.Definition ghost_both g sh n1 n2 := ghost_part_ref(P := sum_ghost) g sh n1 n2.Definition thread_lock_R sh gsh g ctr lockc :=
  lock_inv sh lockc (cptr_lock_inv g ctr) * ghost_part g gsh 1%nat.Definition thread_lock_inv tsh sh gsh g ctr lockc lockt :=
  selflock (thread_lock_R sh gsh g ctr lockc) tsh lockt.

Lemma body_thread_func : semax_body Vprog Gprog f_thread_func thread_func_spec.