Definition Zfast_div_eucl (a b : Z) :=
match a with
| Z0 => (0, 0)%Z
| Zpos a' =>
match b with
| Z0 => (0, 0)%Z
| Zpos b' => Zpos_div_eucl_aux a' b'
| Zneg b' =>
let (q, r) := Zpos_div_eucl_aux a' b' in
match r with
| Z0 => (-q, 0)%Z
| Zpos _ => (-(q + 1), (b + r))%Z
| Zneg _ => (-(q + 1), (b + r))%Z
end
end
| Zneg a' =>
match b with
| Z0 => (0, 0)%Z
| Zpos b' =>
let (q, r) := Zpos_div_eucl_aux a' b' in
match r with
| Z0 => (-q, 0)%Z
| Zpos _ => (-(q + 1), (b - r))%Z
| Zneg _ => (-(q + 1), (b - r))%Z
end
| Zneg b' => let (q, r) := Zpos_div_eucl_aux a' b' in (q, (-r)%Z)
end
end.

(* Specifications: *)
Theorem Zfast_div_eucl_correct :
forall a b : Z,
Zfast_div_eucl a b = Zdiv_eucl a b.