C/C++ Clang error in optimization


I tried to compile this http://lolengine.net/wiki/oss/lolremez with clang, but using any optimization causes the program to behave in a very strange way and gives numerically erroneous results.
Compile without optimization produces a very slow binary, so I have to compile using g++48 to use optimization.

I tried compile with various versions of clang on FreeBSD and Debian.

What is causing this?

Thanks in advance.