#!/bin/bash

if [ $# -ne 2 ] 
then
    echo "usage: ./run.sh BENCHMARK TMPDIR" 
    exit 1
fi

TMPDIR=$2
REVIVAL=./revival
MINISAT=./minisat  

TMP=bench
TMP_1=${TMPDIR}/bench.viv.cnf

echo -n "c revival is preprocessing the formula..."
$REVIVAL $1 500 > $TMP_1 #&> /dev/null
echo "done !"

echo "c Calling MINISAT"
$MINISAT $TMP_1 ${TMPDIR}/$TMP.result "$@"
X=$?
if [ $X == 20 ]; then
    echo "s UNSATISFIABLE"
    exit 20
elif [ $X == 10 ]; then
    echo "s SATISFIABLE"
    echo -n "v "
    cat ${TMPDIR}/$TMP.result | tail -1 
    exit 10
else
    echo "c ERROR !"
fi
exit $X
