Fix invalid LLVM IR from nested functions