(** Preservation by external calls *)
Section EXTCALL.
Variables F1 F2: meminj.
Variables m1 m2 m1' m2': mem.
Hypothesis MAXPERM: forall b ofs p, Mem.valid_block m1 b -> Mem.perm m2 b ofs Max p -> Mem.perm m1 b ofs Max p.
Hypothesis MAXPERM': forall b ofs p, Mem.valid_block m1' b -> Mem.perm m2' b ofs Max p -> Mem.perm m1' b ofs Max p.
Hypothesis UNCHANGED: Mem.unchanged_on (loc_out_of_reach F1 m1) m1' m2'.
Hypothesis INJ: Mem.inject F1 m1 m1'.
Hypothesis INCR: inject_incr F1 F2.
Hypothesis SEP: inject_separated F1 F2 m1 m1'.

Lemma match_stacks_extcall:
forall stk stk' bound,
match_stacks F1 m1 m1' stk stk' bound ->
Ple bound (Mem.nextblock m1') ->
match_stacks F2 m2 m2' stk stk' bound
with match_stacks_inside_extcall:
forall stk stk' f' ctx sp' rs',
match_stacks_inside F1 m1 m1' stk stk' f' ctx sp' rs' ->
Plt sp' (Mem.nextblock m1') ->
match_stacks_inside F2 m2 m2' stk stk' f' ctx sp' rs'.