refactor rarch_main_clear_state