Just a couple of things - no point in initialising the automatic variables "from" "to" and "temp" - they're going to get assigned anyway.
Maybe make them "byte".
You're probably spending a fair amount of time in "random" - look at a simpler/faster homebrew "random".