Optimized ARM RWSEM algorithm - Thanks to faux123