#if 0
/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss or reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#include <nanu-nanu.h>

/** @addtogroup nanu */
/** @{ */

/**
*	Greatest common divisor.
*
*	This function finds the greatest common divisor of the top two
*	elements on the stack. The elements are then discarded and the
*	GCD is pushed onto the stack. If the two numbers are relative
*	primes (coprimes), then the result is 1.
*
*	@param	nanu			The natural number machine state descriptor
*
*	@retval	BC_NANU_NANU	The operation succeeded
*	@retval	BC_NANU_SUND	There were less that 2 elements on the stack
*	@retval	BC_NANU_NANN	One of the operands was 0.
*	@retval	BC_NANU_OMEM	There's not enough memory in the pool to store
*							the result.
*
*	@par Stack image
*		a b ...  ==> GCD(a,b) ...
*/

int		BC_NanuRmul( BC_NANU nanu )
{
int		x, y, t, s, g;

	// We use the binary GCD algorithm. It is slower than the extended
	// binary GCD or the Lehmer algorithm, but it has the advantage that
	// it requires no extra storage and it uses only simple add-shift
	// operations.


	// x y



	t = BC_NanuComp( nanu, BC_NANU_LT );

	if ( t < 0 ) return( t );
	if ( t > 0 ) BC_NanuSwap( nanu );

	x = nanu->nanu[ --nanu->sptr ].vref;
	y = nanu->nanu[ --nanu->sptr ].vref;
	p = _bc_NanuVarPtr( nanu, x );
	q = _bc_NanuVarPtr( nanu, y );

	g = 0;

	if ( _bc_NanuVarLen( nanu, x ) == 1 && ! *p )

		return( _bc_NanuError( BC_NANU_NANN ) );



}


#endif

