The cremaster and dartos muscles both work to regulate the temperature of the male testes, found in the scrotum, according to the General Practice Notebook. The cremaster muscle also functions to retract the testes to guard against injury.
The cremaster muscle covers the spermatic cord, which originates in the abdomen and extends to the scrotum, and testes. This muscle flexes, pulling the scrotum closer toward the body in cold temperatures to regulate the temperature of the testes, explains Healthline. When the testes are held close to the body by the cremaster, they are less exposed to cold air or water and receive heat from the body. The cremaster muscle also pulls the scrotum close to the body when a perceived danger is present. This action pulls the testes out of danger, protecting them from extreme pain, speculates Pacific Standard Magazine.
The dartos muscle has a similar function and lies within the wall of the scrotum, states the General Practice Notebook. This muscle also works to regulate the temperature of the scrotum. In cold temperatures the dartos muscle contracts the skin of the scrotum, creating wrinkles. This action reduces the surface area of the scrotum, reducing the heat lost through the skin.