Section read_write.
Variable (f: file) (fptr: nat).
Let contents := get_contents f.
Fixpoint read_file_aux (nbytes sz cur: nat): list memval :=
match nbytes with
| O => nil
| S nbytes' => if eq_nat_dec sz cur then nil
else contents cur :: read_file_aux nbytes' sz (S cur)
end.

Lemma loadbytes_read_file_le m b ofs nbytes0 nbytes sz cur:
nbytes0 <= nbytes ->
Mem.loadbytes m b ofs (Z_of_nat nbytes) = Some (read_file_aux nbytes sz cur) ->
Mem.loadbytes m b ofs (Z_of_nat nbytes0) = Some (read_file_aux nbytes0 sz cur).