(*Clight-specific Imports*)
Require Export VST.veric.lift.
Require Export VST.veric.mpred.
Fixpoint modifiedvars' (c: statement) (S: idset) : idset :=
match c with
| Sset id e => insert_idset id S
| Sifthenelse _ c1 c2 => modifiedvars' c1 (modifiedvars' c2 S)
| Scall (Some id) _ _ => insert_idset id S
| Sbuiltin (Some id) _ _ _ => insert_idset id S
| Ssequence c1 c2 =>  modifiedvars' c1 (modifiedvars' c2 S)
| Sloop c1 c2 => modifiedvars' c1 (modifiedvars' c2 S)
| Sswitch e cs => modifiedvars_ls cs S
| Slabel _ c => modifiedvars' c S
| _ => S
end
with
modifiedvars_ls (cs: labeled_statements) (S: idset) : idset :=
match cs with
| LSnil => S
| LScons _ c ls => modifiedvars' c (modifiedvars_ls ls S)
end.
Definition isOK {A} (P: Errors.res A) := match P with Errors.OK _ => true | _ => false end.
Definition modifiedvars (c: statement) (id: ident) :=
isSome ((modifiedvars' c idset0) ! id).
Definition type_of_global (ge: Clight.genv) (b: block) : option type :=
match Genv.find_var_info ge b with
| Some gv => Some gv.(gvar_info)
| None =>
match Genv.find_funct_ptr ge b with
| Some fd => Some(type_of_fundef fd)
| None => None
end
end.
Definition filter_genv (ge: Clight.genv) : genviron :=
Genv.find_symbol ge.
Definition make_tenv (te : Clight.temp_env) : tenviron := fun id => PTree.get id te.
Definition make_venv (te : Clight.env) : venviron := fun id => PTree.get id te.
Definition construct_rho ge ve te:= mkEnviron ge (make_venv ve) (make_tenv te) .
Definition empty_environ (ge: Clight.genv) := mkEnviron (filter_genv ge) (Map.empty _) (Map.empty _).
(** Definitions related to function specifications and return assertions **)
Inductive exitkind : Type := EK_normal | EK_break | EK_continue | EK_return.
Instance EqDec_exitkind: EqDec exitkind.
Definition sub_option {A} (x y: option A) :=
match x with Some x' => y = Some x' | None => True end.
Definition Annotation_sub (A1 A2: option Annotation):Prop :=
match A1, A2 with
_, None => True
| Some (StrongAnnotation _), Some (WeakAnnotation _) => True
| Some (StrongAnnotation X), Some (StrongAnnotation Y) => X=Y (*maybe have entailment here?*)
| X, Y => X=Y
end.

Lemma Annotation_sub_trans a1 a2 a3: Annotation_sub a1 a2 ->
Annotation_sub a2 a3 -> Annotation_sub a1 a3.