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

Lemma semax_load_nth_ram_field_at :
forall {Espec: OracleKind}{cs: compspecs} n (Delta: tycontext) sh id P Q R e1 Pre
t_id t_root gfs (p v_val: val) (v_reptype: reptype (nested_field_type t_root gfs)),
typeof e1 = nested_field_type t_root gfs ->
typeof_temp Delta id = Some t_id ->
is_neutral_cast (nested_field_type t_root gfs) t_id = true ->
type_is_volatile (nested_field_type t_root gfs) = false ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq (field_address t_root gfs p)) (eval_lvalue e1)) ->
nth_error R n = Some Pre ->
readable_share sh ->
Pre |-- field_at sh t_root gfs v_reptype p * TT ->
JMeq v_reptype v_val ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_lvalue Delta e1) && local (`(tc_val (nested_field_type t_root gfs) v_val)) ->
@semax cs Espec Delta (|> PROPx P (LOCALx Q (SEPx R)))
(Sset id e1)
(normal_ret_assert
(PROPx P
(LOCALx (temp id v_val :: remove_localdef_temp id Q)
(SEPx R)))).