def xgcd(a, b):
	"""
	Performs the Extended Euclidean algorithm to return the result of Bézout's 
	identity. 

	Arguments:
		a (:int) - the first integer
		b (:int) - the second integer

	Returns:
		'r' such that ar + bs = d where d = gcd(a, b)
	"""
	r, s = 0, 1
	while b != 0:
		c, d = divmod(a, b)
		r, s = s, r - c*s
		a, b = b, d
	return r