Towards Secure and Safe AI-enabled Systems Through Optimizations