You should try your program by hand, with a pen and paper, using two simple numbers, and see what happens. Then you will see why it does not give what you want it to give.
For example:
x=4, y=2
go in 3rd if
x=0 now
call GDC(2,0)
go to 2nd if
print as in 2nd if
return
print as in 3rd if...