There's a corner case when imm is -2147483648, that's -2^31 and 0x80000000 in two's compliment.
SignExt this value then take it's negative, it's still 0x80000000 and interpreted as -2^31 by i32 type.
So we have infinite loop here where this function consume and produce this number forever.
"-(1<<31)" is undefined behavior, strictly speaking. There are a few different ways you could write it, but the simplest is "INT32_MIN".