Fixpoint intlist_to_bytelist (l: list int) : list byte :=
match l with
| nil => nil
| i::r =>
Byte.repr (Int.unsigned (Shr 24 i)) ::
Byte.repr (Int.unsigned (Shr 16 i)) ::
Byte.repr (Int.unsigned (Shr 8 i)) ::
Byte.repr (Int.unsigned i) ::
intlist_to_bytelist r
end.
Definition bytes_to_Int (a b c d : byte) : Int.int :=
Int.or (Int.or (Int.or
(Int.shl (Int.repr (Byte.unsigned a)) (Int.repr 24))
(Int.shl (Int.repr (Byte.unsigned b)) (Int.repr 16)))
(Int.shl (Int.repr (Byte.unsigned c)) (Int.repr 8)))
(Int.repr (Byte.unsigned d)).
Fixpoint bytelist_to_intlist (nl: list byte) : list int :=
match nl with
| h1::h2::h3::h4::t => bytes_to_Int h1 h2 h3 h4 :: bytelist_to_intlist t
| _ => nil
end.
Hint Rewrite Int.bits_or using omega : testbit.
Hint Rewrite Int.bits_shl using omega : testbit.
Hint Rewrite Int.bits_and using omega : testbit.
Hint Rewrite Int.bits_shru using omega : testbit.
Hint Rewrite Int.unsigned_repr using omega : testbit.
Hint Rewrite Int.testbit_repr using omega : testbit.
Hint Rewrite if_false using omega : testbit.
Hint Rewrite if_true using omega : testbit.
Hint Rewrite Z.ones_spec_low using omega : testbit.
Hint Rewrite Z.ones_spec_high using omega : testbit.
Hint Rewrite orb_false_r orb_true_r andb_false_r andb_true_r : testbit.
Hint Rewrite orb_false_l orb_true_l andb_false_l andb_true_l : testbit.
Hint Rewrite Z.add_simpl_r : testbit.
Hint Rewrite Int.unsigned_repr using rep_omega : testbit.
Hint Rewrite Byte.testbit_repr using rep_omega : testbit.
Hint Rewrite Byte.bits_above using rep_omega : testbit.

Lemma intlist_to_bytelist_to_intlist:
forall il: list int,
bytelist_to_intlist (intlist_to_bytelist il) = il.