Instance CompSpecs : compspecs.Definition Vprog : varspecs.Definition flip_ends {A} lo hi (contents: list A) :=
  sublist 0 lo (rev contents)
  ++ sublist lo hi contents
  ++ sublist hi (Zlength contents) (rev contents).

(* Specifications: *)
Lemma Zlength_flip_ends: forall A i j (al: list A), 0 <= i -> i<=j -> j <= Zlength al -> Zlength (flip_ends i j al) = Zlength al.
Lemma flip_fact_1: forall A size (contents: list A) j, Zlength contents = size -> 0 <= j -> size - j - 1 <= j <= size - j -> flip_ends j (size - j) contents = rev contents.
Lemma flip_fact_3: forall A (al: list A) j size, size = Zlength al -> 0 <= j < size - j - 1 -> sublist 0 j (flip_ends j (size - j) al) ++ sublist (size - j - 1) (size - j) al ++ sublist (j + 1) size (sublist 0 (size - j - 1) (flip_ends j (size - j) al) ++ sublist j (j + 1) (flip_ends j (size - j) al) ++ sublist (size - j) size (flip_ends j (size - j) al)) = flip_ends (j + 1) (size - (j + 1)) al.
Lemma flip_ends_map: forall A B (F: A -> B) lo hi (al: list A), flip_ends lo hi (map F al) = map F (flip_ends lo hi al).
Lemma flip_fact_2: forall {A}{d: Inhabitant A} (al: list A) size j, Zlength al = size -> j < size - j - 1 -> 0 <= j -> Znth (size - j - 1) al = Znth (size - j - 1) (flip_ends j (size - j) al).
Lemma body_reverse: semax_body Vprog Gprog f_reverse reverse_spec.
Lemma body_main: semax_body Vprog Gprog f_main main_spec.
Lemma prog_correct: semax_prog prog Vprog Gprog.