#include <stdio.h>
short byte[20000];
int whichbyte=0;
void main(void)

{ 
  int i;
  int Constant_Pool_Count;
  int interface_count,fields_count,methods_count,attributes_count;

  void printf();
  int read_bytes(int);
  void print_bytes(int);
  void print_constants(int);
  void read_fields(int);
  void read_interfaces(int);
  void read_methods(int);
  void read_attributes(int);

    printf("--------------------------------------------------------------------\n");
    printf("**********magic**********\n");
    i=read_bytes(4);
    if (i==-1) exit(0);
    printf("%x %x %x %x\n",byte[0],byte[1],byte[2],byte[3]);
    printf("--------------------------------------------------------------------\n");

    printf("**********minor_version**********\n");
    i = read_bytes(2);
    if (i==-1) exit(0);
    print_bytes(2);
    printf("--------------------------------------------------------------------\n");
    printf("**********major_version**********\n");
    i = read_bytes(2);
    if (i==-1) exit(0);
    print_bytes(2);
    printf("--------------------------------------------------------------------\n");
    printf("**********Constant_Pool_Count**********\n");
    i = read_bytes(2);
    if (i==-1) exit(0);
    print_bytes(2);
    Constant_Pool_Count = byte[0] <<8 | byte[1];

    printf("Debug Debug*****%d\n", Constant_Pool_Count);

    print_constants(Constant_Pool_Count);
    printf("--------------------------------------------------------------------\n");


    printf("**********access_flags**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);
    printf("--------------------------------------------------------------------\n");

    printf("**********this_class**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);

    printf("--------------------------------------------------------------------\n");

    printf("**********super_class**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);

    printf("--------------------------------------------------------------------\n");

    printf("**********interfaces_count**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);
    interface_count=(byte[0]<<8)|byte[1];
    printf("numberof interfaces %d \n",interface_count);
    printf("--------------------------------------------------------------------\n");

    if (interface_count > 0)

	read_interfaces(interface_count);

    printf("--------------------------------------------------------------------\n");

    printf("**********fields_count**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);
    fields_count=(byte[0]<<8)|byte[1];
    printf("numberof fieldscount %d \n",fields_count);

    printf("--------------------------------------------------------------------\n");

    if (fields_count > 0)

	read_fields(fields_count);

    printf("--------------------------------------------------------------------\n");

    printf("**********methods_count**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);
    methods_count=(byte[0]<<8)|byte[1];
    printf("numberof fieldscount %d \n",methods_count);

    printf("--------------------------------------------------------------------\n");

    if (methods_count > 0)

	read_methods(methods_count);

    printf("--------------------------------------------------------------------\n");
    
    printf("**********attributes_count**********\n");
    i = read_bytes(2);
    if (i == -1) exit(0);
    print_bytes(2);
    attributes_count=(byte[0]<<8)|byte[1];
    printf("numberof attributescount %d \n",attributes_count);

    printf("--------------------------------------------------------------------\n");

    if (attributes_count > 0)

	read_attributes(attributes_count);

    printf("--------------------------------------------------------------------\n");



}


int read_bytes(int n)
{
  char i,j;
  int count = 0;
  short x1,x2,x;
 
  void printf();
  int scanf();
  short convert(char);

  /* Debug Statement start*/

  whichbyte = whichbyte+n;
  
  /* Debug Statement end */
  while (count < n)
    {
      if ((i=getc(stdin)) ==-1) 
      return(-1);
      while  ((i == '\n') ||(i == ' ')) 
	{
	  i = getc(stdin);
	}
      if (i == -1) 
     return(-1);
      if ((j=getc(stdin))==-1) return(-1);
      while  ((j == '\n') ||(j == ' ')) 
	{
	  j = getc(stdin);
	}
      if (j==-1) return(-1);

      /*      printf("%c %c\n",i,j); */

      x1 = convert(i);
      x2 = convert(j);

      x = x1<<4 | x2;
      byte[count] = x;
      
      count++;
    }
  return(0);
}

short convert(char ch)
{
  if (ch < 'a') return(ch -'0');
   else return(ch - 'a'+10);
}

void print_bytes(int n)
{
  void printf();

  int count=0;
  
  /*  printf(" Debug start&&&&&&&&\n");
  printf( "Which Byte :^^^^:-( %d\n",whichbyte);
  printf(" Debug End&&&&&&&&\n"); */
  while (count < n)
  {
    printf("%d ", byte[count]);
    count++;
  }
  printf("\n");
}



