Instance CompSpecs : compspecs. make_compspecs prog. Defined.
Definition Vprog : varspecs. mk_varspecs prog. Defined.
Definition acquire_spec := DECLARE _acquire acquire_spec.
Definition release_spec := DECLARE _release release_spec.
Definition makelock_spec := DECLARE _makelock (makelock_spec _).
Definition spawn_spec := DECLARE _spawn spawn_spec.
Definition f_spec :=
DECLARE _f
WITH i : Z
PRE [ _i OF tint ]
PROP (repable_signed (i * i))
LOCAL (temp _i (vint i))
SEP ()
POST [ tint ]
PROP ()
LOCAL (temp ret_temp (vint (i * i)))
SEP ().
Definition ttask := Tstruct _task noattr.
Definition task_inv sh p := EX arg : Z, !!(repable_signed (arg * arg)) &&
field_at sh ttask [StructField _arg] (vint arg) p *
field_at Ews ttask [StructField _result] (vint (arg * arg)) p.
Definition g_spec :=
DECLARE _g
WITH p : val, x : Z * share
PRE [ _p OF tptr tvoid ]
let '(arg, sh) := x in
PROP  ()
LOCAL (temp _p p)
SEP   ((!!(repable_signed (arg * arg) /\ readable_share sh) && emp);
field_at sh ttask [StructField _arg] (vint arg) p;
lock_inv sh p (task_inv sh p);
field_at_ Ews ttask [StructField _result] p)
POST [ tptr tvoid ]
PROP ()
LOCAL ()
SEP ().
Definition main_spec :=
DECLARE _main
WITH u : unit
PRE  [] main_pre prog tt nil u
POST [ tint ] main_post prog nil u.
Definition Gprog : funspecs := ltac:(with_library prog [acquire_spec; release_spec; makelock_spec;
spawn_spec; f_spec; g_spec; main_spec]).
Hint Resolve inv_precise inv_positive.

Lemma body_main:  semax_body Vprog Gprog f_main main_spec.