2typedef unsigned short UINT16;
 
    3typedef unsigned char BYTE;
 
    4static UINT16 HuffCodeLOM[] = { 0x0001, 0x0000, 0x0002, 0x0009, 0x0006, 0x0005, 0x000d, 0x000b,
 
    5                              0x0003, 0x001b, 0x0007, 0x0017, 0x0037, 0x000f, 0x004f, 0x006f,
 
    6                              0x002f, 0x00ef, 0x001f, 0x005f, 0x015f, 0x009f, 0x00df, 0x01df,
 
    7                              0x003f, 0x013f, 0x00bf, 0x01bf, 0x007f, 0x017f, 0x00ff, 0x01ff };
 
    9UINT16 HashTable[32] = { [0 ... 31] = 0xffff };
 
   11BYTE tab[4] = { 0, 4, 10, 19 };
 
   13UINT16 hash(UINT16 key)
 
   15  return ((key & 0x1f) ^ (key >> 5) ^ (key >> 9));
 
   18BYTE minihash(UINT16 key)
 
   22  return ((h ^ (h >> 2) ^ (h >> 3)) & 0x3);
 
   25void buildhashtable(
void)
 
   27  for (
int i = 0; i < 32; i++)
 
   29    UINT16 h = hash(HuffCodeLOM[i]);
 
   31    if (HashTable[h] != 0xffff)
 
   33      HashTable[h] ^= (HuffCodeLOM[i] & 0xfe0) ^ 0xfe0;
 
   34      HashTable[tab[minihash(HuffCodeLOM[i])]] = i;
 
   39      HashTable[h] ^= 0xfe0;
 
   42    printf(
"at %d %" PRIu16 
"=0x%" PRIx16 
"\n", i, h, HashTable[h]);
 
   46BYTE getvalue(UINT16 huff)
 
   48  UINT16 h = HashTable[hash(huff)];
 
   55    return HashTable[tab[minihash(huff)]];
 
   61  printf(
"static UINT16 HuffIndexLOM[32] = {\n");
 
   63  for (
int i = 0; i < 32; i++)
 
   66      printf(
"0x%" PRIx16 
" };\n", HashTable[i]);
 
   68      printf(
"0x%" PRIx16 
", ", HashTable[i]);
 
   71  for (
int i = 0; i < 32; i++)
 
   72    if (i != getvalue(HuffCodeLOM[i]))
 
   73      printf(
"Fail :( at %d : 0x%04" PRIx16 
" got %" PRIu8 
"\n", i, HuffCodeLOM[i],
 
   74             getvalue(HuffCodeLOM[i]));