Automatic Co-Synthesis Of Hardware And Software Safety Monitors For Embedded Systems