How to insert a self-written function to a piece of programme

Thanks for your reply! I send the message to the mail list this time~

Did you mean I need to initialize M and the Context? Is that really necessary? Does all the function need to be wrapped in the module? I remember you once said “you can just declare the function (i.e. no need to give it a body), and call it.You can then link with an object file that defines it. This is simpler than injecting the function into each module.”
I DEFINITELY GO FOR THE SIMPLER ONE! That is to say, I simply give the declaration and then the body of the function in C language(not in LLVM API), then I just use the CallInst to call that “check function”. Could you be kind and show me how exactly to define that “int check()” function and then “link it with an object file”? I really need your help!!!

Thank you!