Section SHIFT_AMOUNT.
Variable l: Z.
Hypothesis l_range: 0 <= l < 32.
Variable N: int.
Hypothesis N_eq: Int.unsigned N = two_p l.
Remark mk_amount_range:
forall n, Int.ltu (Int.zero_ext l n) N = true.
Remark mk_amount_eq:
forall n, Int.ltu n N = true -> Int.zero_ext l n = n.
End SHIFT_AMOUNT.
Program Definition mk_amount32 (n: int): amount32 :=
{| a32_amount := Int.zero_ext 5 n |}.
Next Obligation.
apply mk_amount_range. omega. reflexivity.
Qed.
Program Definition mk_amount64 (n: int): amount64 :=
{| a64_amount := Int.zero_ext 6 n |}.
Next Obligation.
apply mk_amount_range. omega. reflexivity.
Qed.
(** Recognition of move operations. *)
Definition is_move_operation
(A: Type) (op: operation) (args: list A) : option A :=
match op, args with
| Omove, arg :: nil => Some arg
| _, _ => None
end.
(** [negate_condition cond] returns a condition that is logically equivalent to the negation of [cond]. *)
Definition negate_condition (cond: condition): condition :=
match cond with
| Ccomp c => Ccomp (negate_comparison c)
| Ccompu c => Ccompu (negate_comparison c)
| Ccompimm c n => Ccompimm (negate_comparison c) n
| Ccompuimm c n => Ccompuimm (negate_comparison c) n
| Ccompshift c s a => Ccompshift (negate_comparison c) s a
| Ccompushift c s a => Ccompushift (negate_comparison c) s a
| Cmaskzero n => Cmasknotzero n
| Cmasknotzero n => Cmaskzero n
| Ccompl c => Ccompl (negate_comparison c)
| Ccomplu c => Ccomplu (negate_comparison c)
| Ccomplimm c n => Ccomplimm (negate_comparison c) n
| Ccompluimm c n => Ccompluimm (negate_comparison c) n
| Ccomplshift c s a => Ccomplshift (negate_comparison c) s a
| Ccomplushift c s a => Ccomplushift (negate_comparison c) s a
| Cmasklzero n => Cmasklnotzero n
| Cmasklnotzero n => Cmasklzero n
| Ccompf c => Cnotcompf c
| Cnotcompf c => Ccompf c
| Ccompfzero c => Cnotcompfzero c
| Cnotcompfzero c => Ccompfzero c
| Ccompfs c => Cnotcompfs c
| Cnotcompfs c => Ccompfs c
| Ccompfszero c => Cnotcompfszero c
| Cnotcompfszero c => Ccompfszero c
end.

Lemma eval_negate_condition:
forall cond vl m,
eval_condition (negate_condition cond) vl m = option_map negb (eval_condition cond vl m).