Mathematical analysis and optimal control interventions for sex structured syphilis model with three stages of infection and loss of immunity