I don’t necessarily think this was something out of line - I have had Dr’s check for genital abnormalities with similar testing. She was probably checking for lumps in the testicles, which could be malignant, possibly also checking the penis for anything that seemed out of order. When she had you stand, turn to the side & cough while feeling the pubic area, she was checking for a possible hernia. Sounds to me like she didn’t do anything unprofessional & was doing a thorough physical - she didn’t want to miss something that could turn out to be important. Did she also perform a digital rectal exam (DRE) for possible prostate issues? That could be either benign enlargement (BPH) or of course if a hard nodule was found, that could be potentially more serious, e.g. prostate cancer. Dr’s usually start checking that once you hit your 40s, altho right at 40, maybe not. Anyway, I wouldn’t be concerned about any of this - you should thank her for being thorough!