Definition bytes_of_init_data (i: init_data): list memval :=
match i with
| Init_int8 n => inj_bytes (encode_int 1%nat (Int.unsigned n))
| Init_int16 n => inj_bytes (encode_int 2%nat (Int.unsigned n))
| Init_int32 n => inj_bytes (encode_int 4%nat (Int.unsigned n))
| Init_int64 n => inj_bytes (encode_int 8%nat (Int64.unsigned n))
| Init_float32 n => inj_bytes (encode_int 4%nat (Int.unsigned (Float32.to_bits n)))
| Init_float64 n => inj_bytes (encode_int 8%nat (Int64.unsigned (Float.to_bits n)))
| Init_space n => list_repeat (Z.to_nat n) (Byte Byte.zero)
| Init_addrof id ofs =>
match find_symbol ge id with
| Some b => inj_value (if Archi.ptr64 then Q64 else Q32) (Vptr b ofs)
| None   => list_repeat (if Archi.ptr64 then 8%nat else 4%nat) Undef
end
end.
Remark init_data_size_addrof:
forall id ofs, init_data_size (Init_addrof id ofs) = size_chunk Mptr.

(* Specifications: *)
Lemma store_init_data_loadbytes:
forall m b p i m',
store_init_data m b p i = Some m' ->
readbytes_as_zero m b p (init_data_size i) ->
Mem.loadbytes m' b p (init_data_size i) = Some (bytes_of_init_data i).