#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef struct {
  unsigned int used : 1;
  unsigned int weight :7;
} count_t;

typedef struct {
  unsigned short lChild;
  unsigned short rChild;
  unsigned long weight;
  unsigned int used :1;
} parentnode_t;

typedef struct {
  unsigned long code;
  unsigned short length; 
} table_entry_t;

static unsigned char inBitBuffer;
static unsigned char inBitCount=0;

static unsigned char numOutBits=0;  //number of bits in output buffer
static unsigned long outBitBuffer=0;//buffer for bits to be output
count_t counter[256];
long    bigcounter[256];

parentnode_t parent[256];
short minUnusedParent;

table_entry_t table[256];
