Low-level Haskell: The cursed way to emulate inline assembly in Haskell/GHC, or how to return multiple values from a foreign function

This article is an English version of my earlier post “ 【低レベルHaskell】Haskell (GHC) でもインラインアセンブリに肉薄したい！ ” (in Japanese). The translation was assisted by AI (if you don’t like reading AI-generated content, please read the Japanese version!). Modern CPUs have many instructions specialized for particular purposes. Examples include SIMD, instructions useful for hashing and cryptography, and a variety…