make sure we init type/entity module on every created ir_prog
Added local optimization: a * (b & 1) -> a & -(b & 1).
Simplified code.
Added local optimizations.

- Mux((a & 1) != 0, 0, b) => -a & b
- Mux((a & 1) == 0, 0, b) => (a - 1) & b