lastpos = msgstreamp -> tellg( );
lastpos = msgfile . tellg( );
int main (int argc, char ** argv){  Message_t msg;                           // the current message  istream * msgstreamp;                    // the message file stream  ifstream msgfile;                        // the message file, if applicable  IDMap_t typemap(1000);                   // NCode to index mapping  ID_t ti;                                 // current type index  NCode_t msgcode;                         // current message NCode  streampos lastpos;                       // last tellg pos  vector< pair<uint32_t,uint32_t> > sums (1);  // message count and size sums  uint64_t c1, c2;  //-- Parse the command line arguments  ParseArgs (argc, argv);    //-- BEGIN: MAIN EXCEPTION CATCH  try {  //-- Open the message file  if ( OPT_MessageName . empty( ) )    msgstreamp = &cin;  else    {      msgfile . open (OPT_MessageName . c_str( ));      if ( !msgfile )	AMOS_THROW_IO ("Could not open message file " + OPT_MessageName);      msgstreamp = &msgfile;    }  lastpos = msgstreamp -> tellg( );  //-- Parse the message file  while ( (msgcode = msg . skip (*msgstreamp)) )    {      if ( typemap . exists (msgcode) )	ti = typemap . lookup (msgcode);      else	{	  ti = sums . size( );	  typemap . insert (msgcode, ti);	  sums . push_back (pair<uint32_t, uint32_t> (0,0));	}      sums [ti] . first ++;      sums [ti] . second += msgstreamp -> tellg( ) - lastpos;      lastpos = msgstreamp -> tellg( );    }  typemap . invert( );  }  catch (Exception_t & e) {  //-- On error, print debugging information  cerr << "Last message: " << Decode (msgcode) << " eid:";  if ( msg . exists (F_EID) )    cerr << msg . getField (F_EID);  cerr << "\nERROR: -- Fatal AMOS Exception --\n" << e;  return EXIT_FAILURE;  }  //-- END: MAIN EXCEPTION CATCH  msgfile . close( );  printf ("%5s %9s %12s %12s\n", "NCODE", "COUNT", "SIZE", "AVG");  printf ("-----------------------------------------\n");  c1 = c2 = 0;  for ( ID_t i = 1; i < sums . size( ); i ++ )    {      msgcode = typemap . lookup (i);      printf ("%5s %9d %12d %12lld\n",	      Decode (msgcode) . c_str( ),	      sums [i] . first,	      sums [i] . second,	      SafeIntDiv (sums [i] . second, sums [i] . first));      c1 += sums [i] . first;      c2 += sums [i] . second;    }  printf ("-----------------------------------------\n");  printf ("      %9ld %12ld %12lld\n", (long)c1, (long)c2, SafeIntDiv (c2, c1));  return EXIT_SUCCESS;}