

#include "include/cudd.h"
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>


int main( int argc, char * argv[] )
{
	int					specVec1[3] = { 0, 1, 2};
	int					specVec2[3] = { 0, 0, 0};
	DdManager *			dd;
	FILE *				fp;
	BddArray *			arr;
	int					i, ret;
	struct _timeb time1, time2;
	int           timer;

	if ( argc != 2 ) {
		printf("Invalid programm call !");
		getc(stdin);
		return 0;
	}

	dd = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
	if ( dd == NULL )
		return 1;

	fp = fopen(argv[1], "r");
	if ( !fp ) {
		printf("Unable to open pla: %s !", argv[1]);
		getc(stdin);
		Cudd_Quit( dd );
		return 0;
	}
	
	_ftime( &time1 );
	arr = Cudd_plaLoad( dd, fp, specVec1, specVec2 );
	_ftime( &time2 );

	timer = (int)( 1000 * (time2.time - time1.time) + (time2.millitm - time1.millitm) );
	printf( "Loaded in %d milliseconds !", timer );

	fclose( fp );
	if ( arr ) {
		if ( arr->roots ) {
			for ( i = 0; i < arr->outputs; i++ )
				Cudd_RecursiveDeref( dd, arr->roots[i] );
			free( arr->roots );
		}
		if ( arr->roots2 ) {
			for ( i = 0; i < arr->outputs; i++ )
				Cudd_RecursiveDeref( dd, arr->roots2[i] );
			free( arr->roots2 );
		}
		free( arr );
	}
	Cudd_Quit( dd );
	return 0;
}

