When I attempt to compile my program, my program crashes. I'm pretty sure the shuffle_array function causes it to crash. When I delete the function and run the program, it compiles just fine and gives me an output. Just need a point in the right direction.
I've not the time to read it, but memory leaks don't cause crashes that easily, they are more something that uses resources while you're not aware of. Most of the times when you have a memory leak you won't even know it unless your program runs for hours and hours and you find out that ram usage actually inreased more than it should have had.
On lines 50ish, you seem to make your program access random indexes of an array, even if they may be out of bounds. That's quite dangerous and will cause leaks.