Optimizing Data Allocation for Loops on Embedded Systems with Scratch-Pad Memory