Open Scope Z.
(* Note: x must be non-zero, y is allowed to be zero (because x is a constant in all usages, its non-zero-check seems to be removed by the parser). *)
Definition mul_with_table(x y: Z)(pow: list int)(log: list Z): int :=
if Int.eq (if Int.eq (Int.repr y) Int.zero then Int.zero else Int.one) Int.zero
then Int.zero
else Znth (Int.unsigned
(Int.mods (Int.repr (Znth x log + Znth y log))
(Int.repr 255))) pow.
Definition Z_to_val(x: Z): val := if zeq x (-1) then Vundef else Vint (Int.repr x).
(* Calls forward_if with the current precondition to which the provided conditions are added *)
(* QQQ TODO does this already exist? Add to library? *)
Ltac forward_if_diff add := match add with
| (PROPx ?P2 (LOCALx ?Q2 (SEPx ?R2))) => match goal with
| |- semax ?Delta (PROPx ?P1 (LOCALx ?Q1 (SEPx ?R1))) _ _ =>
let P3 := fresh "P3" in let Q3 := fresh "Q3" in let R3 := fresh "R3" in
pose (P3 := P1 ++ P2); pose (Q3 := Q1 ++ Q2); pose (R3 := R1 ++ R2);
simpl in P3, Q3, R3;
forward_if (PROPx P3 (LOCALx Q3 (SEPx R3)));
subst P3 Q3 R3
end
end.

(* TODO floyd this lemma should be invoked by entailer! Note: in summaray, this already works for data_at, but why doesn't it work for field_at? QQQ: And why/how does it work for data_at? *)
Lemma field_at_update_val: forall sh t gfs v v' p,
v = v' -> field_at sh t gfs v p |-- field_at sh t gfs v' p.