imul function
Calculates the C-like 32-bit multiplication of the two parameters
Implementation
@pragma('vm:prefer-inline')
int imul(int a, int b) {
final aHi = (a >>> 16) & 0xffff;
final aLo = a & 0xffff;
final bHi = (b >>> 16) & 0xffff;
final bLo = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((aLo * bLo) + (((aHi * bLo + aLo * bHi) << 16) >>> 0)).toSigned(32);
}