(** Decomposing 64-bit ints as pairs of 32-bit ints *)

Definition loword (n: int) : Int.int := Int.repr (unsigned n).Definition hiword (n: int) : Int.int := Int.repr (unsigned (shru n (repr Int.zwordsize))).Definition ofwords (hi lo: Int.int) : int :=
  or (shl (repr (Int.unsigned hi)) (repr Int.zwordsize)) (repr (Int.unsigned lo)).

(* Specifications: *)
Lemma bits_loword: forall n i, 0 <= i < Int.zwordsize -> Int.testbit (loword n) i = testbit n i.
Lemma bits_hiword: forall n i, 0 <= i < Int.zwordsize -> Int.testbit (hiword n) i = testbit n (i + Int.zwordsize).
Lemma bits_ofwords: forall hi lo i, 0 <= i < zwordsize -> testbit (ofwords hi lo) i = if zlt i Int.zwordsize then Int.testbit lo i else Int.testbit hi (i - Int.zwordsize).
Lemma lo_ofwords: forall hi lo, loword (ofwords hi lo) = lo.
Lemma hi_ofwords: forall hi lo, hiword (ofwords hi lo) = hi.
Lemma ofwords_recompose: forall n, ofwords (hiword n) (loword n) = n.
Lemma ofwords_add: forall lo hi, ofwords hi lo = repr (Int.unsigned hi * two_p 32 + Int.unsigned lo).
Lemma ofwords_add': forall lo hi, unsigned (ofwords hi lo) = Int.unsigned hi * two_p 32 + Int.unsigned lo.
Lemma bits_loword: forall n i, 0 <= i < Int.zwordsize -> Int.testbit (loword n) i = testbit n i.
Lemma bits_hiword: forall n i, 0 <= i < Int.zwordsize -> Int.testbit (hiword n) i = testbit n (i + Int.zwordsize).
Lemma bits_ofwords: forall hi lo i, 0 <= i < zwordsize -> testbit (ofwords hi lo) i = if zlt i Int.zwordsize then Int.testbit lo i else Int.testbit hi (i - Int.zwordsize).
Lemma lo_ofwords: forall hi lo, loword (ofwords hi lo) = lo.
Lemma hi_ofwords: forall hi lo, hiword (ofwords hi lo) = hi.
Lemma ofwords_recompose: forall n, ofwords (hiword n) (loword n) = n.
Lemma ofwords_add: forall lo hi, ofwords hi lo = repr (Int.unsigned hi * two_p 32 + Int.unsigned lo).
Lemma ofwords_add': forall lo hi, unsigned (ofwords hi lo) = Int.unsigned hi * two_p 32 + Int.unsigned lo.