PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)