Optimized ARM RWSEM algorithm(by @faux123)