import re


def process_cmd(keyword, cmd, opts, enable):
  """ Process the compile and simulation command

  Args:
    keyword : Keyword to search
    cmd     : Command to be processed
    opts    : Options to replace the keyword
    enable  : Option enable/disable

  Returns:
    Processed command
  """
  if enable == "1":
    return re.sub(keyword, opts.rstrip(), cmd)
  else:
    return re.sub(keyword, "", cmd)