As soon as your eyes adjust to the density, I think this is actually quite legible. There are sensible names, and the formatting and arrangement serve to show the regularity of operations.
This is a style of programming in c, relying heavily on the preprocessor. It is usually used by all array languages modeled on the style used by Arthur whitney.
It’s hard for me and you to read and understand this, but more talented programmers like John and Arthur and others use it daily.
So, it’s not a mess at all, but very condensed code.
Here, I inserted a subtle bug in this function, can you find it?