Ltac inv_safe H :=
  inv H;
  try solve[match goal with
    | H : semantics.at_external _ _ _ = _ |- _ =>
      simpl in H; congruence
    | H : j_at_external _ _ _ = _ |- _ =>
      simpl in H; congruence
    | H : semantics.halted _ _ _ |- _ =>
      simpl in H; unfold cl_halted in H; contradiction
  end].

Lemma semax_loop: forall Delta Q Q' incr body R, semax Espec Delta Q body (loop1_ret_assert Q' R) -> semax Espec Delta Q' incr (loop2_ret_assert Q R) -> semax Espec Delta Q (Sloop body incr) R.