ir: Add buildVarStatSmart for inserting variables into functions
semantic: Fix length in array copy
test: Add array copy length bug