.text
.globl f

f:
	#this is a reimplementation of GCD that originally uses recursion, but
	#we make tail calls instead of actual calls.
	mov %edi,%ebx
	mov %esi,%eax
	
_repeat:
	# I have errorneously used TEST here which actually does bitwise-AND
	# comparison. CMP is the right instruction. :]
	cmp %eax, %ebx
	je _quit

	cmp %eax, %ebx # arguments of CMP in GNU-as syntax are swapped
	               # in a rather counterintuitive way.
	jg _b_greater # so this means ebx>eax...

	sub %ebx, %eax
	jmp _repeat
	
_b_greater:
	sub %eax, %ebx
	jmp _repeat

_quit:
	retq
