Hi,
Welcome to health care magic,
As per your facts that you have posted here,it appears that you have problem of getting hard erection while attempting to have sex and pain over anal region with testis.
This is kind of problems are often due psychological or mind related and due to performance anxiety.
Below listed measures will help you to boost up your confidence and getting good erection and have enjoyable sex.
1) Do regular exercises for about 30 minutes followed by
meditation for 1/2 an hour in the morning.
2) Take high protein diet rich in vegetables and fruits and
Vitamin A,C,D,E.and Zinc
3)Take anti oxidants like Almonds 5-6 everyday..
4) Avoid alcohol and smoking..
In addition to above,you will also need to rule out certain medical causes,
like diabetes, hormonal problems, blood flow problems, vitamin deficiencies, etc.)
For
anal pain and
testicular pain you can take over the counter pain killers but before that you need to be further evaluated by some blood works and
ultrasound of local part.
So,better to consult general physician for complete treatment.
Regards,