#!/usr/bin/perl -X 
use component;
require 'systemhelper';
$| = 1;
$comp[0] = component->new(component => 'C2bin', comparg => '', statefile => 'C2bin.state');;
$comp[1] = component->new(component => 'C1bin', comparg => '', statefile => 'C1bin.state');;
L: while(1){
chop ($x = <STDIN>);
if ($x eq ".") {last L;}
@states = &loadStates(2);
$rt = 0;
$xs = $x;

      
      $comp[0]->run($x,$states[0]);
       $y = $comp[0]->getOutput; $rt += $comp[0]->getRuntime;
      
      $states[0] = $comp[0]->getState;
       
$x = $xs;
if ($y >= 0.5) {

      $comp = component->new(component => 'C3.bin', comparg => '', stateless => 1);
      $comp->run($x);
       $y = $comp->getOutput; $rt += $comp->getRuntime;
      
      
       
$x = $y;

      
      $comp[1]->run($x,$states[1]);
       $y = $comp[1]->getOutput; $rt += $comp[1]->getRuntime;
      
      $states[1] = $comp[1]->getState;
       
} else {

      $comp = component->new(component => 'C4.bin', comparg => '', stateless => 1);
      $comp->run($x);
       $y = $comp->getOutput; $rt += $comp->getRuntime;
      
      
       
}
OVER:
&saveStates( @states );
print "$y \n";
print STDERR "$rt\n";
}
