/* Perform a "final reduction" in field F255 (field for Curve25519) The source value must be less than twice the modulus. If the value is not lower than the modulus, then the modulus is subtracted and this function returns 1; otherwise, it leaves it untouched and it returns 0.  */
static uint32_t reduce_final_f255(uint32_t *d)
/* Perform a "final reduction" in field F255 (field for Curve25519) The source value must be less than twice the modulus. If the value is not lower than the modulus, then the modulus is subtracted and this function returns 1; otherwise, it leaves it untouched and it returns 0.  */
static uint32_t reduce_final_f255(uint32_t *d)
{
	uint32_t t[9];
	uint32_t cc;
	int i;
	memcpy(t, d, sizeof t);
	cc = 19;
	for (i = 0; i < 9; i ++) {
		uint32_t w;
		w = t[i] + cc;
		cc = w >> 30;
		t[i] = w & 0x3FFFFFFF;
	}
	cc = t[8] >> 15;
	t[8] &= 0x7FFF;
	CCOPY(cc, d, t, sizeof t);
	return cc;
}