(** ** Size of a type *)
(** In the ISO C standard, size is defined only for complete types.  However, it is convenient that [sizeof] is a total function.  For [void] and function types, we follow GCC and define their size to be 1.  For undefined structures and unions, the size is arbitrarily taken to be 0. *)
Fixpoint sizeof (env: composite_env) (t: type) : Z :=
match t with
| Tvoid => 1
| Tint I8 _ _ => 1
| Tint I16 _ _ => 2
| Tint I32 _ _ => 4
| Tint IBool _ _ => 1
| Tlong _ _ => 8
| Tfloat F32 _ => 4
| Tfloat F64 _ => 8
| Tpointer _ _ => if Archi.ptr64 then 8 else 4
| Tarray t' n _ => sizeof env t' * Z.max 0 n
| Tfunction _ _ _ => 1
| Tstruct id _ | Tunion id _ =>
match env!id with Some co => co_sizeof co | None => 0 end
end.

(* Specifications: *)
Lemma sizeof_pos:
forall env t, sizeof env t >= 0.
Lemma sizeof_pos:
forall env t, sizeof env t >= 0.