Definition fun_id (ext_link: Strings.String.string -> ident) (ef: external_function) : option ident :=
  match ef with EF_external id sig => Some (ext_link id) | _ => None end.

(* Specifications: *)
Lemma module_sequential_safety : (*TODO*) forall {CS: compspecs} (prog: program) (V: varspecs) (G: funspecs) ora m f f_id f_b f_body args, let ge := Genv.globalenv prog in let ext_link := ext_link_prog prog in let spec := add_funspecs NullExtension.Espec ext_link G in let tys := sig_args (ef_sig f) in let rty := sig_res (ef_sig f) in let sem := juicy_core_sem (cl_core_sem (Build_genv ge (prog_comp_env prog))) in @semax_prog spec CS prog V G -> fun_id ext_link f = Some f_id -> Genv.find_symbol ge f_id = Some f_b -> Genv.find_funct ge (Vptr f_b Ptrofs.zero) = Some f_body -> forall x : ext_spec_type (@OK_spec spec) f, ext_spec_pre (@OK_spec spec) f x (genv_symb_injective ge) tys args ora m -> exists q, initial_core sem 0 (*additional temporary argument - TODO (Santiago): FIXME*) m q m (Vptr f_b Ptrofs.zero) args /\ forall n, safeN_(genv_symb := @genv_symb_injective _ _)(Hrel := juicy_extspec.Hrel) (coresem_extract_cenv sem (prog_comp_env prog)) (upd_exit (@OK_spec spec) x (genv_symb_injective ge)) ge n ora q m.
Lemma module_sequential_safety : (*TODO*) forall {CS: compspecs} (prog: program) (V: varspecs) (G: funspecs) ora m f f_id f_b f_body args, let ge := Genv.globalenv prog in let ext_link := ext_link_prog prog in let spec := add_funspecs NullExtension.Espec ext_link G in let tys := sig_args (ef_sig f) in let rty := sig_res (ef_sig f) in let sem := juicy_core_sem (cl_core_sem (Build_genv ge (prog_comp_env prog))) in @semax_prog spec CS prog V G -> fun_id ext_link f = Some f_id -> Genv.find_symbol ge f_id = Some f_b -> Genv.find_funct ge (Vptr f_b Ptrofs.zero) = Some f_body -> forall x : ext_spec_type (@OK_spec spec) f, ext_spec_pre (@OK_spec spec) f x (genv_symb_injective ge) tys args ora m -> exists q, initial_core sem 0 (*additional temporary argument - TODO (Santiago): FIXME*) m q m (Vptr f_b Ptrofs.zero) args /\ forall n, safeN_(genv_symb := @genv_symb_injective _ _)(Hrel := juicy_extspec.Hrel) (coresem_extract_cenv sem (prog_comp_env prog)) (upd_exit (@OK_spec spec) x (genv_symb_injective ge)) ge n ora q m.