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 gcdGI_recE m n x y : ('N y <= m)%N -> ('N y <= n)%N
-> ('N y < 'N x)%N -> gcdGI_rec m x y = gcdGI_rec n x y.