add -r=COUNT argument to run-tests.py

this runs the tests multiple times.
fix segfaults when using gcc 4.8 on amd64/x86 unix

I'm just porting the aarch64 stuff committed recently.