#!/usr/bin/perl

# Usage: exsize <mapping-size-lower-bound> <mapping-size-upper-bound>
#               [ <regular-expression> ]
#   The files OUTPUT and num-nodes-STATS must be present.
#
# Output (on stdout): all clone pairs in OUTPUT whose clone sizes are in the range
#   [mapping-size-lower-bound .. mapping-size-upper-bound] and which satisfy
#   regular-expression.

open (NUM_NODES, "num-nodes-STATS") or die "Unable to open num-nodes-STATS!";
open (OUTPUT, "OUTPUT") or die "Unable to open OUTPUT!";

if ($#ARGV == 2) {
	while(defined($numNodes = <NUM_NODES>) && 
		  defined($outputLine = <OUTPUT>)) {
		print $outputLine 
			if (($numNodes >= $ARGV[0]) && ($numNodes <= $ARGV[1]) &&
				($outputLine =~ /$ARGV[2]/));
	}
}
else {
	while(defined($numNodes = <NUM_NODES>) && 
		  defined($outputLine = <OUTPUT>)) {
		print $outputLine 
			if (($numNodes >= $ARGV[0]) && ($numNodes <= $ARGV[1]));
	}
}
