#include "utilities.h"

#include <string.h>

bool kissat_has_suffix (const char *str, const char *suffix) {
  const char *p = str;
  while (*p)
    p++;
  const char *q = suffix;
  while (*q)
    q++;
  while (p > str && q > suffix)
    if (*--p != *--q)
      return false;
  return q == suffix;
}

double kissat_effectiveness_scale (double average, double low_threshold,
                                   double high_threshold,
                                   double backoff_factor,
                                   double aggressive_factor) {
  if (average <= 0)
    return 1.0;
  if (low_threshold <= 0 && high_threshold <= 0)
    return 1.0;
  double scale = 1.0;
  if (low_threshold > 0 && average < low_threshold)
    scale = backoff_factor;
  else if (high_threshold > 0 && average > high_threshold)
    scale = aggressive_factor;
  return scale;
}
