Currently this code is very hard to manage:
- variables defined in the beginning of the function might be used several screens later
- Code for adding checks isn't uniform enough (some use Instruction::Create, others use IRBuilder)
- Code for adding one check is tangled with code for adding next check, because we split basic block only at that time.
I tried to fix this issues, and hopefully that improves the code readability.
You've removed the check for the icmp. Why?