#include <iostream>
#include <fstream>
 
using namespace std;

int
main()
{
   short 
   fun_size,
   name_size,
   entry_point,
   addr,addr0,addr1,
   code_size,
   size;
   char name[100];
   char code[10240];
   fstream in("hello16", ios::in | ios::binary);
   if(in) {
      in.read((char*)&fun_size, sizeof(short));
      cout << "fun_size == " << fun_size << endl;
      for(int i = 0; i < fun_size; i++) {
         in.read((char*)&name_size, sizeof(short));
         cout << "name_size == " << name_size << endl << flush;
         in.read(name, name_size);
         cout << "name == \"" << name << "\"" << endl << flush;
         in.read((char*)&entry_point, sizeof(short));
         in.read((char*)&addr, sizeof(short));
         in.read((char*)&size, sizeof(short));
         cout << "entry_point == " << hex << entry_point << endl << flush;
         cout << "addr == " << hex << addr << endl << flush;
         cout << "size == " << hex << size << endl << flush;

         for(int j = 0; j < size; j++) {
            in.read((char*)&addr0, sizeof(short));
            cout << "addr0 == " << hex << addr << endl;
         }
      }
      in.read((char*)&size, sizeof(short));
      for(int j = 0; j < size; j++) {
         in.read((char*)&addr0, sizeof(short));
         in.read((char*)&addr1, sizeof(short));
      }
      in.read((char*)&code_size, sizeof(short));
      in.read(code, code_size);
      in.close();
   }
   return 0;
}
