/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*************************************************************************/
/*                                                                       */
/*   SNU-RT Benchmark Suite for Worst Case Timing Analysis               */
/*   =====================================================               */
/*                              Collected and Modified by S.-S. Lim      */
/*                                           sslim@archi.snu.ac.kr       */
/*                                         Real-Time Research Group      */
/*                                        Seoul National University      */
/*                                                                       */
/*                                                                       */
/*        < Features > - restrictions for our experimental environment   */
/*                                                                       */
/*          1. Completely structured.                                    */
/*               - There are no unconditional jumps.                     */
/*               - There are no exit from loop bodies.                   */
/*                 (There are no 'break' or 'return' in loop bodies)     */
/*          2. No 'switch' statements.                                   */
/*          3. No 'do..while' statements.                                */
/*          4. Expressions are restricted.                               */
/*               - There are no multiple expressions joined by 'or',     */
/*                'and' operations.                                      */
/*          5. No library calls.                                         */
/*               - All the functions needed are implemented in the       */
/*                 source file.                                          */
/*                                                                       */
/*                                                                       */
/*************************************************************************/
/*                                                                       */
/*  FILE: adpcm.c                                                        */
/*  SOURCE : C Algorithms for Real-Time DSP by P. M. Embree              */
/*                                                                       */
/*  DESCRIPTION :                                                        */
/*                                                                       */
/*     CCITT G.722 ADPCM (Adaptive Differential Pulse Code Modulation)   */
/*     algorithm.                                                        */
/*     16khz sample rate data is stored in the array test_data[SIZE].    */
/*     Results are stored in the array compressed[SIZE] and result[SIZE].*/
/*     Execution time is determined by the constant SIZE (default value  */
/*     is 2000).                                                         */
/*                                                                       */
/*  REMARK :                                                             */
/*                                                                       */
/*  EXECUTION TIME :                                                     */
/*                                                                       */
/*                                                                       */
/*************************************************************************/
#include <stdio.h>

int encode (int, int);
void decode (int);
int filtez (int *bpl, int *dlt);
void upzero (int dlt, int *dlti, int *bli);
int filtep (int rlt1, int al1, int rlt2, int al2);
int quantl (int el, int detl);
int logscl (int il, int nbl);
int scalel (int nbl, int shift_constant);
int uppol2 (int al1, int al2, int plt, int plt1, int plt2);
int uppol1 (int al1, int apl2, int plt, int plt1);
int logsch (int ih, int nbh);
void reset ();

/* G722 C code */

/* variables for transimit quadrature mirror filter here */
int tqmf[24];

/* QMF filter coefficients:
scaled by a factor of 4 compared to G722 CCITT recomendation */
const int h[24] = {
  12, -44, -44, 212, 48, -624, 128, 1448,
  -840, -3220, 3804, 15504, 15504, 3804, -3220, -840,
  1448, 128, -624, 48, 212, -44, -44, 12
};

int xl, xh;

/* variables for receive quadrature mirror filter here */
int accumc[11], accumd[11];

/* outputs of decode() */
int xout1, xout2;

int xs, xd;

/* variables for encoder (hi and lo) here */

int il, szl, spl, sl, el;

const int qq4_code4_table[16] = {
  0, -20456, -12896, -8968, -6288, -4240, -2584, -1200,
  20456, 12896, 8968, 6288, 4240, 2584, 1200, 0
};

const int qq6_code6_table[64] = {
  -136, -136, -136, -136, -24808, -21904, -19008, -16704,
  -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856,
  -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576,
  -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728,
  24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192,
  10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456,
  4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032,
  1688, 1360, 1040, 728, 432, 136, -432, -136
};

int delay_bpl[6];

int delay_dltx[6];

const int wl_code_table[16] = {
  -60, 3042, 1198, 538, 334, 172, 58, -30,
  3042, 1198, 538, 334, 172, 58, -30, -60
};

const int ilb_table[32] = {
  2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
  2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
  2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
  3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
};

int nbl;			/* delay line */
int al1, al2;
int plt, plt1, plt2;
int dlt;
int rlt, rlt1, rlt2;

/* decision levels - pre-multiplied by 8, 0 to indicate end */
const int decis_levl[30] = {
  280, 576, 880, 1200, 1520, 1864, 2208, 2584,
  2960, 3376, 3784, 4240, 4696, 5200, 5712, 6288,
  6864, 7520, 8184, 8968, 9752, 10712, 11664, 12896,
  14120, 15840, 17560, 20456, 23352, 32767
};

int detl;

/* quantization table 31 long to make quantl look-up easier,
last entry is for mil=30 case when wd is max */
const int quant26bt_pos[31] = {
  61, 60, 59, 58, 57, 56, 55, 54,
  53, 52, 51, 50, 49, 48, 47, 46,
  45, 44, 43, 42, 41, 40, 39, 38,
  37, 36, 35, 34, 33, 32, 32
};

/* quantization table 31 long to make quantl look-up easier,
last entry is for mil=30 case when wd is max */
const int quant26bt_neg[31] = {
  63, 62, 31, 30, 29, 28, 27, 26,
  25, 24, 23, 22, 21, 20, 19, 18,
  17, 16, 15, 14, 13, 12, 11, 10,
  9, 8, 7, 6, 5, 4, 4
};

int deth;
int sh;				/* this comes from adaptive predictor */
int eh;

const int qq2_code2_table[4] = {
  -7408, -1616, 7408, 1616
};

const int wh_code_table[4] = {
  798, -214, 798, -214
};

int dh, ih;
int nbh, szh;
int sph, ph, yh, rh;

int delay_dhx[6];

int delay_bph[6];

int ah1, ah2;
int ph1, ph2;
int rh1, rh2;

/* variables for decoder here */
int ilr, rl;
int dec_deth, dec_detl, dec_dlt;

int dec_del_bpl[6];

int dec_del_dltx[6];

int dec_plt, dec_plt1, dec_plt2;
int dec_szl, dec_spl, dec_sl;
int dec_rlt1, dec_rlt2, dec_rlt;
int dec_al1, dec_al2;
int dl;
int dec_nbl, dec_dh, dec_nbh;

/* variables used in filtez */
int dec_del_bph[6];

int dec_del_dhx[6];

int dec_szh;
/* variables used in filtep */
int dec_rh1, dec_rh2;
int dec_ah1, dec_ah2;
int dec_ph, dec_sph;

int dec_sh;

int dec_ph1, dec_ph2;

/* G722 encode function two ints in, one 8 bit output */

/* put input samples in xin1 = first value, xin2 = second value */
/* returns il and ih stored together */

int
abs (int n)
{
  int m;

  if (n >= 0)
    m = n;
  else
    m = -n;
  return m;
}

int
encode (int xin1, int xin2)
{
  int i;
  const int *h_ptr;
  int *tqmf_ptr, *tqmf_ptr1;
  long int xa, xb;
  int decis;

/* transmit quadrature mirror filters implemented here */
  h_ptr = h;
  tqmf_ptr = tqmf;
  xa = (long) (*tqmf_ptr++) * (*h_ptr++);
  xb = (long) (*tqmf_ptr++) * (*h_ptr++);
/* main multiply accumulate loop for samples and coefficients */
  for (i = 0; i < 10; i++)
    {
      xa += (long) (*tqmf_ptr++) * (*h_ptr++);
      xb += (long) (*tqmf_ptr++) * (*h_ptr++);
    }
/* final mult/accumulate */
  xa += (long) (*tqmf_ptr++) * (*h_ptr++);
  xb += (long) (*tqmf_ptr) * (*h_ptr++);

/* update delay line tqmf */
  tqmf_ptr1 = tqmf_ptr - 2;
  for (i = 0; i < 22; i++)
    *tqmf_ptr-- = *tqmf_ptr1--;
  *tqmf_ptr-- = xin1;
  *tqmf_ptr = xin2;

/* scale outputs */
  xl = (xa + xb) >> 15;
  xh = (xa - xb) >> 15;

/* end of quadrature mirror filter code */

/* starting with lower sub band encoder */

/* filtez - compute predictor output section - zero section */
  szl = filtez (delay_bpl, delay_dltx);

/* filtep - compute predictor output signal (pole section) */
  spl = filtep (rlt1, al1, rlt2, al2);

/* compute the predictor output value in the lower sub_band encoder */
  sl = szl + spl;
  el = xl - sl;

/* quantl: quantize the difference signal */
  il = quantl (el, detl);

/* computes quantized difference signal */
/* for invqbl, truncate by 2 lsbs, so mode = 3 */
  dlt = ((long) detl * qq4_code4_table[il >> 2]) >> 15;

/* logscl: updates logarithmic quant. scale factor in low sub band */
  nbl = logscl (il, nbl);

/* scalel: compute the quantizer scale factor in the lower sub band */
/* calling parameters nbl and 8 (constant such that scalel can be scaleh) */
  detl = scalel (nbl, 8);

/* parrec - simple addition to compute recontructed signal for adaptive pred */
  plt = dlt + szl;

/* upzero: update zero section predictor coefficients (sixth order)*/
/* calling parameters: dlt, dlt1, dlt2, ..., dlt6 from dlt */
/*  bpli (linear_buffer in which all six values are delayed */
/* return params:      updated bpli, delayed dltx */
  upzero (dlt, delay_dltx, delay_bpl);

/* uppol2- update second predictor coefficient apl2 and delay it as al2 */
/* calling parameters: al1, al2, plt, plt1, plt2 */
  al2 = uppol2 (al1, al2, plt, plt1, plt2);

/* uppol1 :update first predictor coefficient apl1 and delay it as al1 */
/* calling parameters: al1, apl2, plt, plt1 */
  al1 = uppol1 (al1, al2, plt, plt1);

/* recons : compute recontructed signal for adaptive predictor */
  rlt = sl + dlt;

/* done with lower sub_band encoder; now implement delays for next time*/
  rlt2 = rlt1;
  rlt1 = rlt;
  plt2 = plt1;
  plt1 = plt;

/* high band encode */

  szh = filtez (delay_bph, delay_dhx);

  sph = filtep (rh1, ah1, rh2, ah2);

/* predic: sh = sph + szh */
  sh = sph + szh;
/* subtra: eh = xh - sh */
  eh = xh - sh;

/* quanth - quantization of difference signal for higher sub-band */
/* quanth: in-place for speed params: eh, deth (has init. value) */
  if (eh >= 0)
    {
      ih = 3;			/* 2,3 are pos codes */
    }
  else
    {
      ih = 1;			/* 0,1 are neg codes */
    }
  decis = (564L * (long) deth) >> 12L;
  if (abs (eh) > decis)
    ih--;			/* mih = 2 case */

/* compute the quantized difference signal, higher sub-band*/
  dh = ((long) deth * qq2_code2_table[ih]) >> 15L;

/* logsch: update logarithmic quantizer scale factor in hi sub-band*/
  nbh = logsch (ih, nbh);

/* note : scalel and scaleh use same code, different parameters */
  deth = scalel (nbh, 10);

/* parrec - add pole predictor output to quantized diff. signal */
  ph = dh + szh;

/* upzero: update zero section predictor coefficients (sixth order) */
/* calling parameters: dh, dhi, bphi */
/* return params: updated bphi, delayed dhx */
  upzero (dh, delay_dhx, delay_bph);

/* uppol2: update second predictor coef aph2 and delay as ah2 */
/* calling params: ah1, ah2, ph, ph1, ph2 */
  ah2 = uppol2 (ah1, ah2, ph, ph1, ph2);

/* uppol1:  update first predictor coef. aph2 and delay it as ah1 */
  ah1 = uppol1 (ah1, ah2, ph, ph1);

/* recons for higher sub-band */
  yh = sh + dh;

/* done with higher sub-band encoder, now Delay for next time */
  rh2 = rh1;
  rh1 = yh;
  ph2 = ph1;
  ph1 = ph;

/* multiplex ih and il to get signals together */
  return (il | (ih << 6));
}

/* decode function, result in xout1 and xout2 */

void
decode (int input)
{
  int i;
  long int xa1, xa2;		/* qmf accumulators */
  const int *h_ptr;
  int *ac_ptr, *ac_ptr1, *ad_ptr, *ad_ptr1;

/* split transmitted word from input into ilr and ih */
  ilr = input & 0x3f;
  ih = input >> 6;

/* LOWER SUB_BAND DECODER */

/* filtez: compute predictor output for zero section */
  dec_szl = filtez (dec_del_bpl, dec_del_dltx);

/* filtep: compute predictor output signal for pole section */
  dec_spl = filtep (dec_rlt1, dec_al1, dec_rlt2, dec_al2);

  dec_sl = dec_spl + dec_szl;

/* compute quantized difference signal for adaptive predic */
  dec_dlt = ((long) dec_detl * qq4_code4_table[ilr >> 2]) >> 15;

/* compute quantized difference signal for decoder output */
  dl = ((long) dec_detl * qq6_code6_table[il]) >> 15;

  rl = dl + dec_sl;

/* logscl: quantizer scale factor adaptation in the lower sub-band */
  dec_nbl = logscl (ilr, dec_nbl);

/* scalel: computes quantizer scale factor in the lower sub band */
  dec_detl = scalel (dec_nbl, 8);

/* parrec - add pole predictor output to quantized diff. signal */
/* for partially reconstructed signal */
  dec_plt = dec_dlt + dec_szl;

/* upzero: update zero section predictor coefficients */
  upzero (dec_dlt, dec_del_dltx, dec_del_bpl);

/* uppol2: update second predictor coefficient apl2 and delay it as al2 */
  dec_al2 = uppol2 (dec_al1, dec_al2, dec_plt, dec_plt1, dec_plt2);

/* uppol1: update first predictor coef. (pole setion) */
  dec_al1 = uppol1 (dec_al1, dec_al2, dec_plt, dec_plt1);

/* recons : compute recontructed signal for adaptive predictor */
  dec_rlt = dec_sl + dec_dlt;

/* done with lower sub band decoder, implement delays for next time */
  dec_rlt2 = dec_rlt1;
  dec_rlt1 = dec_rlt;
  dec_plt2 = dec_plt1;
  dec_plt1 = dec_plt;

/* HIGH SUB-BAND DECODER */

/* filtez: compute predictor output for zero section */
  dec_szh = filtez (dec_del_bph, dec_del_dhx);

/* filtep: compute predictor output signal for pole section */
  dec_sph = filtep (dec_rh1, dec_ah1, dec_rh2, dec_ah2);

/* predic:compute the predictor output value in the higher sub_band decoder */
  dec_sh = dec_sph + dec_szh;

/* in-place compute the quantized difference signal */
  dec_dh = ((long) dec_deth * qq2_code2_table[ih]) >> 15L;

/* logsch: update logarithmic quantizer scale factor in hi sub band */
  dec_nbh = logsch (ih, dec_nbh);

/* scalel: compute the quantizer scale factor in the higher sub band */
  dec_deth = scalel (dec_nbh, 10);

/* parrec: compute partially recontructed signal */
  dec_ph = dec_dh + dec_szh;

/* upzero: update zero section predictor coefficients */
  upzero (dec_dh, dec_del_dhx, dec_del_bph);

/* uppol2: update second predictor coefficient aph2 and delay it as ah2 */
  dec_ah2 = uppol2 (dec_ah1, dec_ah2, dec_ph, dec_ph1, dec_ph2);

/* uppol1: update first predictor coef. (pole setion) */
  dec_ah1 = uppol1 (dec_ah1, dec_ah2, dec_ph, dec_ph1);

/* recons : compute recontructed signal for adaptive predictor */
  rh = dec_sh + dec_dh;

/* done with high band decode, implementing delays for next time here */
  dec_rh2 = dec_rh1;
  dec_rh1 = rh;
  dec_ph2 = dec_ph1;
  dec_ph1 = dec_ph;

/* end of higher sub_band decoder */

/* end with receive quadrature mirror filters */
  xd = rl - rh;
  xs = rl + rh;

/* receive quadrature mirror filters implemented here */
  h_ptr = h;
  ac_ptr = accumc;
  ad_ptr = accumd;
  xa1 = (long) xd *(*h_ptr++);
  xa2 = (long) xs *(*h_ptr++);
/* main multiply accumulate loop for samples and coefficients */
  for (i = 0; i < 10; i++)
    {
      xa1 += (long) (*ac_ptr++) * (*h_ptr++);
      xa2 += (long) (*ad_ptr++) * (*h_ptr++);
    }
/* final mult/accumulate */
  xa1 += (long) (*ac_ptr) * (*h_ptr++);
  xa2 += (long) (*ad_ptr) * (*h_ptr++);

/* scale by 2^14 */
  xout1 = xa1 >> 14;
  xout2 = xa2 >> 14;

/* update delay lines */
  ac_ptr1 = ac_ptr - 1;
  ad_ptr1 = ad_ptr - 1;
  for (i = 0; i < 10; i++)
    {
      *ac_ptr-- = *ac_ptr1--;
      *ad_ptr-- = *ad_ptr1--;
    }
  *ac_ptr = xd;
  *ad_ptr = xs;
}

/* clear all storage locations */

void
reset ()
{
  int i;

  detl = dec_detl = 32;		/* reset to min scale factor */
  deth = dec_deth = 8;
  nbl = al1 = al2 = plt1 = plt2 = rlt1 = rlt2 = 0;
  nbh = ah1 = ah2 = ph1 = ph2 = rh1 = rh2 = 0;
  dec_nbl = dec_al1 = dec_al2 = dec_plt1 = dec_plt2 = dec_rlt1 = dec_rlt2 = 0;
  dec_nbh = dec_ah1 = dec_ah2 = dec_ph1 = dec_ph2 = dec_rh1 = dec_rh2 = 0;

  for (i = 0; i < 6; i++)
    {
      delay_dltx[i] = 0;
      delay_dhx[i] = 0;
      dec_del_dltx[i] = 0;
      dec_del_dhx[i] = 0;
    }

  for (i = 0; i < 6; i++)
    {
      delay_bpl[i] = 0;
      delay_bph[i] = 0;
      dec_del_bpl[i] = 0;
      dec_del_bph[i] = 0;
    }

  for (i = 0; i < 24; i++)
    tqmf[i] = 0;		// i<23

  for (i = 0; i < 11; i++)
    {
      accumc[i] = 0;
      accumd[i] = 0;
    }
}

/* filtez - compute predictor output signal (zero section) */
/* input: bpl1-6 and dlt1-6, output: szl */

int
filtez (int *bpl, int *dlt)
{
  int i;
  long int zl;
  zl = (long) (*bpl++) * (*dlt++);
  for (i = 1; i < 6; i++)
    zl += (long) (*bpl++) * (*dlt++);

  return ((int) (zl >> 14));	/* x2 here */
}

/* filtep - compute predictor output signal (pole section) */
/* input rlt1-2 and al1-2, output spl */

int
filtep (int rlt1, int al1, int rlt2, int al2)
{
  long int pl, pl2;
  pl = 2 * rlt1;
  pl = (long) al1 *pl;
  pl2 = 2 * rlt2;
  pl += (long) al2 *pl2;
  return ((int) (pl >> 15));
}

/* quantl - quantize the difference signal in the lower sub-band */
int
quantl (int el, int detl)
{
  int ril, mil;
  long int wd, decis;

/* abs of difference signal */
  wd = abs (el);
/* determine mil based on decision levels and detl gain */
  for (mil = 0; mil < 30; mil++)
    {
      decis = (decis_levl[mil] * (long) detl) >> 15L;
      if (wd <= decis)
	break;
    }
/* if mil=30 then wd is less than all decision levels */
  if (el >= 0)
    ril = quant26bt_pos[mil];
  else
    ril = quant26bt_neg[mil];
  return (ril);
}

/* logscl - update log quantizer scale factor in lower sub-band */
/* note that nbl is passed and returned */

int
logscl (int il, int nbl)
{
  long int wd;
  wd = ((long) nbl * 127L) >> 7L;	/* leak factor 127/128 */
  nbl = (int) wd + wl_code_table[il >> 2];
  if (nbl < 0)
    nbl = 0;
  if (nbl > 18432)
    nbl = 18432;
  return (nbl);
}

/* scalel: compute quantizer scale factor in lower or upper sub-band*/

int
scalel (int nbl, int shift_constant)
{
  int wd1, wd2, wd3;
  wd1 = (nbl >> 6) & 31;
  wd2 = nbl >> 11;
  wd3 = ilb_table[wd1] >> (shift_constant + 1 - wd2);
  return (wd3 << 3);
}

/* upzero - inputs: dlt, dlti[0-5], bli[0-5], outputs: updated bli[0-5] */
/* also implements delay of bli and update of dlti from dlt */

void
upzero (int dlt, int *dlti, int *bli)
{
  int i, wd2, wd3;
/*if dlt is zero, then no sum into bli */
  if (dlt == 0)
    {
      for (i = 0; i < 6; i++)
	{
	  bli[i] = (int) ((255L * bli[i]) >> 8L);	/* leak factor of 255/256 */
	}
    }
  else
    {
      for (i = 0; i < 6; i++)
	{
	  if ((long) dlt * dlti[i] >= 0)
	    wd2 = 128;
	  else
	    wd2 = -128;
	  wd3 = (int) ((255L * bli[i]) >> 8L);	/* leak factor of 255/256 */
	  bli[i] = wd2 + wd3;
	}
    }
/* implement delay line for dlt */
  dlti[5] = dlti[4];
  dlti[4] = dlti[3];
  dlti[3] = dlti[2];
  dlti[2] = dlti[1];
  dlti[1] = dlti[0];
  dlti[0] = dlt;
}

/* uppol2 - update second predictor coefficient (pole section) */
/* inputs: al1, al2, plt, plt1, plt2. outputs: apl2 */

int
uppol2 (int al1, int al2, int plt, int plt1, int plt2)
{
  long int wd2, wd4;
  int apl2;
  wd2 = 4L * (long) al1;
  if ((long) plt * plt1 >= 0L)
    wd2 = -wd2;			/* check same sign */
  wd2 = wd2 >> 7;		/* gain of 1/128 */
  if ((long) plt * plt2 >= 0L)
    {
      wd4 = wd2 + 128;		/* same sign case */
    }
  else

/* apl2 is limited to +-.75 */
  if (apl2 > 12288)
    apl2 = 12288;
  if (apl2 < -12288)
    apl2 = -12288;
  return (apl2);
}

/* uppol1 - update first predictor coefficient (pole section) */
/* inputs: al1, apl2, plt, plt1. outputs: apl1 */

int
uppol1 (int al1, int apl2, int plt, int plt1)
{
  long int wd2;
  int wd3, apl1;
  wd2 = ((long) al1 * 255L) >> 8L;	/* leak factor of 255/256 */
  if ((long) plt * plt1 >= 0L)
    {
      apl1 = (int) wd2 + 192;	/* same sign case */
    }
  else
    {
      apl1 = (int) wd2 - 192;
    }
/* note: wd3= .9375-.75 is always positive */
  wd3 = 15360 - apl2;		/* limit value */
  if (apl1 > wd3)
    apl1 = wd3;
  if (apl1 < -wd3)
    apl1 = -wd3;
  return (apl1);
}

/* logsch - update log quantizer scale factor in higher sub-band */
/* note that nbh is passed and returned */

int
logsch (int ih, int nbh)
{
  int wd;
  wd = ((long) nbh * 127L) >> 7L;	/* leak factor 127/128 */
  nbh = wd + wh_code_table[ih];
  if (nbh < 0)
    nbh = 0;
  if (nbh > 22528)
    nbh = 22528;
  return (nbh);
}

/*
+--------------------------------------------------------------------------+
| * Test Vectors (added for CHStone)                                       |
|     test_data : input data                                               |
|     test_compressed : expected output data for "encode"                  |
|     test_result : expected output data for "decode"                      |
+--------------------------------------------------------------------------+
*/

#define SIZE 100
#define IN_END 100

const int test_data[SIZE] = {
  0x44, 0x44, 0x44, 0x44, 0x44,
  0x44, 0x44, 0x44, 0x44, 0x44,
  0x44, 0x44, 0x44, 0x44, 0x44,
  0x44, 0x44, 0x43, 0x43, 0x43,
  0x43, 0x43, 0x43, 0x43, 0x42,
  0x42, 0x42, 0x42, 0x42, 0x42,
  0x41, 0x41, 0x41, 0x41, 0x41,
  0x40, 0x40, 0x40, 0x40, 0x40,
  0x40, 0x40, 0x40, 0x3f, 0x3f,
  0x3f, 0x3f, 0x3f, 0x3e, 0x3e,
  0x3e, 0x3e, 0x3e, 0x3e, 0x3d,
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
  0x3c, 0x3c, 0x3c, 0x3c, 0x3c,
  0x3c, 0x3c, 0x3c, 0x3c, 0x3b,
  0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
  0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
  0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
  0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
  0x3b, 0x3b, 0x3c, 0x3c, 0x3c,
  0x3c, 0x3c, 0x3c, 0x3c, 0x3c
};
int compressed[SIZE], result[SIZE];
const int test_compressed[SIZE] = {
  0xfd, 0xde, 0x77, 0xba, 0xf2,
  0x90, 0x20, 0xa0, 0xec, 0xed,
  0xef, 0xf1, 0xf3, 0xf4, 0xf5,
  0xf5, 0xf5, 0xf5, 0xf6, 0xf6,
  0xf6, 0xf7, 0xf8, 0xf7, 0xf8,
  0xf7, 0xf9, 0xf8, 0xf7, 0xf9,
  0xf8, 0xf8, 0xf6, 0xf8, 0xf8,
  0xf7, 0xf9, 0xf9, 0xf9, 0xf8,
  0xf7, 0xfa, 0xf8, 0xf8, 0xf7,
  0xfb, 0xfa, 0xf9, 0xf8, 0xf8
};
const int test_result[SIZE] = {
  0, 0xffffffff, 0xffffffff, 0, 0,
  0xffffffff, 0, 0, 0xffffffff, 0xffffffff,
  0, 0, 0x1, 0x1, 0,
  0xfffffffe, 0xffffffff, 0xfffffffe, 0, 0xfffffffc,
  0x1, 0x1, 0x1, 0xfffffffb, 0x2,
  0x2, 0x3, 0xb, 0x14, 0x14,
  0x16, 0x18, 0x20, 0x21, 0x26,
  0x27, 0x2e, 0x2f, 0x33, 0x32,
  0x35, 0x33, 0x36, 0x34, 0x37,
  0x34, 0x37, 0x35, 0x38, 0x36,
  0x39, 0x38, 0x3b, 0x3a, 0x3f,
  0x3f, 0x40, 0x3a, 0x3d, 0x3e,
  0x41, 0x3c, 0x3e, 0x3f, 0x42,
  0x3e, 0x3b, 0x37, 0x3b, 0x3e,
  0x41, 0x3b, 0x3b, 0x3a, 0x3b,
  0x36, 0x39, 0x3b, 0x3f, 0x3c,
  0x3b, 0x37, 0x3b, 0x3d, 0x41,
  0x3d, 0x3e, 0x3c, 0x3e, 0x3b,
  0x3a, 0x37, 0x3b, 0x3e, 0x41,
  0x3c, 0x3b, 0x39, 0x3a, 0x36
};

void
adpcm_main ()
{
  int i, j;

/* reset, initialize required memory */
  reset ();

  j = 10;

  for (i = 0; i < IN_END; i += 2)
    {
      compressed[i / 2] = encode (test_data[i], test_data[i + 1]);
    }
  for (i = 0; i < IN_END; i += 2)
    {
      decode (compressed[i / 2]);
      result[i] = xout1;
      result[i + 1] = xout2;
    }
}

int
main ()
{
  int i;
  int main_result;

      main_result = 0;
      adpcm_main ();
      for (i = 0; i < IN_END / 2; i++)
	{
	  if (compressed[i] != test_compressed[i])
	    {
	      main_result += 1;
	    }
	}
      for (i = 0; i < IN_END; i++)
	{
	  if (result[i] != test_result[i])
	    {
	      main_result += 1;
	    }
	}
      printf ("%d\n", main_result);
      return main_result;
    }


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/* crypto/bf/bf.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@mincom.oz.au).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@mincom.oz.au).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@mincom.oz.au)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
#include <stdio.h>

#include "blowfish.h"
#include "bf_locl.h"
#include "bf_pi.h"
#include "bf_skey.c"
#include "bf_cfb64.c"
#include "bf_enc.c"

/*
+--------------------------------------------------------------------------+
| * Test Vectors (added for CHStone)                                       |
|     in_key : input data                                                  |
|     out_key : expected output data                                       |
+--------------------------------------------------------------------------+
*/
#define KEYSIZE 5200
const unsigned char in_key[KEYSIZE] = {
  75, 117, 114, 116, 86, 111, 110, 110, 101, 103, 117, 116, 115, 67, 111, 109,
  109, 101, 110, 99, 101, 109, 101, 110, 116, 65, 100, 100, 114, 101, 115,
  115, 97, 116, 77, 73, 84, 76, 97, 100,
  105, 101, 115, 97, 110, 100, 103, 101, 110, 116, 108, 101, 109, 101, 110,
  111, 102, 116, 104, 101, 99, 108, 97, 115, 115, 111, 102, 57, 55, 87, 101,
  97, 114, 115, 117, 110, 115, 99, 114, 101,
  101, 110, 73, 102, 73, 99, 111, 117, 108, 100, 111, 102, 102, 101, 114, 121,
  111, 117, 111, 110, 108, 121, 111, 110, 101, 116, 105, 112, 102, 111, 114,
  116, 104, 101, 102, 117, 116, 117, 114, 101,
  115, 117, 110, 115, 99, 114, 101, 101, 110, 119, 111, 117, 108, 100, 98,
  101, 105, 116, 84, 104, 101, 108, 111, 110, 103, 116, 101, 114, 109, 98,
  101, 110, 101, 102, 105, 116, 115, 111, 102, 115,
  117, 110, 115, 99, 114, 101, 101, 110, 104, 97, 118, 101, 98, 101, 101, 110,
  112, 114, 111, 118, 101, 100, 98, 121, 115, 99, 105, 101, 110, 116, 105,
  115, 116, 115, 119, 104, 101, 114, 101, 97,
  115, 116, 104, 101, 114, 101, 115, 116, 111, 102, 109, 121, 97, 100, 118,
  105, 99, 101, 104, 97, 115, 110, 111, 98, 97, 115, 105, 115, 109, 111,
  114, 101, 114, 101, 108, 105, 97, 98, 108, 101,
  116, 104, 97, 110, 109, 121, 111, 119, 110, 109, 101, 97, 110, 100, 101,
  114, 105, 110, 103, 101, 120, 112, 101, 114, 105, 101, 110, 99, 101, 73,
  119, 105, 108, 108, 100, 105, 115, 112, 101, 110,
  115, 101, 116, 104, 105, 115, 97, 100, 118, 105, 99, 101, 110, 111, 119, 69,
  110, 106, 111, 121, 116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100,
  98, 101, 97, 117, 116, 121, 111, 102, 121,
  111, 117, 114, 121, 111, 117, 116, 104, 79, 104, 110, 101, 118, 101, 114,
  109, 105, 110, 100, 89, 111, 117, 119, 105, 108, 108, 110, 111, 116, 117,
  110, 100, 101, 114, 115, 116, 97, 110, 100, 116,
  104, 101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121,
  111, 102, 121, 111, 117, 114, 121, 111, 117, 116, 104, 117, 110, 116, 105,
  108, 116, 104, 101, 121, 118, 101, 102, 97,
  100, 101, 100, 66, 117, 116, 116, 114, 117, 115, 116, 109, 101, 105, 110,
  50, 48, 121, 101, 97, 114, 115, 121, 111, 117, 108, 108, 108, 111, 111,
  107, 98, 97, 99, 107, 97, 116, 112, 104, 111,
  116, 111, 115, 111, 102, 121, 111, 117, 114, 115, 101, 108, 102, 97, 110,
  100, 114, 101, 99, 97, 108, 108, 105, 110, 97, 119, 97, 121, 121, 111,
  117, 99, 97, 110, 116, 103, 114, 97, 115, 112,
  110, 111, 119, 104, 111, 119, 109, 117, 99, 104, 112, 111, 115, 115, 105,
  98, 105, 108, 105, 116, 121, 108, 97, 121, 98, 101, 102, 111, 114, 101,
  121, 111, 117, 97, 110, 100, 104, 111, 119, 102,
  97, 98, 117, 108, 111, 117, 115, 121, 111, 117, 114, 101, 97, 108, 108, 121,
  108, 111, 111, 107, 101, 100, 89, 111, 117, 97, 114, 101, 110, 111, 116,
  97, 115, 102, 97, 116, 97, 115, 121, 111,
  117, 105, 109, 97, 103, 105, 110, 101, 68, 111, 110, 116, 119, 111, 114,
  114, 121, 97, 98, 111, 117, 116, 116, 104, 101, 102, 117, 116, 117, 114,
  101, 79, 114, 119, 111, 114, 114, 121, 98, 117,
  116, 107, 110, 111, 119, 116, 104, 97, 116, 75, 117, 114, 116, 86, 111, 110,
  110, 101, 103, 117, 75, 117, 114, 116, 86, 111, 110, 110, 101, 103, 117,
  116, 115, 67, 111, 109, 109, 101, 110, 99,
  101, 109, 101, 110, 116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77, 73,
  84, 76, 97, 100, 105, 101, 115, 97, 110, 100, 103, 101, 110, 116, 108,
  101, 109, 101, 110, 111, 102, 116, 104, 101,
  99, 108, 97, 115, 115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117, 110,
  115, 99, 114, 101, 101, 110, 73, 102, 73, 99, 111, 117, 108, 100, 111,
  102, 102, 101, 114, 121, 111, 117, 111, 110,
  108, 121, 111, 110, 101, 116, 105, 112, 102, 111, 114, 116, 104, 101, 102,
  117, 116, 117, 114, 101, 115, 117, 110, 115, 99, 114, 101, 101, 110, 119,
  111, 117, 108, 100, 98, 101, 105, 116, 84, 104,
  101, 108, 111, 110, 103, 116, 101, 114, 109, 98, 101, 110, 101, 102, 105,
  116, 115, 111, 102, 115, 117, 110, 115, 99, 114, 101, 101, 110, 104, 97,
  118, 101, 98, 101, 101, 110, 112, 114, 111, 118,
  101, 100, 98, 121, 115, 99, 105, 101, 110, 116, 105, 115, 116, 115, 119,
  104, 101, 114, 101, 97, 115, 116, 104, 101, 114, 101, 115, 116, 111, 102,
  109, 121, 97, 100, 118, 105, 99, 101, 104, 97,
  115, 110, 111, 98, 97, 115, 105, 115, 109, 111, 114, 101, 114, 101, 108,
  105, 97, 98, 108, 101, 116, 104, 97, 110, 109, 121, 111, 119, 110, 109,
  101, 97, 110, 100, 101, 114, 105, 110, 103, 101,
  120, 112, 101, 114, 105, 101, 110, 99, 101, 73, 119, 105, 108, 108, 100,
  105, 115, 112, 101, 110, 115, 101, 116, 104, 105, 115, 97, 100, 118, 105,
  99, 101, 110, 111, 119, 69, 110, 106, 111, 121,
  116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116,
  121, 111, 102, 121, 111, 117, 114, 121, 111, 117, 116, 104, 79, 104, 110,
  101, 118, 101, 114, 109, 105, 110, 100, 89,
  111, 117, 119, 105, 108, 108, 110, 111, 116, 117, 110, 100, 101, 114, 115,
  116, 97, 110, 100, 116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100,
  98, 101, 97, 117, 116, 121, 111, 102, 121, 111,
  117, 114, 121, 111, 117, 116, 104, 117, 110, 116, 105, 108, 116, 104, 101,
  121, 118, 101, 102, 97, 100, 101, 100, 66, 117, 116, 116, 114, 117, 115,
  116, 109, 101, 105, 110, 50, 48, 121, 101, 97,
  114, 115, 121, 111, 117, 108, 108, 108, 111, 111, 107, 98, 97, 99, 107, 97,
  116, 112, 104, 111, 116, 111, 115, 111, 102, 121, 111, 117, 114, 115, 101,
  108, 102, 97, 110, 100, 114, 101, 99, 97,
  108, 108, 105, 110, 97, 119, 97, 121, 121, 111, 117, 99, 97, 110, 116, 103,
  114, 97, 115, 112, 110, 111, 119, 104, 111, 119, 109, 117, 99, 104, 112,
  111, 115, 115, 105, 98, 105, 108, 105, 116,
  121, 108, 97, 121, 98, 101, 102, 111, 114, 101, 121, 111, 117, 97, 110, 100,
  104, 111, 119, 102, 97, 98, 117, 108, 111, 117, 115, 121, 111, 117, 114,
  101, 97, 108, 108, 121, 108, 111, 111, 107,
  101, 100, 89, 111, 117, 97, 114, 101, 110, 111, 116, 97, 115, 102, 97, 116,
  97, 115, 121, 111, 117, 105, 109, 97, 103, 105, 110, 101, 68, 111, 110,
  116, 119, 111, 114, 114, 121, 97, 98, 111,
  117, 116, 116, 104, 101, 102, 117, 116, 117, 114, 101, 79, 114, 119, 111,
  114, 114, 121, 98, 117, 116, 107, 110, 111, 119, 116, 104, 97, 116, 75,
  117, 114, 116, 86, 111, 110, 110, 101, 103, 117,
  116, 115, 67, 111, 109, 109, 101, 110, 99, 101, 109, 101, 110, 116, 65, 100,
  100, 114, 101, 115, 115, 97, 116, 77, 73, 84, 76, 97, 100, 105, 101, 115,
  97, 110, 100, 103, 101, 110, 116, 108,
  101, 109, 101, 110, 111, 102, 116, 104, 101, 99, 108, 97, 115, 115, 111,
  102, 57, 55, 87, 101, 97, 114, 115, 117, 110, 115, 99, 114, 101, 101, 110,
  73, 102, 73, 99, 111, 117, 108, 100, 111,
  102, 102, 101, 114, 121, 111, 117, 111, 110, 108, 121, 111, 110, 101, 116,
  105, 112, 102, 111, 114, 116, 104, 101, 102, 117, 116, 117, 114, 101, 115,
  117, 110, 115, 99, 114, 101, 101, 110, 119, 111,
  117, 108, 100, 98, 101, 105, 116, 84, 104, 101, 108, 111, 110, 103, 116,
  101, 114, 109, 98, 101, 110, 101, 102, 105, 116, 115, 111, 102, 115, 117,
  110, 115, 99, 114, 101, 101, 110, 104, 97, 118,
  101, 98, 101, 101, 110, 112, 114, 111, 118, 101, 100, 98, 121, 115, 99, 105,
  101, 110, 116, 105, 115, 116, 115, 119, 104, 101, 114, 101, 97, 115, 116,
  104, 101, 114, 101, 115, 116, 111, 102, 109,
  121, 97, 100, 118, 105, 99, 101, 104, 97, 115, 110, 111, 98, 97, 115, 105,
  115, 109, 111, 114, 101, 114, 101, 108, 105, 97, 98, 108, 101, 116, 104,
  97, 110, 109, 121, 111, 119, 110, 109, 101,
  97, 110, 100, 101, 114, 105, 110, 103, 101, 120, 112, 101, 114, 105, 101,
  110, 99, 101, 73, 119, 105, 108, 108, 100, 105, 115, 112, 101, 110, 115,
  101, 116, 104, 105, 115, 97, 100, 118, 105, 99,
  101, 110, 111, 119, 69, 110, 106, 111, 121, 116, 104, 101, 112, 111, 119,
  101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121, 111, 102, 121, 111,
  117, 114, 121, 111, 117, 116, 104, 79, 104, 110,
  101, 118, 101, 114, 109, 105, 110, 100, 89, 111, 117, 119, 105, 108, 108,
  110, 111, 116, 117, 110, 100, 101, 114, 115, 116, 97, 110, 100, 116, 104,
  101, 112, 111, 119, 101, 114, 97, 110, 100, 98,
  101, 97, 117, 116, 121, 111, 102, 121, 111, 117, 114, 121, 111, 117, 116,
  104, 117, 110, 116, 105, 108, 116, 104, 101, 121, 118, 101, 102, 97, 100,
  101, 100, 66, 117, 116, 116, 114, 117, 115, 116,
  109, 101, 105, 110, 50, 48, 121, 101, 97, 114, 115, 121, 111, 117, 108, 108,
  108, 111, 111, 107, 98, 97, 99, 107, 97, 116, 112, 104, 111, 116, 111,
  115, 111, 102, 121, 111, 117, 114, 115, 101,
  108, 102, 97, 110, 100, 114, 101, 99, 97, 108, 108, 105, 110, 97, 119, 97,
  121, 121, 111, 117, 99, 97, 110, 116, 103, 114, 97, 115, 112, 110, 111,
  119, 104, 111, 119, 109, 117, 99, 104, 112,
  111, 115, 115, 105, 98, 105, 108, 105, 116, 121, 108, 97, 121, 98, 101, 102,
  111, 114, 101, 121, 111, 117, 97, 110, 100, 104, 111, 119, 102, 97, 98,
  117, 108, 111, 117, 115, 121, 111, 117, 114,
  101, 97, 108, 108, 121, 108, 111, 111, 107, 101, 100, 89, 111, 117, 97, 114,
  101, 110, 111, 116, 97, 115, 102, 97, 116, 97, 115, 121, 111, 117, 105,
  109, 97, 103, 105, 110, 101, 68, 111, 110,
  116, 119, 111, 114, 114, 121, 97, 98, 111, 117, 116, 116, 104, 101, 102,
  117, 116, 117, 114, 101, 79, 114, 119, 111, 114, 114, 121, 98, 117, 116,
  107, 110, 111, 119, 116, 104, 97, 116, 75, 117,
  114, 116, 86, 111, 110, 110, 101, 103, 117, 116, 115, 67, 111, 109, 109,
  101, 110, 99, 101, 109, 101, 110, 116, 65, 100, 100, 114, 101, 115, 115,
  97, 116, 77, 73, 84, 76, 97, 100, 105, 101,
  115, 97, 110, 100, 103, 101, 110, 116, 108, 101, 109, 101, 110, 111, 102,
  116, 104, 101, 99, 108, 97, 115, 115, 111, 102, 57, 55, 87, 101, 97, 114,
  115, 117, 110, 115, 99, 114, 101, 101, 110,
  73, 102, 73, 99, 111, 117, 108, 100, 111, 102, 102, 101, 114, 121, 111, 117,
  111, 110, 108, 121, 111, 110, 101, 116, 105, 112, 102, 111, 114, 116, 104,
  101, 102, 117, 116, 117, 114, 101, 115, 117,
  110, 115, 99, 114, 101, 101, 110, 119, 111, 117, 108, 100, 98, 101, 105,
  116, 84, 104, 101, 108, 111, 110, 103, 116, 101, 114, 109, 98, 101, 110,
  101, 102, 105, 116, 115, 111, 102, 115, 117, 110,
  115, 99, 114, 101, 101, 110, 104, 97, 118, 101, 98, 101, 101, 110, 112, 114,
  111, 118, 101, 100, 98, 121, 115, 99, 105, 101, 110, 116, 105, 115, 116,
  115, 119, 104, 101, 114, 101, 97, 115, 116,
  104, 101, 114, 101, 115, 116, 111, 102, 109, 121, 97, 100, 118, 105, 99,
  101, 104, 97, 115, 110, 111, 98, 97, 115, 105, 115, 109, 111, 114, 101,
  114, 101, 108, 105, 97, 98, 108, 101, 116, 104,
  97, 110, 109, 121, 111, 119, 110, 109, 101, 97, 110, 100, 101, 114, 105,
  110, 103, 101, 120, 112, 101, 114, 105, 101, 110, 99, 101, 73, 119, 105,
  108, 108, 100, 105, 115, 112, 101, 110, 115, 101,
  116, 104, 105, 115, 97, 100, 118, 105, 99, 101, 110, 111, 119, 69, 110, 106,
  111, 121, 116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101,
  97, 117, 116, 121, 111, 102, 121, 111, 117,
  114, 121, 111, 117, 116, 104, 79, 104, 110, 101, 118, 101, 114, 109, 105,
  110, 100, 89, 111, 117, 119, 105, 108, 108, 110, 111, 116, 117, 110, 100,
  101, 114, 115, 116, 97, 110, 100, 116, 104, 101,
  112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121, 111, 102,
  121, 111, 117, 114, 121, 111, 117, 116, 104, 117, 110, 116, 105, 108, 116,
  104, 101, 121, 118, 101, 102, 97, 100, 101,
  100, 66, 117, 116, 116, 114, 117, 115, 116, 109, 101, 105, 110, 50, 48, 121,
  101, 97, 114, 115, 121, 111, 117, 108, 108, 108, 111, 111, 107, 98, 97,
  99, 107, 97, 116, 112, 104, 111, 116, 111,
  115, 111, 102, 121, 111, 117, 114, 115, 101, 108, 102, 97, 110, 100, 114,
  101, 99, 97, 108, 108, 105, 110, 97, 119, 97, 121, 121, 111, 117, 99, 97,
  110, 116, 103, 114, 97, 115, 112, 110, 111,
  119, 104, 111, 119, 109, 117, 99, 104, 112, 111, 115, 115, 105, 98, 105,
  108, 105, 116, 121, 108, 97, 121, 98, 101, 102, 111, 114, 101, 121, 111,
  117, 97, 110, 100, 104, 111, 119, 102, 97, 98,
  117, 108, 111, 117, 115, 121, 111, 117, 114, 101, 97, 108, 108, 121, 108,
  111, 111, 107, 101, 100, 89, 111, 117, 97, 114, 101, 110, 111, 116, 97,
  115, 102, 97, 116, 97, 115, 121, 111, 117, 105,
  109, 97, 103, 105, 110, 101, 68, 111, 110, 116, 119, 111, 114, 114, 121, 97,
  98, 111, 117, 116, 116, 104, 101, 102, 117, 116, 117, 114, 101, 79, 114,
  119, 111, 114, 114, 121, 75, 117, 114, 116,
  86, 111, 110, 110, 101, 103, 117, 116, 115, 67, 111, 109, 109, 101, 110, 99,
  101, 109, 101, 110, 116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77,
  73, 84, 76, 97, 100, 105, 101, 115, 97,
  110, 100, 103, 101, 110, 116, 108, 101, 109, 101, 110, 111, 102, 116, 104,
  101, 99, 108, 97, 115, 115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117,
  110, 115, 99, 114, 101, 101, 110, 73, 102,
  73, 99, 111, 117, 108, 100, 111, 102, 102, 101, 114, 121, 111, 117, 111,
  110, 108, 121, 111, 110, 101, 116, 105, 112, 102, 111, 114, 116, 104, 101,
  102, 117, 116, 117, 114, 101, 115, 117, 110, 115,
  99, 114, 101, 101, 110, 119, 111, 117, 108, 100, 98, 101, 105, 116, 84, 104,
  101, 108, 111, 110, 103, 116, 101, 114, 109, 98, 101, 110, 101, 102, 105,
  116, 115, 111, 102, 115, 117, 110, 115, 99,
  114, 101, 101, 110, 104, 97, 118, 101, 98, 101, 101, 110, 112, 114, 111,
  118, 101, 100, 98, 121, 115, 99, 105, 101, 110, 116, 105, 115, 116, 115,
  119, 104, 101, 114, 101, 97, 115, 116, 104, 101,
  114, 101, 115, 116, 111, 102, 109, 121, 97, 100, 118, 105, 99, 101, 104, 97,
  115, 110, 111, 98, 97, 115, 105, 115, 109, 111, 114, 101, 114, 101, 108,
  105, 97, 98, 108, 101, 116, 104, 97, 110,
  109, 121, 111, 119, 110, 109, 101, 97, 110, 100, 101, 114, 105, 110, 103,
  101, 120, 112, 101, 114, 105, 101, 110, 99, 101, 73, 119, 105, 108, 108,
  100, 105, 115, 112, 101, 110, 115, 101, 116, 104,
  105, 115, 97, 100, 118, 105, 99, 101, 110, 111, 119, 69, 110, 106, 111, 121,
  116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117,
  116, 121, 111, 102, 121, 111, 117, 114, 121,
  111, 117, 116, 104, 79, 104, 110, 101, 118, 101, 114, 109, 105, 110, 100,
  89, 111, 117, 119, 105, 108, 108, 110, 111, 116, 117, 110, 100, 101, 114,
  115, 116, 97, 110, 100, 116, 104, 101, 112, 111,
  119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121, 111, 102, 121, 111,
  117, 114, 121, 111, 117, 116, 104, 117, 110, 116, 105, 108, 116, 104, 101,
  121, 118, 101, 102, 97, 100, 101, 100, 66,
  117, 116, 116, 114, 117, 115, 116, 109, 101, 105, 110, 50, 48, 121, 101, 97,
  114, 115, 121, 111, 117, 108, 108, 108, 111, 111, 107, 98, 97, 99, 107,
  97, 116, 112, 104, 111, 116, 111, 115, 111,
  102, 121, 111, 117, 114, 115, 101, 108, 102, 97, 110, 100, 114, 101, 99, 97,
  108, 108, 105, 110, 97, 119, 97, 121, 121, 111, 117, 99, 97, 110, 116,
  103, 114, 97, 115, 112, 110, 111, 119, 104,
  111, 119, 109, 117, 99, 104, 112, 111, 115, 115, 105, 98, 105, 108, 105,
  116, 121, 108, 97, 121, 98, 101, 102, 111, 114, 101, 121, 111, 117, 97,
  110, 100, 104, 111, 119, 102, 97, 98, 117, 108,
  111, 117, 115, 121, 111, 117, 114, 101, 97, 108, 108, 121, 108, 111, 111,
  107, 101, 100, 89, 111, 117, 97, 114, 101, 110, 111, 116, 97, 115, 102,
  97, 116, 97, 115, 121, 111, 117, 105, 109, 97,
  103, 105, 110, 101, 68, 111, 110, 116, 119, 111, 114, 114, 121, 97, 98, 111,
  117, 116, 116, 104, 101, 102, 117, 116, 117, 114, 101, 79, 114, 119, 111,
  114, 114, 121, 98, 117, 116, 107, 110, 111,
  119, 116, 104, 97, 116, 75, 117, 114, 116, 86, 111, 110, 110, 101, 103, 117,
  75, 117, 114, 116, 86, 111, 110, 110, 101, 103, 117, 116, 115, 67, 111,
  109, 109, 101, 110, 99, 101, 109, 101, 110,
  116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77, 73, 84, 76, 97, 100,
  105, 101, 115, 97, 110, 100, 103, 101, 110, 116, 108, 101, 109, 101, 110,
  111, 102, 116, 104, 101, 99, 108, 97, 115,
  115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117, 110, 115, 99, 114, 101,
  101, 110, 73, 102, 73, 99, 111, 117, 108, 100, 111, 102, 102, 101, 114,
  121, 111, 117, 111, 110, 108, 121, 111, 110,
  101, 116, 105, 112, 102, 111, 114, 116, 104, 101, 102, 117, 116, 117, 114,
  101, 115, 117, 110, 115, 99, 114, 101, 101, 110, 119, 111, 117, 108, 100,
  98, 101, 105, 116, 84, 104, 101, 108, 111, 110,
  103, 116, 101, 114, 109, 98, 101, 110, 101, 102, 105, 116, 115, 111, 102,
  115, 117, 110, 115, 99, 114, 101, 101, 110, 104, 97, 118, 101, 98, 101,
  101, 110, 112, 114, 111, 118, 101, 100, 98, 121,
  115, 99, 105, 101, 110, 116, 105, 115, 116, 115, 119, 104, 101, 114, 101,
  97, 115, 116, 104, 101, 114, 101, 115, 116, 111, 102, 109, 121, 97, 100,
  118, 105, 99, 101, 104, 97, 115, 110, 111, 98,
  97, 115, 105, 115, 109, 111, 114, 101, 114, 101, 108, 105, 97, 98, 108, 101,
  116, 104, 97, 110, 109, 121, 111, 119, 110, 109, 101, 97, 110, 100, 101,
  114, 105, 110, 103, 101, 120, 112, 101, 114,
  105, 101, 110, 99, 101, 73, 119, 105, 108, 108, 100, 105, 115, 112, 101,
  110, 115, 101, 116, 104, 105, 115, 97, 100, 118, 105, 99, 101, 110, 111,
  119, 69, 110, 106, 111, 121, 116, 104, 101, 112,
  111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121, 111, 102, 121,
  111, 117, 114, 121, 111, 117, 116, 104, 79, 104, 110, 101, 118, 101, 114,
  109, 105, 110, 100, 89, 111, 117, 119, 105,
  108, 108, 110, 111, 116, 117, 110, 100, 101, 114, 115, 116, 97, 110, 100,
  116, 104, 101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117,
  116, 121, 111, 102, 121, 111, 117, 114, 121, 111,
  117, 116, 104, 117, 110, 116, 105, 108, 116, 104, 101, 121, 118, 101, 102,
  97, 100, 101, 100, 66, 117, 116, 116, 114, 117, 115, 116, 109, 101, 105,
  110, 50, 48, 121, 101, 97, 114, 115, 121, 111,
  117, 108, 108, 108, 111, 111, 107, 98, 97, 99, 107, 97, 116, 112, 104, 111,
  116, 111, 115, 111, 102, 121, 111, 117, 114, 115, 101, 108, 102, 97, 110,
  100, 114, 101, 99, 97, 108, 108, 105, 110,
  97, 119, 97, 121, 121, 111, 117, 99, 97, 110, 116, 103, 114, 97, 115, 112,
  110, 111, 119, 104, 111, 119, 109, 117, 99, 104, 112, 111, 115, 115, 105,
  98, 105, 108, 105, 116, 121, 108, 97, 121,
  98, 101, 102, 111, 114, 101, 121, 111, 117, 97, 110, 100, 104, 111, 119,
  102, 97, 98, 117, 108, 111, 117, 115, 121, 111, 117, 114, 101, 97, 108,
  108, 121, 108, 111, 111, 107, 101, 100, 89, 111,
  117, 97, 114, 101, 110, 111, 116, 97, 115, 102, 97, 116, 97, 115, 121, 111,
  117, 105, 109, 97, 103, 105, 110, 101, 68, 111, 110, 116, 119, 111, 114,
  114, 121, 97, 98, 111, 117, 116, 116, 104,
  101, 102, 117, 116, 117, 114, 101, 79, 114, 119, 111, 114, 114, 121, 98,
  117, 116, 107, 110, 111, 119, 116, 104, 97, 116, 75, 117, 114, 116, 86,
  111, 110, 110, 101, 103, 117, 116, 115, 67, 111,
  109, 109, 101, 110, 99, 101, 109, 101, 110, 116, 65, 100, 100, 114, 101,
  115, 115, 97, 116, 77, 73, 84, 76, 97, 100, 105, 101, 115, 97, 110, 100,
  103, 101, 110, 116, 108, 101, 109, 101, 110,
  111, 102, 116, 104, 101, 99, 108, 97, 115, 115, 111, 102, 57, 55, 87, 101,
  97, 114, 115, 117, 110, 115, 99, 114, 101, 101, 110, 73, 102, 73, 99, 111,
  117, 108, 100, 111, 102, 102, 101, 114,
  121, 111, 117, 111, 110, 108, 121, 111, 110, 101, 116, 105, 112, 102, 111,
  114, 116, 104, 101, 102, 117, 116, 117, 114, 101, 115, 117, 110, 115, 99,
  114, 101, 101, 110, 119, 111, 117, 108, 100, 98,
  101, 105, 116, 84, 104, 101, 108, 111, 110, 103, 116, 101, 114, 109, 98,
  101, 110, 101, 102, 105, 116, 115, 111, 102, 115, 117, 110, 115, 99, 114,
  101, 101, 110, 104, 97, 118, 101, 98, 101, 101,
  110, 112, 114, 111, 118, 101, 100, 98, 121, 115, 99, 105, 101, 110, 116,
  105, 115, 116, 115, 119, 104, 101, 114, 101, 97, 115, 116, 104, 101, 114,
  101, 115, 116, 111, 102, 109, 121, 97, 100, 118,
  105, 99, 101, 104, 97, 115, 110, 111, 98, 97, 115, 105, 115, 109, 111, 114,
  101, 114, 101, 108, 105, 97, 98, 108, 101, 116, 104, 97, 110, 109, 121,
  111, 119, 110, 109, 101, 97, 110, 100, 101,
  114, 105, 110, 103, 101, 120, 112, 101, 114, 105, 101, 110, 99, 101, 73,
  119, 105, 108, 108, 100, 105, 115, 112, 101, 110, 115, 101, 116, 104, 105,
  115, 97, 100, 118, 105, 99, 101, 110, 111, 119,
  69, 110, 106, 111, 121, 116, 104, 101, 112, 111, 119, 101, 114, 97, 110,
  100, 98, 101, 97, 117, 116, 121, 111, 102, 121, 111, 117, 114, 121, 111,
  117, 116, 104, 79, 104, 110, 101, 118, 101, 114,
  109, 105, 110, 100, 89, 111, 117, 119, 105, 108, 108, 110, 111, 116, 117,
  110, 100, 101, 114, 115, 116, 97, 110, 100, 116, 104, 101, 112, 111, 119,
  101, 114, 97, 110, 100, 98, 101, 97, 117, 116,
  121, 111, 102, 121, 111, 117, 114, 121, 111, 117, 116, 104, 117, 110, 116,
  105, 108, 116, 104, 101, 121, 118, 101, 102, 97, 100, 101, 100, 66, 117,
  116, 116, 114, 117, 115, 116, 109, 101, 105, 110,
  50, 48, 121, 101, 97, 114, 115, 121, 111, 117, 108, 108, 108, 111, 111, 107,
  98, 97, 99, 107, 97, 116, 112, 104, 111, 116, 111, 115, 111, 102, 121,
  111, 117, 114, 115, 101, 108, 102, 97, 110,
  100, 114, 101, 99, 97, 108, 108, 105, 110, 97, 119, 97, 121, 121, 111, 117,
  99, 97, 110, 116, 103, 114, 97, 115, 112, 110, 111, 119, 104, 111, 119,
  109, 117, 99, 104, 112, 111, 115, 115, 105,
  98, 105, 108, 105, 116, 121, 108, 97, 121, 98, 101, 102, 111, 114, 101, 121,
  111, 117, 97, 110, 100, 104, 111, 119, 102, 97, 98, 117, 108, 111, 117,
  115, 121, 111, 117, 114, 101, 97, 108, 108,
  121, 108, 111, 111, 107, 101, 100, 89, 111, 117, 97, 114, 101, 110, 111,
  116, 97, 115, 102, 97, 116, 97, 115, 121, 111, 117, 105, 109, 97, 103,
  105, 110, 101, 68, 111, 110, 116, 119, 111, 114,
  114, 121, 97, 98, 111, 117, 116, 116, 104, 101, 102, 117, 116, 117, 114,
  101, 79, 114, 119, 111, 114, 114, 121, 98, 117, 116, 107, 110, 111, 119,
  116, 104, 97, 116, 75, 117, 114, 116, 86, 111,
  110, 110, 101, 103, 117, 116, 115, 67, 111, 109, 109, 101, 110, 99, 101,
  109, 101, 110, 116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77, 73, 84,
  76, 97, 100, 105, 101, 115, 97, 110, 100,
  103, 101, 110, 116, 108, 101, 109, 101, 110, 111, 102, 116, 104, 101, 99,
  108, 97, 115, 115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117, 110, 115,
  99, 114, 101, 101, 110, 73, 102, 73, 99,
  111, 117, 108, 100, 111, 102, 102, 101, 114, 121, 111, 117, 111, 110, 108,
  121, 111, 110, 101, 116, 105, 112, 102, 111, 114, 116, 104, 101, 102, 117,
  116, 117, 114, 101, 115, 117, 110, 115, 99, 114,
  101, 101, 110, 119, 111, 117, 108, 100, 98, 101, 105, 116, 84, 104, 101,
  108, 111, 110, 103, 116, 101, 114, 109, 98, 101, 110, 101, 102, 105, 116,
  115, 111, 102, 115, 117, 110, 115, 99, 114, 101,
  101, 110, 104, 97, 118, 101, 98, 101, 101, 110, 112, 114, 111, 118, 101,
  100, 98, 121, 115, 99, 105, 101, 110, 116, 105, 115, 116, 115, 119, 104,
  101, 114, 101, 97, 115, 116, 104, 101, 114, 101,
  115, 116, 111, 102, 109, 121, 97, 100, 118, 105, 99, 101, 104, 97, 115, 110,
  111, 98, 97, 115, 105, 115, 109, 111, 114, 101, 114, 101, 108, 105, 97,
  98, 108, 101, 116, 104, 97, 110, 109, 121,
  111, 119, 110, 109, 101, 97, 110, 100, 101, 114, 105, 110, 103, 101, 120,
  112, 101, 114, 105, 101, 110, 99, 101, 73, 119, 105, 108, 108, 100, 105,
  115, 112, 101, 110, 115, 101, 116, 104, 105, 115,
  97, 100, 118, 105, 99, 101, 110, 111, 119, 69, 110, 106, 111, 121, 116, 104,
  101, 112, 111, 119, 101, 114, 97, 110, 100, 98, 101, 97, 117, 116, 121,
  111, 102, 121, 111, 117, 114, 121, 111, 117,
  116, 104, 79, 104, 110, 101, 118, 101, 114, 109, 105, 110, 100, 89, 111,
  117, 119, 105, 108, 108, 110, 111, 116, 117, 110, 100, 101, 114, 115, 116,
  97, 110, 100, 116, 104, 101, 112, 111, 119, 101,
  114, 97, 110, 100, 98, 101, 97, 117, 116, 121, 111, 102, 121, 111, 117, 114,
  121, 111, 117, 116, 104, 117, 110, 116, 105, 108, 116, 104, 101, 121, 118,
  101, 102, 97, 100, 101, 100, 66, 117, 116,
  116, 114, 117, 115, 116, 109, 101, 105, 110, 50, 48, 121, 101, 97, 114, 115,
  121, 111, 117, 108, 108, 108, 111, 111, 107, 98, 97, 99, 107, 97, 116,
  112, 104, 111, 116, 111, 115, 111, 102, 121,
  111, 117, 114, 115, 101, 108, 102, 97, 110, 100, 114, 101, 99, 97, 108, 108,
  105, 110, 97, 119, 97, 121, 121, 111, 117, 99, 97, 110, 116, 103, 114, 97,
  115, 112, 110, 111, 119, 104, 111, 119,
  109, 117, 99, 104, 112, 111, 115, 115, 105, 98, 105, 108, 105, 116, 121,
  108, 97, 121, 98, 101, 102, 111, 114, 101, 121, 111, 117, 97, 110, 100,
  104, 111, 119, 102, 97, 98, 117, 108, 111, 117,
  115, 121, 111, 117, 114, 101, 97, 108, 108, 121, 108, 111, 111, 107, 101,
  100, 89, 111, 117, 97, 114, 101, 110, 111, 116, 97, 115, 102, 97, 116, 97,
  115, 121, 111, 117, 105, 109, 97, 103, 105,
  110, 101, 68, 111, 110, 116, 119, 111, 114, 114, 121, 97, 98, 111, 117, 116,
  116, 104, 101, 102, 117, 116, 117, 114, 101, 79, 114, 119, 111, 114, 114,
  121, 98, 117, 116, 107, 110, 111, 119, 116,
  104, 97, 116, 116, 115, 67, 111, 109, 109, 101, 110, 99, 101, 109, 101, 110,
  116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77, 73, 84, 76, 97, 100,
  105, 101, 115, 97, 110, 100, 103, 101,
  110, 116, 108, 101, 109, 101, 110, 111, 102, 116, 104, 101, 99, 108, 97,
  115, 115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117, 110, 115, 99, 114,
  101, 101, 110, 73, 102, 73, 99, 111, 117,
  108, 100, 111, 102, 102, 101, 114, 121, 111, 117, 111, 110, 108, 121, 111,
  110, 101, 116, 105, 112, 102, 111, 114, 116, 104, 101, 102, 117, 116, 117,
  114, 101, 75, 117, 114, 116, 86, 111, 110, 110,
  101, 103, 117, 116, 115, 67, 111, 109, 109, 101, 110, 99, 101, 109, 101,
  110, 116, 65, 100, 100, 114, 101, 115, 115, 97, 116, 77, 73, 84, 76, 97,
  100, 105, 101, 115, 97, 110, 100, 103, 101,
  110, 116, 108, 101, 109, 101, 110, 111, 102, 116, 104, 101, 99, 108, 97,
  115, 115, 111, 102, 57, 55, 87, 101, 97, 114, 115, 117, 110, 115, 99, 114,
  101, 101, 110, 73, 102, 73, 99, 111, 117,
  108, 100, 111, 102, 102, 101, 114, 121, 111, 117, 111, 110, 108, 121, 111,
  110, 101, 116, 105, 112, 102, 111, 114, 116, 104, 101, 102, 117, 116, 117,
  114, 101, 115, 117, 110, 115, 99, 114, 101, 101,
  110, 119, 111, 117, 108, 100, 98, 101, 105, 116, 84, 104, 101, 108, 111,
  110, 103, 116, 101, 114, 109, 98, 101, 110, 101, 102, 105, 116, 115, 111,
  102, 115, 117, 110, 115, 99, 114, 101, 101, 110,
  104, 97, 118, 101, 98, 101, 101, 110, 112, 114, 111, 118, 101, 100, 98, 121,
  115, 99, 105, 101, 110, 116, 105, 115, 116, 115, 119, 104, 101, 114, 101,
  97, 115, 116, 104, 101, 114, 101, 115, 116
};

const unsigned char out_key[KEYSIZE] = {
  5, 140, 229, 49, 55, 247, 179, 22, 234, 116, 197, 105, 104, 250, 30, 106,
  253, 124, 41, 105, 239, 252, 189, 239, 182, 63, 187, 140, 239, 253, 142,
  216, 26, 137, 170, 225, 52, 248, 13, 173, 77, 52, 249, 67, 194, 246, 207,
  5, 77, 17, 170, 24, 33, 72, 252, 9, 28, 7, 33, 144, 57, 125, 250, 143, 48,
  87, 203, 193, 205, 203, 207, 202, 214, 135, 56, 19, 76, 251, 100, 122,
  141, 135, 103, 210, 173, 79, 109, 16, 204, 155, 2, 12, 35, 122, 247, 66,
  212, 30, 183, 207, 142, 201, 255, 49, 229, 209, 56, 213, 171, 232, 181,
  122, 62, 42, 75, 53, 136, 234, 3, 44, 18, 8, 134, 160, 193, 222, 92, 151,
  93, 238, 76, 67, 186, 145, 29, 184, 214, 173, 178, 49, 41, 251, 128, 185,
  191, 49, 112, 223, 252, 85, 219, 95, 68, 104, 210, 3, 19, 55, 127, 76, 74,
  12, 180, 22, 124, 252, 46, 170, 55, 0, 55, 202, 144, 232, 179, 200, 201,
  206, 37, 219, 195, 98, 77, 154, 157, 22, 39, 169, 66, 87, 204, 150, 25,
  81, 214, 145, 163, 154, 166, 220, 26, 93, 42, 35, 1, 143, 178, 133, 3, 11,
  53, 184, 8, 143, 207, 230, 43, 188, 71, 56, 56, 241, 230, 126, 180, 101,
  134, 122, 171, 217, 173, 221, 56, 46, 166, 240, 159, 29, 181, 228, 119,
  240, 208, 10, 188, 164, 1, 57, 74, 15, 9, 138, 82, 251, 149, 246, 57, 28,
  70, 243, 168, 144, 194, 107, 213, 112, 103, 186, 175, 59, 187, 250, 90,
  239, 73, 230, 133, 173, 195, 92, 211, 142, 163, 226, 184, 237, 115, 57,
  16, 17, 43, 188, 186, 133, 165, 50, 195, 19, 68, 36, 153, 178, 15, 52, 85,
  52, 123, 93, 125, 86, 36, 138, 53, 59, 161, 161, 26, 178, 203, 228, 27,
  37, 140, 67, 236, 7, 182, 88, 71, 139, 228, 22, 15, 147, 220, 18, 132,
  111, 13, 249, 40, 1, 111, 5, 140, 38, 107, 6, 249, 230, 130, 71, 178, 81,
  39, 40, 28, 217, 216, 118, 159, 228, 208, 121, 10, 56, 105, 11, 1, 167,
  105, 64, 209, 44, 86, 191, 237, 254, 101, 25, 126, 161, 37, 54, 12, 87,
  156, 150, 155, 69, 52, 112, 234, 143, 149, 41, 15, 45, 211, 165, 189, 162,
  137, 166, 188, 175, 128, 224, 32, 153, 128, 190, 169, 130, 127, 191, 238,
  223, 146, 155, 177, 142, 176, 78, 229, 52, 96, 141, 119, 223, 36, 10, 24,
  15, 245, 128, 7, 196, 106, 100, 30, 32, 63, 132, 88, 133, 250, 195, 137,
  34, 92, 219, 20, 117, 81, 216, 181, 116, 241, 78, 131, 178, 34, 138, 206,
  10, 144, 51, 210, 108, 111, 122, 116, 49, 213, 152, 232, 228, 20, 245,
  122, 212, 225, 173, 190, 152, 21, 61, 61, 179, 173, 71, 110, 38, 7, 198,
  157, 153, 207, 87, 17, 42, 42, 215, 18, 208, 90, 172, 157, 23, 46, 37,
  166, 218, 65, 25, 136, 173, 85, 149, 105, 54, 20, 218, 6, 65, 184, 239,
  46, 38, 157, 68, 240, 228, 117, 224, 19, 153, 3, 34, 233, 47, 57, 103, 79,
  17, 208, 223, 92, 30, 111, 127, 61, 205, 212, 232, 5, 207, 107, 158, 81,
  192, 135, 67, 75, 60, 118, 68, 51, 30, 200, 176, 187, 62, 1, 100, 173, 63,
  118, 31, 108, 139, 138, 248, 233, 81, 244, 36, 241, 231, 58, 154, 201,
  110, 9, 39, 86, 227, 73, 60, 61, 40, 80, 195, 224, 187, 55, 154, 72, 104,
  218, 60, 253, 248, 216, 90, 44, 213, 78, 177, 148, 76, 244, 57, 170, 1,
  166, 75, 206, 123, 166, 206, 135, 221, 33, 130, 26, 148, 148, 224, 117,
  56, 75, 151, 50, 90, 49, 4, 48, 255, 147, 42, 183, 58, 76, 131, 16, 109,
  222, 86, 85, 134, 253, 209, 74, 17, 220, 238, 82, 200, 140, 89, 210, 117,
  174, 180, 68, 6, 163, 9, 249, 249, 51, 124, 182, 53, 6, 61, 39, 190, 10,
  40, 63, 207, 92, 189, 30, 69, 49, 8, 233, 116, 121, 80, 149, 169, 72, 164,
  203, 152, 71, 201, 169, 144, 205, 83, 10, 214, 213, 0, 147, 32, 62, 91,
  162, 164, 160, 211, 196, 159, 166, 9, 73, 221, 79, 117, 116, 20, 103, 112,
  80, 147, 226, 205, 25, 108, 210, 61, 163, 46, 57, 102, 185, 126, 3, 6, 27,
  118, 139, 113, 67, 62, 4, 242, 88, 152, 95, 92, 142, 233, 139, 34, 177,
  244, 130, 12, 4, 83, 29, 168, 171, 15, 70, 115, 216, 36, 218, 106, 213,
  92, 215, 215, 43, 155, 200, 77, 198, 68, 37, 255, 215, 62, 154, 52, 251,
  198, 148, 55, 207, 79, 99, 243, 135, 43, 64, 204, 179, 106, 144, 78, 120,
  94, 233, 160, 200, 92, 191, 50, 43, 129, 229, 168, 194, 48, 131, 78, 228,
  163, 157, 96, 175, 203, 189, 205, 81, 238, 82, 61, 84, 84, 111, 217, 163,
  7, 18, 77, 156, 41, 209, 47, 10, 250, 58, 236, 187, 248, 212, 131, 60, 52,
  126, 180, 113, 207, 135, 112, 192, 190, 177, 68, 171, 77, 219, 253, 105,
  12, 157, 222, 32, 159, 92, 185, 88, 192, 113, 39, 18, 77, 215, 112, 223,
  114, 128, 102, 42, 219, 15, 127, 23, 114, 152, 125, 254, 12, 52, 78, 242,
  74, 130, 125, 138, 18, 44, 152, 12, 236, 117, 194, 83, 192, 255, 109, 223,
  237, 31, 203, 170, 40, 188, 90, 46, 196, 124, 243, 153, 127, 247, 116,
  174, 67, 233, 199, 148, 111, 68, 60, 78, 196, 119, 159, 218, 85, 112, 9,
  20, 70, 168, 77, 46, 26, 39, 19, 10, 172, 159, 135, 10, 126, 25, 133, 207,
  193, 32, 153, 125, 101, 51, 85, 78, 78, 76, 145, 186, 102, 249, 78, 182,
  138, 224, 17, 207, 21, 205, 50, 139, 223, 5, 196, 78, 254, 239, 82, 129,
  222, 22, 146, 245, 178, 205, 169, 168, 138, 147, 24, 111, 69, 94, 113,
  190, 157, 82, 233, 87, 134, 149, 253, 91, 161, 128, 45, 254, 81, 75, 102,
  26, 154, 159, 73, 163, 198, 6, 27, 84, 136, 165, 116, 190, 234, 17, 160,
  0, 237, 120, 150, 252, 123, 174, 238, 136, 29, 226, 211, 20, 86, 104, 122,
  135, 241, 17, 229, 207, 122, 66, 137, 164, 26, 1, 90, 106, 143, 182, 69,
  160, 186, 10, 231, 57, 79, 226, 209, 186, 123, 82, 231, 228, 66, 239, 214,
  104, 200, 97, 1, 229, 102, 128, 77, 105, 54, 118, 58, 85, 36, 239, 133,
  35, 4, 208, 141, 19, 177, 172, 108, 109, 158, 39, 67, 70, 48, 175, 212,
  181, 75, 50, 248, 98, 94, 161, 124, 249, 187, 158, 137, 78, 35, 142, 90,
  130, 113, 121, 63, 37, 75, 93, 174, 22, 116, 115, 105, 215, 221, 147, 117,
  40, 142, 38, 105, 43, 154, 169, 39, 80, 46, 54, 6, 153, 143, 248, 193,
  110, 232, 77, 140, 97, 20, 122, 253, 82, 80, 205, 249, 140, 168, 142, 2,
  223, 155, 128, 75, 248, 75, 168, 70, 113, 130, 196, 104, 101, 111, 182,
  38, 250, 55, 24, 156, 73, 175, 78, 54, 10, 2, 142, 253, 206, 4, 203, 177,
  223, 95, 231, 45, 12, 123, 121, 237, 149, 191, 49, 93, 82, 157, 85, 85,
  150, 34, 241, 236, 87, 9, 188, 172, 151, 95, 88, 0, 96, 233, 215, 130,
  247, 157, 10, 30, 153, 249, 198, 159, 188, 47, 80, 175, 219, 171, 55, 172,
  214, 231, 54, 88, 50, 87, 113, 84, 10, 35, 170, 122, 95, 172, 73, 224, 97,
  98, 40, 154, 135, 94, 138, 109, 51, 189, 149, 176, 52, 157, 107, 24, 24,
  29, 162, 83, 20, 228, 197, 163, 163, 238, 110, 166, 213, 132, 35, 170, 64,
  242, 159, 44, 95, 224, 242, 254, 122, 158, 181, 214, 216, 224, 3, 35, 116,
  226, 246, 19, 248, 231, 154, 189, 72, 33, 31, 169, 34, 204, 99, 76, 10,
  53, 126, 52, 168, 112, 187, 51, 173, 10, 102, 170, 247, 18, 78, 234, 54,
  211, 165, 112, 68, 85, 113, 248, 165, 90, 95, 20, 73, 121, 40, 238, 115,
  29, 127, 223, 179, 252, 77, 107, 41, 233, 119, 239, 75, 208, 61, 188, 201,
  35, 230, 215, 3, 203, 141, 124, 210, 180, 252, 0, 244, 148, 190, 96, 45,
  218, 234, 120, 143, 136, 0, 63, 71, 215, 9, 233, 27, 226, 29, 255, 112,
  64, 236, 165, 65, 39, 106, 34, 34, 251, 252, 188, 32, 22, 248, 150, 68,
  92, 9, 7, 51, 205, 132, 0, 6, 163, 147, 64, 96, 168, 207, 235, 109, 138,
  29, 14, 222, 104, 141, 97, 183, 117, 142, 38, 24, 192, 54, 206, 104, 2,
  60, 14, 77, 234, 182, 41, 16, 192, 3, 11, 212, 104, 224, 47, 27, 103, 213,
  167, 183, 122, 62, 130, 179, 122, 238, 33, 222, 93, 207, 238, 117, 105,
  121, 98, 103, 89, 63, 132, 168, 32, 102, 244, 240, 17, 11, 169, 78, 167,
  247, 253, 226, 174, 213, 116, 125, 99, 26, 104, 54, 38, 252, 208, 135,
  176, 93, 10, 29, 99, 217, 155, 198, 41, 244, 42, 99, 20, 233, 212, 193,
  175, 27, 123, 120, 187, 155, 167, 14, 70, 225, 203, 18, 129, 59, 177, 135,
  0, 253, 4, 127, 159, 55, 87, 215, 194, 208, 4, 233, 94, 45, 130, 213, 231,
  90, 204, 99, 90, 41, 166, 93, 8, 26, 16, 124, 14, 31, 133, 16, 184, 128,
  209, 178, 247, 223, 211, 9, 126, 96, 26, 86, 43, 126, 17, 122, 13, 90,
  107, 153, 193, 86, 38, 19, 217, 117, 72, 241, 184, 164, 142, 164, 169,
  236, 226, 114, 169, 22, 230, 168, 113, 128, 3, 166, 49, 94, 71, 45, 161,
  32, 77, 164, 126, 197, 226, 131, 188, 176, 114, 127, 31, 162, 200, 168,
  107, 131, 88, 62, 248, 72, 131, 225, 113, 146, 189, 252, 104, 148, 17, 54,
  60, 191, 206, 161, 113, 85, 201, 26, 201, 124, 23, 145, 134, 18, 187, 143,
  35, 246, 74, 116, 43, 37, 104, 247, 250, 47, 59, 251, 147, 96, 205, 207,
  132, 202, 97, 188, 169, 134, 15, 95, 186, 31, 156, 183, 0, 241, 131, 134,
  0, 60, 150, 147, 59, 17, 154, 73, 245, 18, 60, 180, 181, 113, 199, 143,
  96, 162, 197, 249, 64, 37, 174, 217, 48, 23, 125, 141, 213, 227, 250, 139,
  194, 76, 234, 22, 185, 238, 114, 88, 11, 63, 8, 88, 218, 81, 49, 31, 214,
  212, 61, 39, 191, 199, 97, 63, 47, 94, 252, 197, 2, 95, 243, 50, 151, 254,
  53, 244, 196, 57, 60, 48, 84, 14, 85, 210, 163, 49, 214, 71, 191, 159,
  239, 165, 66, 155, 85, 240, 92, 90, 58, 120, 18, 203, 188, 80, 38, 188,
  177, 112, 176, 104, 159, 214, 211, 49, 92, 122, 65, 176, 56, 70, 32, 153,
  69, 12, 137, 199, 159, 70, 242, 180, 60, 116, 235, 100, 88, 250, 67, 225,
  104, 129, 73, 155, 170, 100, 123, 243, 47, 17, 10, 137, 184, 62, 3, 243,
  52, 244, 147, 118, 184, 23, 7, 22, 68, 206, 41, 167, 203, 166, 226, 214,
  179, 243, 249, 22, 118, 224, 103, 56, 56, 6, 246, 47, 40, 107, 192, 56,
  21, 52, 166, 220, 103, 219, 84, 210, 20, 25, 86, 38, 177, 157, 192, 163,
  67, 170, 96, 42, 119, 203, 205, 140, 216, 235, 228, 138, 42, 179, 125, 73,
  112, 199, 180, 38, 159, 100, 92, 144, 158, 240, 183, 206, 42, 240, 206,
  246, 182, 64, 57, 73, 102, 164, 229, 140, 89, 219, 234, 99, 169, 110, 124,
  93, 187, 91, 5, 197, 88, 41, 1, 66, 146, 14, 130, 112, 190, 28, 17, 121,
  217, 113, 31, 235, 205, 164, 192, 101, 248, 130, 49, 57, 239, 87, 6, 117,
  129, 118, 61, 213, 219, 48, 69, 113, 183, 50, 63, 154, 227, 103, 129, 67,
  113, 152, 247, 179, 81, 136, 234, 96, 146, 93, 139, 195, 107, 218, 150,
  43, 129, 31, 83, 57, 171, 234, 11, 90, 70, 168, 0, 210, 130, 61, 110, 215,
  251, 161, 61, 146, 115, 154, 161, 173, 138, 66, 246, 61, 16, 80, 74, 118,
  103, 144, 216, 219, 112, 55, 213, 48, 245, 201, 240, 77, 95, 231, 217,
  204, 206, 52, 227, 247, 58, 129, 101, 231, 39, 179, 187, 66, 114, 90, 193,
  69, 203, 202, 252, 98, 130, 146, 161, 54, 73, 171, 169, 201, 24, 125, 17,
  232, 185, 65, 27, 212, 225, 142, 96, 83, 23, 141, 91, 154, 161, 82, 253,
  250, 154, 50, 85, 221, 27, 181, 168, 115, 243, 249, 24, 229, 154, 136,
  115, 110, 22, 215, 166, 63, 19, 19, 201, 187, 59, 84, 17, 129, 112, 146,
  99, 19, 176, 207, 119, 11, 221, 214, 6, 22, 135, 225, 145, 116, 61, 101,
  128, 86, 218, 210, 110, 98, 19, 196, 117, 248, 198, 13, 150, 109, 30, 110,
  52, 63, 220, 170, 214, 226, 98, 151, 123, 196, 233, 165, 198, 142, 75, 5,
  188, 241, 159, 34, 56, 101, 61, 61, 208, 140, 179, 25, 137, 133, 126, 176,
  166, 24, 206, 133, 61, 93, 128, 255, 216, 97, 7, 51, 251, 48, 77, 208,
  139, 158, 187, 216, 216, 159, 10, 114, 243, 31, 248, 81, 160, 119, 189,
  223, 75, 79, 45, 13, 135, 193, 229, 247, 146, 241, 114, 63, 65, 34, 103,
  96, 197, 5, 15, 228, 45, 208, 200, 201, 149, 74, 46, 99, 182, 201, 143,
  184, 44, 158, 59, 55, 53, 10, 249, 119, 8, 239, 174, 244, 168, 15, 150,
  65, 182, 186, 50, 9, 197, 176, 240, 243, 177, 181, 82, 251, 12, 35, 244,
  23, 158, 62, 152, 43, 237, 51, 211, 29, 207, 90, 156, 11, 80, 199, 193,
  116, 230, 151, 152, 253, 244, 86, 155, 8, 246, 184, 99, 43, 64, 196, 93,
  91, 169, 5, 237, 2, 58, 208, 89, 225, 206, 31, 28, 145, 32, 74, 48, 19,
  51, 198, 183, 239, 52, 216, 188, 152, 93, 110, 140, 45, 146, 49, 31, 172,
  117, 50, 8, 68, 204, 3, 219, 117, 40, 195, 232, 179, 200, 186, 120, 55, 1,
  98, 168, 120, 112, 182, 218, 222, 77, 113, 255, 189, 0, 145, 88, 72, 199,
  87, 204, 105, 46, 188, 77, 77, 183, 21, 86, 50, 217, 195, 10, 215, 29,
  174, 155, 62, 219, 72, 127, 181, 80, 179, 177, 175, 56, 213, 65, 60, 99,
  177, 55, 13, 205, 246, 35, 202, 103, 215, 113, 109, 185, 87, 185, 90, 1,
  74, 88, 149, 187, 230, 81, 3, 135, 170, 73, 70, 113, 118, 183, 250, 209,
  208, 248, 17, 196, 36, 188, 128, 185, 49, 134, 150, 109, 195, 14, 193,
  142, 43, 5, 117, 148, 15, 44, 146, 145, 162, 124, 202, 239, 125, 205, 130,
  189, 221, 253, 171, 73, 36, 127, 35, 12, 230, 153, 159, 37, 227, 82, 188,
  226, 108, 182, 130, 61, 109, 126, 142, 254, 243, 43, 88, 172, 30, 193,
  120, 152, 144, 252, 40, 31, 19, 181, 118, 27, 67, 167, 254, 242, 98, 87,
  192, 22, 173, 173, 129, 9, 112, 118, 90, 142, 175, 41, 80, 198, 23, 17,
  83, 197, 163, 252, 4, 122, 249, 125, 71, 27, 87, 71, 25, 237, 131, 144,
  189, 244, 140, 222, 11, 95, 136, 166, 112, 88, 4, 27, 250, 7, 221, 159,
  118, 34, 181, 112, 11, 64, 222, 95, 71, 127, 210, 89, 11, 73, 127, 217,
  215, 250, 135, 223, 224, 155, 28, 210, 170, 127, 45, 124, 148, 155, 124,
  131, 63, 122, 133, 21, 47, 147, 36, 189, 176, 145, 73, 8, 31, 197, 138,
  43, 160, 163, 46, 72, 48, 26, 56, 171, 138, 52, 22, 183, 191, 234, 107,
  230, 202, 87, 255, 108, 172, 132, 164, 154, 136, 200, 85, 131, 4, 188,
  106, 1, 213, 42, 49, 221, 70, 222, 112, 99, 71, 105, 206, 13, 103, 223,
  37, 104, 36, 97, 253, 149, 222, 81, 232, 233, 228, 223, 136, 123, 201, 10,
  51, 175, 80, 168, 198, 238, 40, 161, 113, 170, 46, 144, 194, 218, 152, 80,
  2, 228, 221, 68, 191, 91, 81, 21, 216, 68, 156, 117, 145, 88, 111, 241,
  201, 33, 158, 35, 245, 69, 140, 162, 43, 108, 46, 119, 69, 224, 121, 136,
  77, 60, 118, 219, 151, 147, 79, 161, 234, 193, 46, 216, 223, 241, 235, 15,
  227, 27, 71, 234, 235, 163, 143, 130, 106, 244, 202, 23, 222, 185, 52,
  109, 150, 43, 81, 68, 218, 162, 175, 76, 165, 133, 232, 172, 104, 240,
  226, 134, 16, 186, 202, 60, 42, 91, 209, 128, 4, 255, 126, 156, 142, 240,
  143, 224, 240, 6, 99, 63, 215, 74, 71, 57, 18, 25, 69, 147, 86, 156, 252,
  157, 227, 171, 157, 16, 97, 101, 77, 70, 218, 212, 50, 68, 151, 107, 173,
  140, 221, 186, 217, 39, 38, 23, 217, 75, 251, 73, 178, 6, 226, 9, 187,
  228, 75, 198, 93, 191, 180, 26, 29, 61, 215, 135, 0, 236, 65, 44, 44, 178,
  24, 2, 98, 92, 151, 250, 68, 45, 196, 178, 174, 95, 57, 217, 88, 109, 163,
  237, 97, 202, 146, 231, 39, 197, 27, 242, 111, 191, 11, 209, 2, 157, 4,
  26, 53, 147, 250, 142, 66, 205, 77, 230, 84, 149, 54, 61, 20, 212, 64, 63,
  241, 99, 236, 186, 120, 28, 46, 209, 123, 254, 86, 98, 0, 138, 191, 2,
  182, 250, 179, 66, 223, 193, 128, 255, 15, 99, 4, 10, 178, 133, 157, 14,
  32, 203, 42, 221, 160, 7, 178, 47, 76, 139, 131, 108, 252, 88, 144, 41,
  19, 219, 168, 209, 248, 193, 129, 87, 178, 121, 56, 132, 81, 36, 95, 30,
  94, 242, 77, 224, 115, 59, 208, 142, 175, 107, 199, 192, 102, 148, 26, 36,
  167, 213, 108, 105, 185, 99, 180, 100, 172, 163, 239, 248, 232, 54, 169,
  182, 252, 134, 84, 112, 66, 26, 26, 83, 143, 162, 198, 214, 2, 238, 137,
  195, 165, 17, 35, 221, 8, 101, 32, 60, 84, 138, 142, 102, 241, 35, 254,
  168, 190, 110, 62, 58, 48, 228, 105, 219, 58, 159, 176, 162, 226, 32, 85,
  218, 125, 124, 221, 39, 175, 59, 247, 110, 182, 130, 30, 74, 16, 141, 232,
  113, 203, 141, 234, 42, 90, 251, 56, 93, 1, 155, 255, 4, 61, 67, 16, 45,
  233, 195, 74, 14, 148, 118, 247, 224, 170, 141, 226, 83, 190, 209, 90, 52,
  225, 120, 201, 238, 76, 205, 12, 56, 42, 84, 122, 94, 236, 24, 124, 135,
  162, 216, 144, 5, 231, 108, 160, 33, 196, 99, 2, 253, 175, 57, 59, 5, 5,
  229, 22, 241, 38, 124, 184, 65, 82, 96, 211, 145, 15, 28, 127, 144, 231,
  172, 111, 184, 251, 71, 214, 144, 96, 120, 141, 128, 86, 97, 84, 138, 124,
  170, 163, 19, 11, 182, 182, 109, 254, 119, 233, 73, 111, 148, 9, 76, 180,
  118, 20, 29, 186, 3, 239, 245, 179, 123, 131, 15, 203, 215, 64, 58, 103,
  141, 29, 1, 206, 182, 168, 211, 118, 152, 246, 68, 115, 160, 39, 15, 34,
  137, 174, 170, 139, 118, 205, 18, 166, 228, 84, 142, 89, 177, 201, 13,
  163, 68, 179, 220, 63, 186, 100, 26, 205, 147, 241, 125, 188, 114, 166,
  168, 214, 101, 148, 64, 255, 32, 213, 2, 39, 51, 54, 98, 73, 189, 113, 14,
  105, 86, 224, 105, 177, 50, 53, 137, 173, 153, 113, 215, 6, 112, 129, 113,
  254, 98, 74, 119, 15, 247, 114, 237, 165, 134, 247, 227, 116, 181, 89,
  189, 44, 82, 7, 197, 140, 154, 123, 157, 101, 147, 57, 162, 143, 248, 143,
  130, 105, 154, 245, 198, 109, 38, 139, 206, 255, 170, 63, 33, 132, 120,
  225, 213, 29, 186, 168, 204, 124, 239, 196, 135, 24, 6, 101, 214, 62, 42,
  239, 45, 29, 249, 186, 168, 116, 84, 54, 130, 98, 170, 116, 128, 114, 163,
  19, 211, 28, 142, 7, 105, 152, 188, 17, 41, 9, 40, 31, 137, 69, 98, 99,
  209, 80, 30, 210, 31, 112, 147, 223, 106, 65, 74, 102, 16, 105, 32, 209,
  115, 183, 70, 46, 253, 79, 186, 27, 17, 53, 145, 57, 16, 18, 249, 21, 170,
  9, 110, 191, 115, 34, 71, 119, 189, 22, 154, 231, 154, 248, 11, 228, 71,
  198, 15, 26, 224, 38, 25, 169, 76, 164, 50, 170, 185, 112, 186, 131, 212,
  191, 1, 32, 168, 92, 20, 231, 64, 167, 193, 191, 176, 62, 89, 182, 142,
  23, 3, 83, 15, 121, 74, 177, 116, 92, 88, 175, 236, 69, 253, 16, 29, 223,
  197, 138, 120, 154, 185, 221, 48, 133, 126, 27, 237, 128, 103, 148, 210,
  131, 95, 107, 23, 46, 56, 167, 145, 190, 69, 86, 188, 247, 95, 173, 187,
  35, 43, 163, 180, 201, 209, 192, 209, 145, 82, 43, 252, 82, 23, 13, 182,
  165, 210, 194, 92, 116, 250, 100, 67, 159, 132, 149, 100, 137, 84, 28,
  207, 105, 13, 61, 46, 125, 9, 113, 107, 194, 192, 145, 215, 180, 70, 27,
  25, 232, 220, 143, 29, 64, 188, 208, 11, 5, 217, 195, 95, 11, 226, 99,
  226, 202, 117, 107, 141, 55, 47, 110, 185, 198, 214, 148, 177, 209, 150,
  115, 19, 201, 205, 173, 240, 126, 174, 139, 213, 215, 4, 20, 93, 40, 108,
  184, 252, 100, 117, 54, 120, 127, 71, 164, 252, 248, 73, 134, 43, 50, 223,
  72, 139, 146, 185, 113, 37, 173, 162, 140, 210, 36, 197, 16, 159, 116,
  146, 212, 97, 129, 248, 252, 137, 148, 96, 130, 108, 207, 41, 123, 207,
  247, 99, 253, 174, 13, 172, 214, 186, 194, 207, 255, 160, 146, 197, 250,
  218, 110, 193, 19, 126, 76, 99, 88, 109, 50, 133, 187, 206, 116, 15, 209,
  124, 81, 188, 88, 28, 239, 241, 68, 71, 30, 125, 130, 30, 163, 109, 156,
  140, 112, 238, 93, 40, 208, 8, 228, 161, 227, 255, 189, 175, 5, 196, 237,
  181, 101, 119, 83, 186, 137, 212, 113, 131, 49, 155, 122, 115, 159, 54,
  15, 118, 9, 86, 194, 205, 140, 33, 3, 2, 8, 209, 31, 160, 5, 26, 29, 179,
  252, 153, 210, 92, 242, 83, 22, 96, 77, 61, 123, 228, 118, 67, 79, 2, 24,
  232, 6, 212, 50, 214, 184, 47, 24, 75, 218, 160, 190, 132, 42, 190, 85,
  178, 230, 70, 209, 83, 40, 150, 176, 134, 124, 95, 64, 234, 163, 212, 96,
  199, 78, 199, 173, 26, 35, 27, 118, 73, 145, 184, 139, 43, 35, 76, 147,
  177, 162, 94, 229, 98, 171, 14, 46, 208, 6, 112, 65, 174, 229, 128, 49,
  29, 201, 75, 48, 215, 137, 188, 236, 13, 212, 21, 119, 253, 188, 78, 111,
  121, 178, 2, 90, 201, 58, 247, 93, 183, 16, 138, 238, 202, 46, 77, 40, 28,
  186, 126, 229, 217, 198, 190, 166, 118, 52, 100, 235, 95, 215, 152, 60,
  22, 123, 235, 208, 48, 195, 127, 216, 189, 98, 138, 170, 244, 222, 121,
  203, 204, 165, 17, 105, 49, 91, 184, 121, 158, 51, 149, 156, 199, 28, 160,
  162, 7, 203, 60, 123, 240, 151, 247, 50, 224, 222, 134, 205, 115, 72, 108,
  1, 46, 27, 124, 178, 175, 222, 19, 123, 65, 53, 77, 88, 82, 193, 241, 10,
  101, 131, 207, 118, 110, 113, 49, 17, 170, 118, 1, 15, 99, 195, 210, 237,
  181, 230, 52, 59, 177, 115, 59, 235, 209, 57, 128, 200, 222, 8, 111, 7,
  77, 244, 9, 109, 251, 236, 126, 225, 19, 96, 91, 89, 98, 39, 224, 173, 70,
  143, 68, 105, 177, 253, 12, 92, 79, 88, 206, 36, 131, 100, 187, 83, 223,
  162, 171, 84, 29, 69, 232, 111, 240, 37, 4, 142, 117, 49, 86, 204, 217,
  36, 58, 36, 14, 110, 221, 16, 25, 187, 243, 29, 69, 19, 77, 43, 10, 81,
  35, 229, 229, 56, 247, 67, 129, 100, 210, 148, 41, 239, 233, 71, 138, 191,
  3, 74, 15, 159, 223, 60, 201, 210, 159, 75, 30, 216, 131, 177, 171, 63,
  243, 189, 39, 156, 255, 115, 181, 240, 9, 216, 184, 228, 203, 135, 242,
  108, 108, 167, 18, 50, 171, 23, 139, 149, 232, 41, 184, 38, 216, 232, 103,
  50, 116, 146, 141, 187, 204, 60, 249, 140, 13, 13, 105, 140, 113, 184,
  121, 234, 199, 32, 171, 19, 246, 192, 99, 194, 54, 160, 95, 177, 99, 92,
  180, 157, 84, 10, 127, 141, 252, 62, 59, 139, 84, 155, 77, 212, 14, 91,
  176, 163, 216, 2, 156, 228, 233, 33, 150, 223, 181, 194, 96, 50, 46, 77,
  160, 238, 166, 35, 0, 180, 8, 126, 15, 94, 8, 10, 38, 95, 85, 133, 163,
  151, 19, 253, 34, 103, 42, 122, 214, 221, 45, 138, 213, 160, 207, 94, 118,
  33, 129, 192, 22, 161, 183, 211, 192, 141, 206, 197, 141, 46, 254, 124,
  75, 232, 26, 175, 77, 184, 238, 26, 89, 141, 118, 139, 73, 181, 113, 225,
  249, 132, 108, 8, 9, 207, 153, 76, 233, 21, 53, 169, 217, 101, 134, 227,
  215, 199, 229, 87, 31, 234, 39, 17, 136, 196, 90, 14, 77, 253, 208, 19,
  229, 43, 254, 2, 113, 83, 70, 76, 39, 39, 71, 135, 1, 178, 143, 91, 205,
  28, 102, 87, 226, 70, 75, 174, 75, 163, 126, 86, 62, 65, 135, 139, 132,
  134, 62, 92, 186, 0, 3, 87, 253, 109, 166, 56, 186, 124, 224, 49, 171, 32,
  239, 46, 163, 105, 168, 243, 142, 111, 100, 207, 208, 8, 112, 94, 145, 30,
  25, 113, 225, 69, 233, 223, 242, 33, 197, 204, 3, 84, 51, 189, 88, 153,
  88, 61, 135, 22, 226, 177, 222, 149, 70, 166, 199, 39, 103, 175, 198, 18,
  183, 119, 92, 85, 53, 170, 105, 116, 97, 211, 71, 207, 5, 107, 245, 154,
  212, 3, 134, 206, 43, 122, 224, 195, 26, 189, 26, 215, 179, 199, 18, 252,
  178, 101, 185, 194, 169, 155, 177, 136, 211, 180, 234, 88, 224, 23, 219,
  175, 50, 35, 74, 241, 147, 108, 127, 110, 211, 241, 159, 208, 233, 194,
  169, 5, 116, 155, 160, 122, 144, 98, 200, 215, 49, 9, 131, 140, 124, 155,
  82, 222, 231, 224, 203, 65, 115, 94, 200, 113, 140, 192, 125, 35, 167,
  131, 152, 158, 65, 193, 57, 81, 172, 232, 45, 184, 65, 58, 12, 211, 106,
  227, 253, 78, 175, 84, 208, 243, 113, 100, 64, 105, 39, 245, 223, 115,
  252, 106, 79, 192, 166, 25, 149, 141, 240, 215, 189, 183, 193, 74, 191,
  115, 80, 98, 25, 182, 1, 164, 156, 11, 19, 71, 109, 217, 109, 255, 1, 216,
  241, 149, 113, 74, 90, 43, 10, 200, 231, 40, 73, 231, 71, 206, 127, 243,
  159, 186, 171, 57, 116, 9, 90, 16, 50, 170, 7, 5, 80, 60, 128, 74, 68,
  178, 98, 246, 112, 186, 72, 226, 183, 192, 4, 57, 30, 221, 49, 203, 237,
  3, 37, 253, 47, 199, 202, 40, 56, 101, 177, 150, 211, 151, 165, 103, 235,
  211, 209, 137, 48, 3, 46, 6, 198, 36, 167, 251, 190, 73, 214, 8, 208, 249,
  5, 7, 245, 169, 195, 230, 116, 108, 129, 180, 55, 109, 203, 124, 11, 179,
  45, 168, 54, 20, 54, 230, 253, 127, 195, 122, 236, 175, 164, 205, 245, 77,
  195, 114, 11, 195, 143, 245, 123, 232, 241, 92, 213, 199, 27, 170, 230,
  32, 66, 175, 127, 90, 147, 1, 233, 76, 20, 229, 86, 126, 167, 191, 216,
  117, 85, 248, 188, 214, 233, 139, 85, 194, 8, 214, 157, 235, 168, 178, 35,
  192, 177, 124, 140, 70, 212, 118, 116, 122, 237, 20, 105, 229, 14, 177,
  231, 201, 99, 140, 97, 104, 26, 226, 67, 233, 25, 176, 52, 80, 136, 220,
  144, 204, 192, 104, 0, 152, 83, 175, 255, 123, 40, 116, 20, 191, 79, 68,
  61, 224, 212, 76, 214, 190, 234, 87, 66, 224, 51, 187, 102, 40, 48, 155,
  106, 216, 105, 212, 109, 233, 114, 120, 225, 157, 130, 13, 58, 44, 111,
  223, 211, 69, 108, 65, 17, 213, 188, 75, 197, 242, 40, 74, 33, 98, 9, 18,
  204, 193, 122, 100, 206, 204, 189, 243, 173, 71, 110, 230, 243, 103, 165,
  99, 18, 87, 209, 183, 34, 195, 2, 199, 193, 182, 151, 146, 107, 202, 166,
  222, 79, 196, 141, 89, 197, 254, 184, 16, 52, 3, 216, 9, 53, 77, 29, 222,
  128, 148, 43, 117, 43, 166, 59, 153, 207, 153, 90, 211, 120, 255, 110, 91,
  98, 130, 171, 149, 92, 43, 179, 43, 26, 185, 15, 7, 16, 93, 111, 85, 162,
  32, 143, 14, 0, 173, 1, 70, 197, 216, 170, 231, 142, 174, 238, 209, 32,
  22, 228, 208, 39, 98, 15, 50, 13, 69, 220, 169, 208, 68, 64, 101, 209,
  117, 175, 93, 212, 253, 73, 75, 249, 1, 53, 180, 94, 123, 82, 168, 32, 65,
  138, 136, 252, 90, 66, 193, 185, 60, 248, 172, 161, 228, 128, 130, 110,
  118, 92, 198, 57, 51, 83, 82, 240, 65, 116, 148, 223, 206, 148, 124, 109,
  54, 202, 28, 169, 202, 100, 27, 235, 237, 49, 50, 188, 72, 88, 186, 97,
  40, 18, 81, 157, 120, 109, 193, 46, 3, 80, 53, 182, 31, 214, 165, 32, 151,
  94, 4, 113, 78, 220, 205, 36, 133, 237, 151, 1, 50, 160, 63, 210, 65, 84,
  148, 88, 33, 14, 208, 92, 174, 117, 164, 181, 197, 155, 238, 144, 246, 26,
  12, 208, 60, 58, 95, 121, 105, 133, 29, 64, 24, 41, 221, 184, 39, 77, 169,
  113, 139, 160, 37, 232, 100, 83, 184, 209, 4, 53, 48, 235, 62, 103, 247,
  21, 56, 60, 109, 154, 76, 6, 93, 94, 69, 19, 75, 204, 65, 9, 223, 116,
  251, 245, 114, 21, 244, 247, 46, 152, 61, 215, 105, 247, 45, 61, 11, 115,
  163, 17, 55, 206, 54, 15, 173, 115, 127, 12, 2, 62, 227, 160, 3, 42, 253,
  55, 165, 149, 2, 231, 134, 121, 66, 79, 25, 123, 217, 139, 173, 87, 232,
  232, 94, 148, 169, 166, 32, 36, 158, 203, 141, 145, 26, 124, 178, 84, 239,
  23, 204, 104, 198, 186, 144, 151, 81, 151, 236, 130, 249, 72, 85, 103,
  109, 183, 120, 149, 45, 62, 90, 238, 145, 34, 109, 209, 126, 129, 207,
  129, 76, 92, 184, 58, 121, 107, 49, 39, 74, 160, 210, 35
};

#define N 40

int
blowfish_main ()
{
  unsigned char ukey[8];
  unsigned char indata[N];
  unsigned char outdata[N];

  int num;
  int i, j, k, l;
  int encordec;
  int check;

  num = 0;
  k = 0;
  l = 0;
  encordec = 1;
  check = 0;
  for (i = 0; i < 8; i++)
    {
      ukey[i] = 0;
      ivec[i] = 0;
    }
  BF_set_key (8, ukey);
  i = 0;
  while (k < KEYSIZE)
    {
      while (k < KEYSIZE && i < N)
	indata[i++] = in_key[k++];

      BF_cfb64_encrypt (indata, outdata, i, ivec, &num, encordec);

      for (j = 0; j < i; j++)
	check += (outdata[j] != out_key[l++]);

      i = 0;
    }
  return check;
}

int
main ()
{
  int main_result;

      main_result = 0;
      main_result = blowfish_main ();

      printf ("%d\n", main_result);

      return main_result;
    }


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*
 * Copyright (C) 2008
 * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
 * Nagoya University, Japan
 * All rights reserved.
 *
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis. The authors disclaims any and all warranties,
 * whether express, implied, or statuary, including any implied warranties or
 * merchantability or of fitness for a particular purpose. In no event shall the
 * copyright-holder be liable for any incidental, punitive, or consequential damages
 * of any kind whatsoever arising from the use of these programs. This disclaimer
 * of warranty extends to the user of these programs and user's customers, employees,
 * agents, transferees, successors, and assigns.
 *
 */
#include <stdio.h>
#include "softfloat.c"

double
ullong_to_double (unsigned long long x)


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*============================================================================

This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
Package, Release 2b.

Written by John R. Hauser.  This work was made possible in part by the
International Computer Science Institute, located at Suite 600, 1947 Center
Street, Berkeley, California 94704.  Funding was partially provided by the
National Science Foundation under grant MIP-9311980.  The original version
of this code was written as part of a project to build a fixed-point vector
processor in collaboration with the University of California at Berkeley,
overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
arithmetic/SoftFloat.html'.

THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.

Derivative works are acceptable, even for commercial purposes, so long as
(1) the source code for the derivative work includes prominent notice that
the work is derivative, and (2) the source code includes prominent notice with
these four paragraphs for those parts of this code that are retained.

=============================================================================*/

/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point types.
*----------------------------------------------------------------------------*/


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*
 * Copyright (C) 2008
 * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
 * Nagoya University, Japan
 * All rights reserved.
 *
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis. The authors disclaims any and all warranties,
 * whether express, implied, or statuary, including any implied warranties or
 * merchantability or of fitness for a particular purpose. In no event shall the
 * copyright-holder be liable for any incidental, punitive, or consequential damages
 * of any kind whatsoever arising from the use of these programs. This disclaimer
 * of warranty extends to the user of these programs and user's customers, employees,
 * agents, transferees, successors, and assigns.
 *
 */
#include <stdio.h>
#include "softfloat.c"

float64
float64_abs (float64 x)

{
  return (x & 0x7fffffffffffffffULL);
}


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*
 * Copyright (C) 2008
 * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
 * Nagoya University, Japan
 * All rights reserved.
 *
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis. The authors disclaims any and all warranties,
 * whether express, implied, or statuary, including any implied warranties or
 * merchantability or of fitness for a particular purpose. In no event shall the
 * copyright-holder be liable for any incidental, punitive, or consequential damages
 * of any kind whatsoever arising from the use of these programs. This disclaimer
 * of warranty extends to the user of these programs and user's customers, employees,
 * agents, transferees, successors, and assigns.
 *
 */
/*
 *  Header file for decoding
 *
 *  @(#) $Id: decode.h,v 1.2 2003/07/18 10:19:21 honda Exp $
 */

#ifndef _DECODE_H_
#define _DECODE_H_

#define NUM_HUFF_TBLS       2
#define NUM_QUANT_TBLS      4
#define DCTSIZE             8
#define DCTSIZE2           64

/*
 * Fix the number of components as 3
 */
#define NUM_COMPONENT       3

#define RGB_NUM  3

/*
 * Define the sample precision as 8
 */
#define IDCT_SHIFT 128
#define IDCT_BOUNT 255
#define MARKER_MARKER 0xff

/* SAMPLING_FACTOR */
#define SF1_1_1  0
#define SF4_1_1  2

char p_jinfo_data_precision;
short p_jinfo_image_height;
short p_jinfo_image_width;
char p_jinfo_num_components;
int p_jinfo_smp_fact;

char p_jinfo_comps_info_index[NUM_COMPONENT];
char p_jinfo_comps_info_id[NUM_COMPONENT];
char p_jinfo_comps_info_h_samp_factor[NUM_COMPONENT];
char p_jinfo_comps_info_v_samp_factor[NUM_COMPONENT];
char p_jinfo_comps_info_quant_tbl_no[NUM_COMPONENT];
char p_jinfo_comps_info_dc_tbl_no[NUM_COMPONENT];
char p_jinfo_comps_info_ac_tbl_no[NUM_COMPONENT];

unsigned int p_jinfo_quant_tbl_quantval[NUM_QUANT_TBLS][DCTSIZE2];

int p_jinfo_dc_xhuff_tbl_bits[NUM_HUFF_TBLS][36];
int p_jinfo_dc_xhuff_tbl_huffval[NUM_HUFF_TBLS][257];

int p_jinfo_ac_xhuff_tbl_bits[NUM_HUFF_TBLS][36];
int p_jinfo_ac_xhuff_tbl_huffval[NUM_HUFF_TBLS][257];

int p_jinfo_dc_dhuff_tbl_ml[NUM_HUFF_TBLS];
int p_jinfo_dc_dhuff_tbl_maxcode[NUM_HUFF_TBLS][36];
int p_jinfo_dc_dhuff_tbl_mincode[NUM_HUFF_TBLS][36];
int p_jinfo_dc_dhuff_tbl_valptr[NUM_HUFF_TBLS][36];

int p_jinfo_ac_dhuff_tbl_ml[NUM_HUFF_TBLS];

int p_jinfo_ac_dhuff_tbl_mincode[NUM_HUFF_TBLS][36];
int p_jinfo_ac_dhuff_tbl_valptr[NUM_HUFF_TBLS][36];

int p_jinfo_MCUWidth;
int p_jinfo_MCUHeight;
int p_jinfo_NumMCU;

unsigned char *p_jinfo_jpeg_data;

#endif /* _DECODE_H_ */


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*
 * Copyright (C) 2008
 * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
 * Nagoya University, Japan
 * All rights reserved.
 *
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis. The authors disclaims any and all warranties,
 * whether express, implied, or statuary, including any implied warranties or
 * merchantability or of fitness for a particular purpose. In no event shall the
 * copyright-holder be liable for any incidental, punitive, or consequential damages
 * of any kind whatsoever arising from the use of these programs. This disclaimer
 * of warranty extends to the user of these programs and user's customers, employees,
 * agents, transferees, successors, and assigns.
 *
 */
/*
 *  Transformation: JPEG -> BMP
 *
 *  @(#) $Id: jpeg2bmp.c,v 1.2 2003/07/18 10:19:21 honda Exp $
 */

/*
 * Buffer for reading JPEG file
 */
unsigned char JpegFileBuf[JPEG_FILE_SIZE];

int
jpeg2bmp_main ()
{
  int ci;
  unsigned char *c;
  int i, j;

  /*
   * Store input data in buffer
   */
  c = JpegFileBuf;
  for (i = 0; i < JPEGSIZE; i++)

    {
        ci = hana_jpg[i];
        *c++ = ci;
    }

  jpeg_read (JpegFileBuf);

  for (i = 0; i < RGB_NUM; i++)
    {
      for (j = 0; j < BMP_OUT_SIZE; j++)
	{
	  if (OutData_comp_buf[i][j] != hana_bmp[i][j])
	    {
	      main_result++;
	    }
	}
    }
  if (OutData_image_width != out_width)
    {
      main_result++;
    }

  if (OutData_image_height != out_length)
    {
      main_result++;


/*
+--------------------------------------------------------------------------+
| CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
| ======================================================================== |
|                                                                          |
| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda,               |
|                            H. Takada and K. Ishii                        |
|                            Nagoya University, Japan                      |
|                                                                          |
| * Remark :                                                               |
|    1. This source code is modified to unify the formats of the benchmark |
|       programs in CHStone.                                               |
|    2. Test vectors are added for CHStone.                                |
|    3. If "main_result" is 0 at the end of the program, the program is    |
|       correctly executed.                                                |
|    4. Please follow the copyright of each benchmark program.             |
+--------------------------------------------------------------------------+
*/
/*
 * Copyright (C) 2008
 * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
 * Nagoya University, Japan
 * All rights reserved.
 *
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis. The authors disclaims any and all warranties,
 * whether express, implied, or statuary, including any implied warranties or
 * merchantability or of fitness for a particular purpose. In no event shall the
 * copyright-holder be liable for any incidental, punitive, or consequential damages
 * of any kind whatsoever arising from the use of these programs. This disclaimer
 * of warranty extends to the user of these programs and user's customers, employees,
 * agents, transferees, successors, and assigns.
 *
 */
#include <stdio.h>
#include <stdlib.h>

#include "global.h"
#include "decode.h"
#include "init.h"
#include "marker.c"
#include "chenidct.c"
#include "huffman.h"
#include "decode.c"
#include "huffman.c"
#include "jfif_read.c"
#include "jpeg2bmp.c"

int
main ()
{
  main_result = 0;
  jpeg2bmp_main ();

  printf ("%d\n", main_result);