modified for clang compatibility and change the ivar algorithm. Clang generated code revealed some bugs, and the assembly is MUCH easier to read than the inlined intel code.