      ;; int main( int argc, char * argv[] ){
main:	
      ;;     int x,y;         x in r1, y in r2

      ;;     scanf( "%d", &x );
      swi      #SysGetNum
      mov      r1,r0

      ;;     scanf( "%d", &y );      
      swi      #SysGetNum
      mov      r2,r0

      ;;     print( "%d", gcd( x, y ) );
      bl       gcd
      swi      #SysPutNum

      ;; }
      swi      #SysHalt


      ;; int gcd( int a, int b) {
      ;;        a in r1, b in r2
      ;;        lr saved at offset 0 in 1 word stack frame
gcd:      
      sub      sp,sp,#1
      str      lr, [sp, #0]

      ;;     if ( a == 0 ) return b;
      cmp      r1,#0
      bne      else1
      mov      r0,r2
      b        return

      ;;     if ( a > b ) return gcd( b, a);
else1:      cmp      r1,r2
      ble      else2
      mov      r0,r2
      mov      r2,r1
      mov      r1,r0
      bl       gcd
      b        return

      ;;     return gcd( a, b-a );
else2:  sub   r2,r2,r1
      bl      gcd
      
return:
      add     sp,sp,#1
      ldr     pc,[sp, #-1]