Optimized redgem generation + max sprintlegs in C