I finally wrote a working implementation of the Graham scan algorithm that is not so slow. You can read it here. It turned out that my previous rant was wrong. The “loop” part can indeed run in O(n), and the complexity is that of the sort. I however have a sound excuse : the Wikipedia complexity analysis is wrong.
So it now runs in a way that is not horribly slow, and should be easier to read :
$ time ./graham2 < points.dat > /tmp/solution
real 0m43.122s user 0m42.840s sys 0m0.190s