Some library calls expect length argument which has pointer sized integer type. However we may create such calls with the actual length parameter typed with the different integer type. For such cases we need to emit correct cast instead of crashing with the assertion failure.
I believe it's hard to encounter in the real world practice but this comes up in the llvm-opt-fuzzer testing.