Definition eval_extcond (xc: extcond) (rs: regset) : option bool :=
match xc with
| Cond_base c =>
eval_testcond c rs
| Cond_and c1 c2 =>
match eval_testcond c1 rs, eval_testcond c2 rs with
| Some b1, Some b2 => Some (b1 && b2)
| _, _ => None
end
| Cond_or c1 c2 =>
match eval_testcond c1 rs, eval_testcond c2 rs with
| Some b1, Some b2 => Some (b1 || b2)
| _, _ => None
end
end.
Definition swap_floats {A: Type} (c: comparison) (n1 n2: A) : A :=
match c with
| Clt | Cle => n2
| Ceq | Cne | Cgt | Cge => n1
end.

(* Specifications: *)
Lemma testcond_for_float_comparison_correct:
forall c n1 n2 rs,
eval_extcond (testcond_for_condition (Ccompf c))
(nextinstr (compare_floats (Vfloat (swap_floats c n1 n2))
(Vfloat (swap_floats c n2 n1)) rs)) =
Some(Float.cmp c n1 n2).
Lemma testcond_for_neg_float_comparison_correct:
forall c n1 n2 rs,
eval_extcond (testcond_for_condition (Cnotcompf c))
(nextinstr (compare_floats (Vfloat (swap_floats c n1 n2))
(Vfloat (swap_floats c n2 n1)) rs)) =
Some(negb(Float.cmp c n1 n2)).
Lemma testcond_for_float32_comparison_correct:
forall c n1 n2 rs,
eval_extcond (testcond_for_condition (Ccompfs c))
(nextinstr (compare_floats32 (Vsingle (swap_floats c n1 n2))
(Vsingle (swap_floats c n2 n1)) rs)) =
Some(Float32.cmp c n1 n2).
Lemma testcond_for_neg_float32_comparison_correct:
forall c n1 n2 rs,
eval_extcond (testcond_for_condition (Cnotcompfs c))
(nextinstr (compare_floats32 (Vsingle (swap_floats c n1 n2))
(Vsingle (swap_floats c n2 n1)) rs)) =
Some(negb(Float32.cmp c n1 n2)).