Since we're using -Os, we can manually inline to get huge speedups. For example, inlining these three functions gives a ~3x speedup. Even so, matrix multiplication is on the order of 0.2% of the total runtime.