(********************************************  Max length gfs field_at load store: semax_max_path_field_load_nth_ram. semax_max_path_field_cast_load_nth_ram. semax_max_path_field_store_nth_ram.  ********************************************)
Section LOADSTORE_FIELD_AT.
Context {cs: compspecs}.

(* TODO: delete it *)
Lemma semax_max_path_field_cast_load_nth_ram:
forall {Espec: OracleKind},
forall n Delta sh id P Q R (e1: expr) Pre
(t t_root: type) (efs: list efield) (gfs: list gfield) (tts: list type)
(p v: val) (v' : reptype (nested_field_type t_root gfs)) lr,
typeof_temp Delta id = Some t ->
type_is_by_value (typeof (nested_efield e1 efs tts)) = true ->
cast_pointer_to_bool (typeof (nested_efield e1 efs tts)) t = false ->
readable_share sh ->
LR_of_type t_root = lr ->
type_is_volatile (typeof (nested_efield e1 efs tts)) = false ->
legal_nested_efield t_root e1 gfs tts lr = true ->
JMeq v' v ->
nth_error R n = Some Pre ->
Pre |-- field_at sh t_root gfs v' p * TT ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq p) (eval_LR e1 lr)) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_LR Delta e1 lr) &&
(tc_efield Delta efs) &&
local (efield_denote efs gfs) &&
local `(tc_val t (eval_cast (typeof (nested_efield e1 efs tts)) t v)) ->
semax Delta (|> PROPx P (LOCALx Q (SEPx R)))
(Sset id (Ecast (nested_efield e1 efs tts) t))
(normal_ret_assert
(PROPx P
(LOCALx (temp id (eval_cast (typeof (nested_efield e1 efs tts)) t v) :: remove_localdef_temp id Q)
(SEPx R)))).