begin writing llvm ir code for the apply function