(** Definitions of some environments **)
Definition empty_genv cenv := Build_genv (Globalenvs.Genv.empty_genv fundef type nil) cenv.Definition empty_tenv := PTree.empty val.Definition empty_environ cenv : environ :=
mkEnviron (filter_genv (empty_genv cenv)) (Map.empty _) (Map.empty _).

Lemma isCastR: forall {CS: compspecs} tfrom tto a, denote_tc_assert (isCastResultType tfrom tto a) = denote_tc_assert match classify_cast tfrom tto with | Cop.cast_case_default => tc_FF (invalid_cast tfrom tto) | Cop.cast_case_f2i _ Signed => tc_andp (tc_Zge a Int.min_signed ) (tc_Zle a Int.max_signed) | Cop.cast_case_s2i _ Signed => tc_andp (tc_Zge a Int.min_signed ) (tc_Zle a Int.max_signed) | Cop.cast_case_f2i _ Unsigned => tc_andp (tc_Zge a 0) (tc_Zle a Int.max_unsigned) | Cop.cast_case_s2i _ Unsigned => tc_andp (tc_Zge a 0) (tc_Zle a Int.max_unsigned) | Cop.cast_case_i2l _ => tc_andp (tc_bool (is_int_type tfrom) (invalid_cast_result tfrom tto)) (if is_pointer_type tto then tc_iszero a else tc_TT) | Cop.cast_case_l2i _ _ => tc_andp (tc_bool (is_long_type tfrom) (invalid_cast_result tfrom tto)) (if is_pointer_type tto then tc_iszero a else tc_TT) | Cop.cast_case_pointer => if eqb_type tfrom tto then tc_TT else if orb (andb (is_pointer_type tto) (is_pointer_type tfrom)) (if Archi.ptr64 then (andb (is_long_type tto) (is_long_type tfrom)) else (andb (is_int_type tto) (is_int_type tfrom))) then tc_TT else if (andb (eqb_type tto int_or_ptr_type) ((if Archi.ptr64 then is_long_type else is_int_type) tfrom)) then tc_TT else if (andb (eqb_type tto int_or_ptr_type) (is_pointer_type tfrom)) then tc_TT else if (andb (eqb_type tfrom int_or_ptr_type) (is_pointer_type tto)) then tc_isptr a else if (andb (eqb_type tfrom int_or_ptr_type) ((if Archi.ptr64 then is_long_type else is_int_type) tto)) then (if Archi.ptr64 then tc_islong else tc_isint) a else tc_iszero a | Cop.cast_case_l2l => tc_bool (is_long_type tfrom && is_long_type tto) (invalid_cast_result tto tto) | Cop.cast_case_f2bool => tc_bool (is_float_type tfrom) (invalid_cast_result tfrom tto) | Cop.cast_case_s2bool => tc_bool (is_single_type tfrom) (invalid_cast_result tfrom tto) | Cop.cast_case_l2bool => if is_pointer_type tfrom then tc_test_eq a (Econst_long Int64.zero (Tlong Unsigned noattr)) else tc_TT | Cop.cast_case_i2bool => if is_pointer_type tfrom then tc_test_eq a (Econst_int Int.zero (Tint I32 Unsigned noattr)) else tc_TT | Cop.cast_case_void => tc_noproof | _ => match tto with | Tint _ _ _ => tc_bool (is_int_type tfrom) (invalid_cast_result tto tto) | Tfloat F64 _ => tc_bool (is_anyfloat_type tfrom) (invalid_cast_result tto tto) | Tfloat F32 _ => tc_bool (is_anyfloat_type tfrom) (invalid_cast_result tto tto) | _ => tc_FF (invalid_cast tfrom tto) end end.