Fixpoint gcdGI_rec (n : nat) (xx  yy : GI) {struct n} :=
let rr := modGI xx yy in
if rr == 0 then yy else
if n is n1.+1 then gcdGI_rec n1 yy rr else rr.
Definition gcdGI x y :=
let: (x1, y1) := if ('N x < 'N y)%N then (y, x) else (x, y) in
if x1 == 0 then y1 else
gcdGI_rec ('N x1) x1 y1.

Lemma dvdGI_gcdlr x y : (gcdGI x y %| x) && (gcdGI x y %| y).