unsigned int
rotate_left(unsigned int value, int bitstorotate)
{
	unsigned int tmprslt, target;
	int mask;

	/* determine which bits will be impacted by the rotate */
	if (bitstorotate == 0)
		mask = 0;
	else
		mask = (int)0x80000000 >> bitstorotate;
		
	/* save off the affected bits */
	tmprslt = value & mask;
		
	/* perform the actual rotate */
	target = value << bitstorotate;
		
	/* now shift the saved off bits */
	tmprslt >>= 32 - bitstorotate;
		
	/* add the rotated bits back in (in the proper location) */
	target |= tmprslt;

	/* now return the result */
	return target;
}

main()
{
	int i;
	for (i = 0; i < 16; i++)
		printf("%d %x\n", i, rotate_left(1, i));
	printf("\n");
	for (i = 0; i < 32; i++)
		printf("%d %x\n", i, rotate_left(0x1000, i));
}

