(*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.

Lemma sub_option_spec: forall {A} (T1 T2: PTree.t A),
(forall id, sub_option (T1 ! id) (T2 ! id)) ->
forall id co, T1 ! id = Some co -> T2 ! id = Some co.