Seems to be a bug on PC . Companion app works . <| sep |> EDIT I got it wrong . No , it seems that gcc doesn ' t optimize this away , my test was wrong . It works when the matrix sizes are specified at compile time which I did in the beginning but it turned out that this doesn ' t happen when the size of the matrix is not fixed . If it wasn ' t optimized , yes . But I thought the c o m p i l e r b ytecodetranslatorwhatever would optimize it so that counterclockwise rotation is equally fast ? I mean , this code doesn ' t look too complicated and considering what kind of awesome optimization I ' ve already seen done by compilers I would be surprised if the compiler wouldn ' t notice that he could just swap a few variables . EDIT I ' m a bit surprised that this optimization isn ' t already done with O 2 in gcc I ' ll have to look more into optimizations at some point I guess when O 3 is given the function calls are indeed optimised away as I expected and the functions are equally long .