build_hash_table (const sparc_opcode **opcode_table,

                  sparc_opcode_hash **hash_table,

                  int num_opcodes)

{

  int i;

  int hash_count[HASH_SIZE];

  static sparc_opcode_hash *hash_buf = NULL;



  /* Start at the end of the table and work backwards so that each

     chain is sorted.  */



  memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));

  memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));

  if (hash_buf != NULL)

    free (hash_buf);

  hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);

  for (i = num_opcodes - 1; i >= 0; --i)

    {

      int hash = HASH_INSN (opcode_table[i]->match);

      sparc_opcode_hash *h = &hash_buf[i];



      h->next = hash_table[hash];

      h->opcode = opcode_table[i];

      hash_table[hash] = h;

      ++hash_count[hash];

    }



#if 0 /* for debugging */

  {

    int min_count = num_opcodes, max_count = 0;

    int total;



    for (i = 0; i < HASH_SIZE; ++i)

      {

        if (hash_count[i] < min_count)

          min_count = hash_count[i];

        if (hash_count[i] > max_count)

          max_count = hash_count[i];

        total += hash_count[i];

      }



    printf ("Opcode hash table stats: min %d, max %d, ave %f\n",

            min_count, max_count, (double) total / HASH_SIZE);

  }

#endif

}

build_hash_table (const sparc_opcode **opcode_table,

                  sparc_opcode_hash **hash_table,

                  int num_opcodes)

{

  int i;

  int hash_count[HASH_SIZE];

  static sparc_opcode_hash *hash_buf = NULL;



  





  memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));

  memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));

  if (hash_buf != NULL)

    free (hash_buf);

  hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);

  for (i = num_opcodes - 1; i >= 0; --i)

    {

      int hash = HASH_INSN (opcode_table[i]->match);

      sparc_opcode_hash *h = &hash_buf[i];



      h->next = hash_table[hash];

      h->opcode = opcode_table[i];

      hash_table[hash] = h;

      ++hash_count[hash];

    }



#if 0 

  {

    int min_count = num_opcodes, max_count = 0;

    int total;



    for (i = 0; i < HASH_SIZE; ++i)

      {

        if (hash_count[i] < min_count)

          min_count = hash_count[i];

        if (hash_count[i] > max_count)

          max_count = hash_count[i];

        total += hash_count[i];

      }



    printf ("Opcode hash table stats: min %d, max %d, ave %f\n",

            min_count, max_count, (double) total / HASH_SIZE);

  }

#endif

}

FUNC_0 (const sparc_opcode **VAR_0,

                  sparc_opcode_hash **VAR_1,

                  int VAR_2)

{

  int VAR_3;

  int VAR_4[HASH_SIZE];

  static sparc_opcode_hash *VAR_5 = NULL;



  





  memset (VAR_1, 0, HASH_SIZE * sizeof (VAR_1[0]));

  memset (VAR_4, 0, HASH_SIZE * sizeof (VAR_4[0]));

  if (VAR_5 != NULL)

    free (VAR_5);

  VAR_5 = malloc (sizeof (* VAR_5) * VAR_2);

  for (VAR_3 = VAR_2 - 1; VAR_3 >= 0; --VAR_3)

    {

      int VAR_6 = HASH_INSN (VAR_0[VAR_3]->match);

      sparc_opcode_hash *h = &VAR_5[VAR_3];



      h->next = VAR_1[VAR_6];

      h->opcode = VAR_0[VAR_3];

      VAR_1[VAR_6] = h;

      ++VAR_4[VAR_6];

    }



#if 0 

  {

    int min_count = VAR_2, max_count = 0;

    int total;



    for (VAR_3 = 0; VAR_3 < HASH_SIZE; ++VAR_3)

      {

        if (VAR_4[VAR_3] < min_count)

          min_count = VAR_4[VAR_3];

        if (VAR_4[VAR_3] > max_count)

          max_count = VAR_4[VAR_3];

        total += VAR_4[VAR_3];

      }



    printf ("Opcode VAR_6 table stats: min %d, max %d, ave %f\n",

            min_count, max_count, (double) total / HASH_SIZE);

  }

#endif

}

FUNC_0 (const sparc_opcode **VAR_0,
sparc_opcode_hash **VAR_1,
int VAR_2)
{ int VAR_3; int VAR_4[HASH_SIZE]; static sparc_opcode_hash *VAR_5 = NULL; memset (VAR_1, 0, HASH_SIZE * sizeof (VAR_1[0])); memset (VAR_4, 0, HASH_SIZE * sizeof (VAR_4[0])); if (VAR_5 != NULL)
free (VAR_5); VAR_5 = malloc (sizeof (* VAR_5) * VAR_2); for (VAR_3 = VAR_2 - 1; VAR_3 >= 0; --VAR_3) { int VAR_6 = HASH_INSN (VAR_0[VAR_3]->match); sparc_opcode_hash *h = &VAR_5[VAR_3]; h->next = VAR_1[VAR_6]; h->opcode = VAR_0[VAR_3]; VAR_1[VAR_6] = h; ++VAR_4[VAR_6]; } #if 0
{ int min_count = VAR_2, max_count = 0; int total; for (VAR_3 = 0; VAR_3 < HASH_SIZE; ++VAR_3) { if (VAR_4[VAR_3] < min_count)
min_count = VAR_4[VAR_3]; if (VAR_4[VAR_3] > max_count)
max_count = VAR_4[VAR_3]; total += VAR_4[VAR_3]; } printf ("Opcode VAR_6 table stats: min %d, max %d, ave %f\n",
min_count, max_count, (double) total / HASH_SIZE); } #endif
}