Hello
First of all I want to tell you that you are in contact with your friend form last 4 years and had sex 10 times ( unprotected ).
Since you are in relationship from 4 years , if your friend wound have been a patient of
HIV infection , this disease may have infected you and symptoms may have developed .
Now the answer of you question "Is a risk of getting HIV ".
HIV infection is predominantly a sexual transmitted disease worldwide. Although ~42%of new HIV infections are among men who have sex with men ( you are not an exception ) but both of you are old partner and know the status of each other so need not to worry.
Now about the ANAL INTERCOURSE & HIV risk.
There is a stron association of transmission of HIV with receptive anal intercourse,probably because only a thin , fragile rectal
mucous membrane separates the deposited semen from potentially susceptible cells in and beneath the mucosa and trauma may be associated with anal intercourse .
Anal douching and sexual practices that traumatize the rectal mucosa also increase the likelihood of infection.
Two ways of HIV infection:
1 Direct inoculation into blood in cases of traumatic tears int he mucosa
2 Infection of susceptible target cells, in the absence of trauma .
So this is the risk .
Read above mentioned and you will get your answer.