There is a distinction between running this on wasm and i686, even though they should be identical. This technically is not _incorrect_, it's just an unexpected difference, which is worth investigating, but not for correctness.
Instead of storing an extra array for discriminant values, create an allocation there and store those in an allocation immediately.