/*
+--------------------------------------------------------------------------+
| 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 "include/blowfish.h"
#include "include/bf_locl.h"
#include "include/bf_pi.h"
/*
#include "include/bf_skey.c"
#include "include/bf_cfb64.c"
#include "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

#ifdef __cplusplus
extern "C" {
#endif
/////////////////////////////////////////////////////
void BF_encrypt (BF_LONG *data, int encrypt)
{
  register BF_LONG l, r, *p, *s;
  p = key_P;
  s = &(key_S[0]);
  l = data[0];
  r = data[1];

  if (encrypt)
    {
      l ^= p[0];

      BF_ENC (r, l, s, p[1]);
      BF_ENC (l, r, s, p[2]);
      BF_ENC (r, l, s, p[3]);
      BF_ENC (l, r, s, p[4]);
      BF_ENC (r, l, s, p[5]);
      BF_ENC (l, r, s, p[6]);
      BF_ENC (r, l, s, p[7]);
      BF_ENC (l, r, s, p[8]);
      BF_ENC (r, l, s, p[9]);
      BF_ENC (l, r, s, p[10]);
      BF_ENC (r, l, s, p[11]);
      BF_ENC (l, r, s, p[12]);
      BF_ENC (r, l, s, p[13]);
      BF_ENC (l, r, s, p[14]);
      BF_ENC (r, l, s, p[15]);
      BF_ENC (l, r, s, p[16]);
      r ^= p[BF_ROUNDS + 1];
    }
  else
    {
      l ^= p[BF_ROUNDS + 1];
      BF_ENC (r, l, s, p[16]);
      BF_ENC (l, r, s, p[15]);
      BF_ENC (r, l, s, p[14]);
      BF_ENC (l, r, s, p[13]);
      BF_ENC (r, l, s, p[12]);
      BF_ENC (l, r, s, p[11]);
      BF_ENC (r, l, s, p[10]);
      BF_ENC (l, r, s, p[9]);
      BF_ENC (r, l, s, p[8]);
      BF_ENC (l, r, s, p[7]);
      BF_ENC (r, l, s, p[6]);
      BF_ENC (l, r, s, p[5]);
      BF_ENC (r, l, s, p[4]);
      BF_ENC (l, r, s, p[3]);
      BF_ENC (r, l, s, p[2]);
      BF_ENC (l, r, s, p[1]);
      r ^= p[0];
    }
  data[1] = l & 0xffffffff;
  data[0] = r & 0xffffffff;
}

/////////////////////////////////////////////////////
void memcpy_blowfish (BF_LONG * s1, const BF_LONG * s2, int n)
{
  BF_LONG *p1;
  const BF_LONG *p2;

  p1 = s1;
  p2 = s2;

  while (n-- > 0)
    {
      *p1 = *p2;
      p1++;
      p2++;
    }
}

/////////////////////////////////////////////////////
void BF_set_key (int len, unsigned char *data)
{
  int i;
  BF_LONG *p, ri, in[2];
  unsigned char *d, *end;

  memcpy_blowfish (key_P, bf_init_P, BF_ROUNDS + 2);
  memcpy_blowfish (key_S, bf_init_S, 4 * 256);
  p = key_P;

  if (len > ((BF_ROUNDS + 2) * 4))
    len = (BF_ROUNDS + 2) * 4;

  d = data;
  end = &(data[len]);
  for (i = 0; i < (BF_ROUNDS + 2); i++)
    {
      ri = *(d++);
      if (d >= end)
	d = data;

      ri <<= 8;
      ri |= *(d++);
      if (d >= end)
	d = data;

      ri <<= 8;
      ri |= *(d++);
      if (d >= end)
	d = data;

      ri <<= 8;
      ri |= *(d++);
      if (d >= end)
	d = data;

      p[i] ^= ri;
    }

  in[0] = 0L;
  in[1] = 0L;
  for (i = 0; i < (BF_ROUNDS + 2); i += 2)
    {
      BF_encrypt (in, BF_ENCRYPT);
      p[i] = in[0];
      p[i + 1] = in[1];
    }

  p = key_S;
  for (i = 0; i < 4 * 256; i += 2)
    {
      BF_encrypt (in, BF_ENCRYPT);
      p[i] = in[0];
      p[i + 1] = in[1];
    }

}

/////////////////////////////////////////////////////
void BF_cfb64_encrypt (unsigned char *in, unsigned char *out, long length, unsigned char *ivec, int *num, int encrypt)
{
  register BF_LONG v0, v1, t;
  register int n;
  register long l;

  unsigned char *iv, c, cc;

  n = *num;
  l = length;
  iv = (unsigned char *) ivec;
  if (encrypt)
    {
      while (l--)
	{
	  if (n == 0)
	    {
	      n2l (iv, v0);
	      ti[0] = v0;
	      n2l (iv, v1);
	      ti[1] = v1;
	      BF_encrypt ((unsigned long *) ti, BF_ENCRYPT);
	      iv = (unsigned char *) ivec;
	      t = ti[0];
	      l2n (t, iv);
	      t = ti[1];
	      l2n (t, iv);

	      iv = (unsigned char *) ivec;
	    }
	  c = *(in++) ^ iv[n];
	  *(out++) = c;
	  iv[n] = c;
	  n = (n + 1) & 0x07;
	}
    }
  else
    {
      while (l--)
	{
	  if (n == 0)
	    {
	      n2l (iv, v0);
	      ti[0] = v0;
	      n2l (iv, v1);
	      ti[1] = v1;
	      BF_encrypt ((unsigned long *) ti, BF_ENCRYPT);
	      iv = (unsigned char *) ivec;
	      t = ti[0];
	      l2n (t, iv);
	      t = ti[1];
	      l2n (t, iv);
	      iv = (unsigned char *) ivec;
	    }
	  cc = *(in++);
	  c = iv[n];
	  iv[n] = cc;
	  *(out++) = c ^ cc;
	  n = (n + 1) & 0x07;
	}
    }
  v0 = v1 = ti[0] = ti[1] = t = c = cc = 0;
  *num = n;
}

/////////////////////////////////////////////////////
int blowfish_main ()
{
  unsigned char ukey[8];
  unsigned char indata[N];
  unsigned char outdata[N];
  unsigned char ivec[8];
  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 < N; ++i)
    outdata[i] = 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;
}
#ifdef __cplusplus
}
#endif

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>

#ifdef __cplusplus
extern "C" {
#endif

#include "include/milieu.h"
#include "include/softfloat.h"

/*----------------------------------------------------------------------------
| Floating-point rounding mode, extended double-precision rounding precision,
| and exception flags.
*----------------------------------------------------------------------------*/
int8 float_rounding_mode = float_round_nearest_even;
int8 float_exception_flags = 0;

/*----------------------------------------------------------------------------
| Primitive arithmetic functions, including multi-word arithmetic, and
| division and square root approximations.  (Can be specialized to target if
| desired.)
*----------------------------------------------------------------------------*/
#include "include/softfloat-macros"

/*----------------------------------------------------------------------------
| Functions and definitions to determine:  (1) whether tininess for underflow
| is detected before or after rounding by default, (2) what (if anything)
| happens when exceptions are raised, (3) how signaling NaNs are distinguished
| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs
| are propagated from function inputs to output.  These details are target-
| specific.
*----------------------------------------------------------------------------*/
#include "include/softfloat-specialize"

#include "include/softfloat.c"
#ifdef __cplusplus
}
#endif

/*
+--------------------------------------------------------------------------+
| * Test Vectors (added for CHStone)                                       |
|     a_input, b_input : input data                                        |
|     z_output : expected output data                                      |
+--------------------------------------------------------------------------+
*/
#define N 46
const float64 a_input[N] = {
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x4000000000000000ULL,	/* 2.0 */
  0x4000000000000000ULL,	/* 2.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF8000000000000ULL,	/* 1.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF8000000000000ULL,	/* 1.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xC000000000000000ULL,	/* -2.0 */
  0xC000000000000000ULL,	/* -2.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0x8000000000000000ULL,	/* -0.0 */
  0xBFF8000000000000ULL,	/* -1.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0x8000000000000000ULL,	/* -0.0 */
  0xBFF8000000000000ULL,	/* -1.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF8000000000000ULL,	/* 1.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x4000000000000000ULL,	/* 2.0 */
  0xFFF0000000000000ULL,	/* -inf */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0x8000000000000000ULL,	/* -0.0 */
  0xBFF8000000000000ULL,	/* -1.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xC000000000000000ULL		/* -2.0 */
};

const float64 b_input[N] = {
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF8000000000000ULL,	/* 1.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x4000000000000000ULL,	/* 2.0 */
  0x4000000000000000ULL,	/* 2.0 */
  0x7FF0000000000000ULL,	/* inf */
  0x7FF0000000000000ULL,	/* inf */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0x8000000000000000ULL,	/* -0.0 */
  0xBFF8000000000000ULL,	/* -1.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xC000000000000000ULL,	/* -2.0 */
  0xC000000000000000ULL,	/* -2.0 */
  0xFFF0000000000000ULL,	/* -inf */
  0xFFF0000000000000ULL,	/* -inf */
  0x8000000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xFFF0000000000000ULL,	/* -inf */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xC000000000000000ULL,	/* -2.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFF0000000000000ULL,	/* -1.0 */
  0x8000000000000000ULL,	/* -0.0 */
  0xBFF8000000000000ULL,	/* -1.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x4000000000000000ULL,	/* 2.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x0000000000000000ULL,	/* 0.0 */
  0x3FF8000000000000ULL		/* 1.5 */
};

const float64 z_output[N] = {
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x4000000000000000ULL,	/* 2.0 */
  0x400C000000000000ULL,	/* 3.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x4000000000000000ULL,	/* 2.0 */
  0x400C000000000000ULL,	/* 3.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x0000000000000000ULL,	/* 0.0 */
  0x4004000000000000ULL,	/* 2.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xC000000000000000ULL,	/* -2.0 */
  0xC00C000000000000ULL,	/* -3.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xC000000000000000ULL,	/* -2.0 */
  0xC00C000000000000ULL,	/* -3.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0x8000000000000000ULL,	/* -0.0 */
  0xC004000000000000ULL,	/* -2.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FFFFFFFFFFFFFFFULL,	/* nan */
  0x0000000000000000ULL,	/* 0.0 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFE0000000000000ULL,	/* -0.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FE0000000000000ULL,	/* 0.5 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FFFFFFFFFFFFFFFULL,	/* nan */
  0x0000000000000000ULL,	/* 0.0 */
  0x7FF8000000000000ULL,	/* nan */
  0x7FF0000000000000ULL,	/* inf */
  0x3FF0000000000000ULL,	/* 1.0 */
  0x3FE0000000000000ULL,	/* 0.5 */
  0xFFF8000000000000ULL,	/* nan */
  0xFFF0000000000000ULL,	/* -inf */
  0xBFF0000000000000ULL,	/* -1.0 */
  0xBFE0000000000000ULL		/* -0.5 */
};

int
main ()
{

  int i;
  float64 x1, x2;
      main_result = 0;
      for (i = 0; i < N; i++)
	{
	  float64 result;
	  x1 = a_input[i];
	  x2 = b_input[i];
	  result = float64_add (x1, x2);
	  main_result += (result != z_output[i]);

	  printf
	    ("a_input=%016llx b_input=%016llx expected=%016llx output=%016llx\n",
	     a_input[i], b_input[i], z_output[i], result);
	}
      printf ("%d\n", main_result);
      return main_result;
    }


//===-- sync.cpp - Implement the C Synthesis Code Generator ---------------===//
//
//                      The Shang HLS frameowrk                               //
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the C Synthesis code generator driver. It provides a convenient
// command-line interface for generating RTL Verilog and various interfacing
// code, given LLVM bitcode.
//
//===----------------------------------------------------------------------===//
#include "vtm/Passes.h"
#include "vtm/LuaScript.h"

#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Config/config.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h"

#include <memory>

// This is the only header we need to include for LuaBind to work
#include "luabind/luabind.hpp"

// Include the lua headers (the extern "C" is a requirement because we're
// using C++ and lua has been compiled as C code)
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

using namespace llvm;

// General options for sync.  Other pass-specific options are specified
// within the corresponding sync passes, and target-specific options
// and back-end code generation options are specified with the target machine.
//
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input lua script>"), cl::init("-"));

namespace llvm {
  extern Target TheVBackendTarget;
}

extern "C" void LLVMInitializeVerilogBackendTargetMC();
extern "C" void LLVMInitializeVerilogBackendTarget();
extern "C" void LLVMInitializeVerilogBackendTargetInfo();

static void LoopOptimizerEndExtensionFn(const PassManagerBuilder &Builder,
                                        PassManagerBase &PM) {
  PM.add(createMemoryAccessAlignerPass());
  PM.add(createScalarEvolutionAliasAnalysisPass());
  PM.add(createTrivialLoopUnrollPass());
  PM.add(createMemoryAccessAlignerPass());
  PM.add(createInstructionCombiningPass());
}

// main - Entry point for the sync compiler.
//
int main(int argc, char **argv) {
  sys::PrintStackTraceOnErrorSignal();

  // Enable debug stream buffering.
  EnableDebugBuffering = true;

  LLVMContext &Context = getGlobalContext();
  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.

  // Initialize target first, so that --version shows registered targets.
  LLVMInitializeVerilogBackendTarget();
  LLVMInitializeVerilogBackendTargetInfo();
  LLVMInitializeVerilogBackendTargetMC();

  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");

  SMDiagnostic Err;

  LuaScript *S = &scriptEngin();
  S->init();

  // Run the lua script.
  if (!S->runScriptFile(InputFilename, Err)){
    Err.print(argv[0], errs());
    return 1;
  }

  S->updateStatus();

  // Load the module to be compiled...
  std::auto_ptr<Module> M;

  M.reset(ParseIRFile(S->getValue<std::string>("InputFile"),
                      Err, Context));
  if (M.get() == 0) {
    Err.print(argv[0], errs());
    return 1;
  }
  Module &mod = *M.get();

  // TODO: Build the right triple.
  Triple TheTriple(mod.getTargetTriple());
  TargetOptions TO;
  std::auto_ptr<TargetMachine>
    target(TheVBackendTarget.createTargetMachine(TheTriple.getTriple(), "",
                                                 S->getDataLayout(), TO));

  // Build up all of the passes that we want to do to the module.
  PassManagerBuilder Builder;
  Builder.DisableUnrollLoops = true;
  Builder.LibraryInfo = new TargetLibraryInfo();
  Builder.LibraryInfo->disableAllFunctions();
  Builder.OptLevel = 3;
  Builder.SizeLevel = 2;
  Builder.DisableSimplifyLibCalls = true;
  Builder.Inliner = createHLSInlinerPass();
  Builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd,
                       LoopOptimizerEndExtensionFn);
  PassManager Passes;
  Passes.add(new TargetData(*target->getTargetData()));

  // Add the immutable target-specific alias analysis ahead of all others AAs.
  Passes.add(createVAliasAnalysisPass(target->getIntrinsicInfo()));

  Passes.add(createVerifierPass());
  // This is the final bitcode, internalize it to expose more optimization
  // opportunities. Note that we should internalize it before SW/HW partition,
  // otherwise we may lost some information that help the later internalize.
  Passes.add(createInternalizePass(true));

  // Perform Software/Hardware partition.
  Passes.add(createFunctionFilterPass(S->getOutputStream("SoftwareIROutput")));
  Passes.add(createGlobalDCEPass());
  // Optimize the hardware part.
  //Builder.populateFunctionPassManager(*FPasses);
  Builder.populateModulePassManager(Passes);
  Builder.populateLTOPassManager(Passes,
                                 /*Internalize*/true,
                                 /*RunInliner*/true);

  //PM.add(createPrintModulePass(&dbgs()));

  // We do not use the stream that passing into addPassesToEmitFile.
  formatted_raw_ostream formatted_nulls(nulls());
  // Ask the target to add backend passes as necessary.
  target->addPassesToEmitFile(Passes, formatted_nulls,
                              TargetMachine::CGFT_Null,
                              false/*NoVerify*/);

  // Analyse the slack between registers.
  Passes.add(createCombPathDelayAnalysisPass());
  Passes.add(createVerilogASTWriterPass(S->getOutputStream("RTLOutput")));

  // Run some scripting passes.
  for (LuaScript::scriptpass_it I = S->passes_begin(), E = S->passes_end();
       I != E; ++I) {
    const luabind::object &o = *I;
    Pass *P = createScriptingPass(
      luabind::object_cast<std::string>(I.key()).c_str(),
      luabind::object_cast<std::string>(o["FunctionScript"]).c_str(),
      luabind::object_cast<std::string>(o["GlobalScript"]).c_str());
    Passes.add(P);
  }

  // Run the passes.
  Passes.run(mod);

  // If no error occur, keep the files.
  S->keepAllFiles();

  return 0;
}


// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2016.2
// Copyright (C) 1986-2016 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================

#ifndef __svm_classifier_getTanh_cosh_lut_V_H__
#define __svm_classifier_getTanh_cosh_lut_V_H__

#include <systemc>
using namespace sc_core;
using namespace sc_dt;

#include <iostream>
#include <fstream>

struct svm_classifier_getTanh_cosh_lut_V_ram : public sc_core::sc_module {

  static const unsigned DataWidth = 9;
  static const unsigned AddressRange = 6;
  static const unsigned AddressWidth = 3;

//latency = 1
//input_reg = 1
//output_reg = 0
sc_core::sc_in <sc_lv<AddressWidth> > address0;
sc_core::sc_in <sc_logic> ce0;
sc_core::sc_out <sc_lv<DataWidth> > q0;
sc_core::sc_in<sc_logic> reset;
sc_core::sc_in<bool> clk;

sc_lv<DataWidth> ram[AddressRange];

   SC_CTOR(svm_classifier_getTanh_cosh_lut_V_ram) {
        ram[0] = "0b001000000";
        ram[1] = "0b000001001";
        ram[2] = "0b000011000";
        ram[3] = "0b001000000";
        ram[4] = "0b010101110";
        ram[5] = "0b111011010";

SC_METHOD(prc_write_0);
  sensitive<<clk.pos();
   }

void prc_write_0()
{
    if (ce0.read() == sc_dt::Log_1)
    {
            if(address0.read().is_01() && address0.read().to_uint()<AddressRange)
              q0 = ram[address0.read().to_uint()];
            else
              q0 = sc_lv<DataWidth>();
    }
}

}; //endmodule

SC_MODULE(svm_classifier_getTanh_cosh_lut_V) {

static const unsigned DataWidth = 9;
static const unsigned AddressRange = 6;
static const unsigned AddressWidth = 3;

sc_core::sc_in <sc_lv<AddressWidth> > address0;
sc_core::sc_in<sc_logic> ce0;
sc_core::sc_out <sc_lv<DataWidth> > q0;
sc_core::sc_in<sc_logic> reset;
sc_core::sc_in<bool> clk;

svm_classifier_getTanh_cosh_lut_V_ram* meminst;

SC_CTOR(svm_classifier_getTanh_cosh_lut_V) {
meminst = new svm_classifier_getTanh_cosh_lut_V_ram("svm_classifier_getTanh_cosh_lut_V_ram");
meminst->address0(address0);
meminst->ce0(ce0);
meminst->q0(q0);


// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2016.2
// Copyright (C) 1986-2016 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================

#ifndef __svm_classifier_mul_14s_13s_27_1__HH__
#define __svm_classifier_mul_14s_13s_27_1__HH__
#include "ACMP_smul_ss.h"
#include <systemc>

template<
    int ID,
    int NUM_STAGE,
    int din0_WIDTH,
    int din1_WIDTH,
    int dout_WIDTH>
SC_MODULE(svm_classifier_mul_14s_13s_27_1) {
    sc_core::sc_in< sc_dt::sc_lv<din0_WIDTH> >   din0;
    sc_core::sc_in< sc_dt::sc_lv<din1_WIDTH> >   din1;
    sc_core::sc_out< sc_dt::sc_lv<dout_WIDTH> >   dout;

    ACMP_smul_ss<ID, 1, din0_WIDTH, din1_WIDTH, dout_WIDTH> ACMP_smul_ss_U;

    SC_CTOR(svm_classifier_mul_14s_13s_27_1):  ACMP_smul_ss_U ("ACMP_smul_ss_U") {
        ACMP_smul_ss_U.din0(din0);
        ACMP_smul_ss_U.din1(din1);
        ACMP_smul_ss_U.dout(dout);


/******************************************************************************
*
* Copyright (C) 2010 - 2015 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file xuartps_hw.h
* @addtogroup uartps_v3_1
* @{
*
* This header file contains the hardware interface of an XUartPs device.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who    Date	Changes
* ----- ------ -------- ----------------------------------------------
* 1.00	drg/jz 01/12/10 First Release
* 1.03a sg     09/04/12 Added defines for XUARTPS_IXR_TOVR,  XUARTPS_IXR_TNFUL
*			and XUARTPS_IXR_TTRIG.
*			Modified the names of these defines
*			XUARTPS_MEDEMSR_DCDX to XUARTPS_MODEMSR_DDCD
*			XUARTPS_MEDEMSR_RIX to XUARTPS_MODEMSR_TERI
*			XUARTPS_MEDEMSR_DSRX to XUARTPS_MODEMSR_DDSR
*			XUARTPS_MEDEMSR_CTSX to XUARTPS_MODEMSR_DCTS
* 1.05a hk     08/22/13 Added prototype for uart reset and related
*			constant definitions.
* 3.00  kvn    02/13/15 Modified code for MISRA-C:2012 compliance.
* 3.1	kvn    04/10/15 Modified code for latest RTL changes.
*
* </pre>
*
******************************************************************************/
#ifndef XUARTPS_HW_H		/* prevent circular inclusions */
#define XUARTPS_HW_H		/* by using protection macros */

#ifdef __cplusplus
extern "C" {
#endif

/***************************** Include Files *********************************/

#include "xil_types.h"
#include "xil_assert.h"
#include "xil_io.h"

/************************** Constant Definitions *****************************/

/** @name Register Map
 *
 * Register offsets for the UART.
 * @{
 */
#define XUARTPS_CR_OFFSET		0x0000U  /**< Control Register [8:0] */
#define XUARTPS_MR_OFFSET		0x0004U  /**< Mode Register [9:0] */
#define XUARTPS_IER_OFFSET		0x0008U  /**< Interrupt Enable [12:0] */
#define XUARTPS_IDR_OFFSET		0x000CU  /**< Interrupt Disable [12:0] */
#define XUARTPS_IMR_OFFSET		0x0010U  /**< Interrupt Mask [12:0] */
#define XUARTPS_ISR_OFFSET		0x0014U  /**< Interrupt Status [12:0]*/
#define XUARTPS_BAUDGEN_OFFSET	0x0018U  /**< Baud Rate Generator [15:0] */
#define XUARTPS_RXTOUT_OFFSET	0x001CU  /**< RX Timeout [7:0] */
#define XUARTPS_RXWM_OFFSET		0x0020U  /**< RX FIFO Trigger Level [5:0] */
#define XUARTPS_MODEMCR_OFFSET	0x0024U  /**< Modem Control [5:0] */
#define XUARTPS_MODEMSR_OFFSET	0x0028U  /**< Modem Status [8:0] */
#define XUARTPS_SR_OFFSET		0x002CU  /**< Channel Status [14:0] */
#define XUARTPS_FIFO_OFFSET		0x0030U  /**< FIFO [7:0] */
#define XUARTPS_BAUDDIV_OFFSET	0x0034U  /**< Baud Rate Divider [7:0] */
#define XUARTPS_FLOWDEL_OFFSET	0x0038U  /**< Flow Delay [5:0] */
#define XUARTPS_TXWM_OFFSET		0x0044U  /**< TX FIFO Trigger Level [5:0] */
#define XUARTPS_RXBS_OFFSET		0x0048U  /**< RX FIFO Byte Status [11:0] */
/* @} */

/** @name Control Register
 *
 * The Control register (CR) controls the major functions of the device.
 *
 * Control Register Bit Definition
 */

#define XUARTPS_CR_STOPBRK	0x00000100U  /**< Stop transmission of break */
#define XUARTPS_CR_STARTBRK	0x00000080U  /**< Set break */
#define XUARTPS_CR_TORST	0x00000040U  /**< RX timeout counter restart */
#define XUARTPS_CR_TX_DIS	0x00000020U  /**< TX disabled. */
#define XUARTPS_CR_TX_EN	0x00000010U  /**< TX enabled */
#define XUARTPS_CR_RX_DIS	0x00000008U  /**< RX disabled. */
#define XUARTPS_CR_RX_EN	0x00000004U  /**< RX enabled */
#define XUARTPS_CR_EN_DIS_MASK	0x0000003CU  /**< Enable/disable Mask */
#define XUARTPS_CR_TXRST	0x00000002U  /**< TX logic reset */
#define XUARTPS_CR_RXRST	0x00000001U  /**< RX logic reset */
/* @}*/

/** @name Mode Register
 *
 * The mode register (MR) defines the mode of transfer as well as the data
 * format. If this register is modified during transmission or reception,
 * data validity cannot be guaranteed.
 *
 * Mode Register Bit Definition
 * @{
 */
#define XUARTPS_MR_CCLK				0x00000400U /**< Input clock selection */
#define XUARTPS_MR_CHMODE_R_LOOP	0x00000300U /**< Remote loopback mode */
#define XUARTPS_MR_CHMODE_L_LOOP	0x00000200U /**< Local loopback mode */
#define XUARTPS_MR_CHMODE_ECHO		0x00000100U /**< Auto echo mode */
#define XUARTPS_MR_CHMODE_NORM		0x00000000U /**< Normal mode */
#define XUARTPS_MR_CHMODE_SHIFT				8U  /**< Mode shift */
#define XUARTPS_MR_CHMODE_MASK		0x00000300U /**< Mode mask */
#define XUARTPS_MR_STOPMODE_2_BIT	0x00000080U /**< 2 stop bits */
#define XUARTPS_MR_STOPMODE_1_5_BIT	0x00000040U /**< 1.5 stop bits */
#define XUARTPS_MR_STOPMODE_1_BIT	0x00000000U /**< 1 stop bit */
#define XUARTPS_MR_STOPMODE_SHIFT			6U  /**< Stop bits shift */
#define XUARTPS_MR_STOPMODE_MASK	0x000000A0U /**< Stop bits mask */
#define XUARTPS_MR_PARITY_NONE		0x00000020U /**< No parity mode */
#define XUARTPS_MR_PARITY_MARK		0x00000018U /**< Mark parity mode */
#define XUARTPS_MR_PARITY_SPACE		0x00000010U /**< Space parity mode */
#define XUARTPS_MR_PARITY_ODD		0x00000008U /**< Odd parity mode */
#define XUARTPS_MR_PARITY_EVEN		0x00000000U /**< Even parity mode */
#define XUARTPS_MR_PARITY_SHIFT				3U  /**< Parity setting shift */
#define XUARTPS_MR_PARITY_MASK		0x00000038U /**< Parity mask */
#define XUARTPS_MR_CHARLEN_6_BIT	0x00000006U /**< 6 bits data */
#define XUARTPS_MR_CHARLEN_7_BIT	0x00000004U /**< 7 bits data */
#define XUARTPS_MR_CHARLEN_8_BIT	0x00000000U /**< 8 bits data */
#define XUARTPS_MR_CHARLEN_SHIFT			1U  /**< Data Length shift */
#define XUARTPS_MR_CHARLEN_MASK		0x00000006U /**< Data length mask */
#define XUARTPS_MR_CLKSEL			0x00000001U /**< Input clock selection */
/* @} */

/** @name Interrupt Registers
 *
 * Interrupt control logic uses the interrupt enable register (IER) and the
 * interrupt disable register (IDR) to set the value of the bits in the
 * interrupt mask register (IMR). The IMR determines whether to pass an
 * interrupt to the interrupt status register (ISR).
 * Writing a 1 to IER Enbables an interrupt, writing a 1 to IDR disables an
 * interrupt. IMR and ISR are read only, and IER and IDR are write only.
 * Reading either IER or IDR returns 0x00.
 *
 * All four registers have the same bit definitions.
 *
 * @{
 */
#define XUARTPS_IXR_RBRK	0x00002000U /**< Rx FIFO break detect interrupt */
#define XUARTPS_IXR_TOVR	0x00001000U /**< Tx FIFO Overflow interrupt */
#define XUARTPS_IXR_TNFUL	0x00000800U /**< Tx FIFO Nearly Full interrupt */
#define XUARTPS_IXR_TTRIG	0x00000400U /**< Tx Trig interrupt */
#define XUARTPS_IXR_DMS		0x00000200U /**< Modem status change interrupt */
#define XUARTPS_IXR_TOUT	0x00000100U /**< Timeout error interrupt */
#define XUARTPS_IXR_PARITY 	0x00000080U /**< Parity error interrupt */
#define XUARTPS_IXR_FRAMING	0x00000040U /**< Framing error interrupt */
#define XUARTPS_IXR_OVER	0x00000020U /**< Overrun error interrupt */
#define XUARTPS_IXR_TXFULL 	0x00000010U /**< TX FIFO full interrupt. */
#define XUARTPS_IXR_TXEMPTY	0x00000008U /**< TX FIFO empty interrupt. */
#define XUARTPS_IXR_RXFULL 	0x00000004U /**< RX FIFO full interrupt. */
#define XUARTPS_IXR_RXEMPTY	0x00000002U /**< RX FIFO empty interrupt. */
#define XUARTPS_IXR_RXOVR  	0x00000001U /**< RX FIFO trigger interrupt. */
#define XUARTPS_IXR_MASK	0x00003FFFU /**< Valid bit mask */
/* @} */

/** @name Baud Rate Generator Register
 *
 * The baud rate generator control register (BRGR) is a 16 bit register that
 * controls the receiver bit sample clock and baud rate.
 * Valid values are 1 - 65535.
 *
 * Bit Sample Rate = CCLK / BRGR, where the CCLK is selected by the MR_CCLK bit
 * in the MR register.
 * @{
 */
#define XUARTPS_BAUDGEN_DISABLE		0x00000000U /**< Disable clock */
#define XUARTPS_BAUDGEN_MASK		0x0000FFFFU /**< Valid bits mask */
#define XUARTPS_BAUDGEN_RESET_VAL	0x0000028BU /**< Reset value */

/** @name Baud Divisor Rate register
 *
 * The baud rate divider register (BDIV) controls how much the bit sample
 * rate is divided by. It sets the baud rate.
 * Valid values are 0x04 to 0xFF. Writing a value less than 4 will be ignored.
 *
 * Baud rate = CCLK / ((BAUDDIV + 1) x BRGR), where the CCLK is selected by
 * the MR_CCLK bit in the MR register.
 * @{
 */
#define XUARTPS_BAUDDIV_MASK        0x000000FFU	/**< 8 bit baud divider mask */
#define XUARTPS_BAUDDIV_RESET_VAL   0x0000000FU	/**< Reset value */
/* @} */

/** @name Receiver Timeout Register
 *
 * Use the receiver timeout register (RTR) to detect an idle condition on
 * the receiver data line.
 *
 * @{
 */
#define XUARTPS_RXTOUT_DISABLE		0x00000000U  /**< Disable time out */
#define XUARTPS_RXTOUT_MASK			0x000000FFU  /**< Valid bits mask */

/** @name Receiver FIFO Trigger Level Register
 *
 * Use the Receiver FIFO Trigger Level Register (RTRIG) to set the value at
 * which the RX FIFO triggers an interrupt event.
 * @{
 */

#define XUARTPS_RXWM_DISABLE	0x00000000U  /**< Disable RX trigger interrupt */
#define XUARTPS_RXWM_MASK		0x0000003FU  /**< Valid bits mask */
#define XUARTPS_RXWM_RESET_VAL	0x00000020U  /**< Reset value */
/* @} */

/** @name Transmit FIFO Trigger Level Register
 *
 * Use the Transmit FIFO Trigger Level Register (TTRIG) to set the value at
 * which the TX FIFO triggers an interrupt event.
 * @{
 */

#define XUARTPS_TXWM_MASK		0x0000003FU  /**< Valid bits mask */
#define XUARTPS_TXWM_RESET_VAL	0x00000020U  /**< Reset value */
/* @} */

/** @name Modem Control Register
 *
 * This register (MODEMCR) controls the interface with the modem or data set,
 * or a peripheral device emulating a modem.
 *
 * @{
 */
#define XUARTPS_MODEMCR_FCM	0x00000010U  /**< Flow control mode */
#define XUARTPS_MODEMCR_RTS	0x00000002U  /**< Request to send */
#define XUARTPS_MODEMCR_DTR	0x00000001U  /**< Data terminal ready */
/* @} */

/** @name Modem Status Register
 *
 * This register (MODEMSR) indicates the current state of the control lines
 * from a modem, or another peripheral device, to the CPU. In addition, four
 * bits of the modem status register provide change information. These bits
 * are set to a logic 1 whenever a control input from the modem changes state.
 *
 * Note: Whenever the DCTS, DDSR, TERI, or DDCD bit is set to logic 1, a modem
 * status interrupt is generated and this is reflected in the modem status
 * register.
 *
 * @{
 */
#define XUARTPS_MODEMSR_FCMS	0x00000100U  /**< Flow control mode (FCMS) */
#define XUARTPS_MODEMSR_DCD		0x00000080U  /**< Complement of DCD input */
#define XUARTPS_MODEMSR_RI		0x00000040U  /**< Complement of RI input */
#define XUARTPS_MODEMSR_DSR		0x00000020U  /**< Complement of DSR input */
#define XUARTPS_MODEMSR_CTS		0x00000010U  /**< Complement of CTS input */
#define XUARTPS_MODEMSR_DDCD	0x00000008U  /**< Delta DCD indicator */
#define XUARTPS_MODEMSR_TERI  0x00000004U  /**< Trailing Edge Ring Indicator */
#define XUARTPS_MODEMSR_DDSR	0x00000002U  /**< Change of DSR */
#define XUARTPS_MODEMSR_DCTS	0x00000001U  /**< Change of CTS */
/* @} */

/** @name Channel Status Register
 *
 * The channel status register (CSR) is provided to enable the control logic
 * to monitor the status of bits in the channel interrupt status register,
 * even if these are masked out by the interrupt mask register.
 *
 * @{
 */
#define XUARTPS_SR_TNFUL	0x00004000U /**< TX FIFO Nearly Full Status */
#define XUARTPS_SR_TTRIG	0x00002000U /**< TX FIFO Trigger Status */
#define XUARTPS_SR_FLOWDEL	0x00001000U /**< RX FIFO fill over flow delay */
#define XUARTPS_SR_TACTIVE	0x00000800U /**< TX active */
#define XUARTPS_SR_RACTIVE	0x00000400U /**< RX active */
#define XUARTPS_SR_TXFULL	0x00000010U /**< TX FIFO full */
#define XUARTPS_SR_TXEMPTY	0x00000008U /**< TX FIFO empty */
#define XUARTPS_SR_RXFULL	0x00000004U /**< RX FIFO full */
#define XUARTPS_SR_RXEMPTY	0x00000002U /**< RX FIFO empty */
#define XUARTPS_SR_RXOVR	0x00000001U /**< RX FIFO fill over trigger */
/* @} */

/** @name Flow Delay Register
 *
 * Operation of the flow delay register (FLOWDEL) is very similar to the
 * receive FIFO trigger register. An internal trigger signal activates when the
 * FIFO is filled to the level set by this register. This trigger will not
 * cause an interrupt, although it can be read through the channel status
 * register. In hardware flow control mode, RTS is deactivated when the trigger
 * becomes active. RTS only resets when the FIFO level is four less than the
 * level of the flow delay trigger and the flow delay trigger is not activated.
 * A value less than 4 disables the flow delay.
 * @{
 */
#define XUARTPS_FLOWDEL_MASK	XUARTPS_RXWM_MASK	/**< Valid bit mask */
/* @} */

/** @name Receiver FIFO Byte Status Register
 *
 * The Receiver FIFO Status register is used to have a continuous
 * monitoring of the raw unmasked byte status information. The register
 * contains frame, parity and break status information for the top
 * four bytes in the RX FIFO.
 *
 * Receiver FIFO Byte Status Register Bit Definition
 * @{
 */
#define XUARTPS_RXBS_BYTE3_BRKE		0x00000800U /**< Byte3 Break Error */
#define XUARTPS_RXBS_BYTE3_FRME		0x00000400U /**< Byte3 Frame Error */
#define XUARTPS_RXBS_BYTE3_PARE		0x00000200U /**< Byte3 Parity Error */
#define XUARTPS_RXBS_BYTE2_BRKE		0x00000100U /**< Byte2 Break Error */
#define XUARTPS_RXBS_BYTE2_FRME		0x00000080U /**< Byte2 Frame Error */
#define XUARTPS_RXBS_BYTE2_PARE		0x00000040U /**< Byte2 Parity Error */
#define XUARTPS_RXBS_BYTE1_BRKE		0x00000020U /**< Byte1 Break Error */
#define XUARTPS_RXBS_BYTE1_FRME		0x00000010U /**< Byte1 Frame Error */
#define XUARTPS_RXBS_BYTE1_PARE		0x00000008U /**< Byte1 Parity Error */
#define XUARTPS_RXBS_BYTE0_BRKE		0x00000004U /**< Byte0 Break Error */
#define XUARTPS_RXBS_BYTE0_FRME		0x00000002U /**< Byte0 Frame Error */
#define XUARTPS_RXBS_BYTE0_PARE		0x00000001U /**< Byte0 Parity Error */
#define XUARTPS_RXBS_MASK		0x00000007U /**< 3 bit RX byte status mask */
/* @} */

/*
 * Defines for backwards compatabilty, will be removed
 * in the next version of the driver
 */
#define XUARTPS_MEDEMSR_DCDX  XUARTPS_MODEMSR_DDCD
#define XUARTPS_MEDEMSR_RIX   XUARTPS_MODEMSR_TERI
#define XUARTPS_MEDEMSR_DSRX  XUARTPS_MODEMSR_DDSR
#define	XUARTPS_MEDEMSR_CTSX  XUARTPS_MODEMSR_DCTS

/**************************** Type Definitions *******************************/

/***************** Macros (Inline Functions) Definitions *********************/

/****************************************************************************/
/**
* Read a UART register.
*
* @param	BaseAddress contains the base address of the device.
* @param	RegOffset contains the offset from the base address of the
*		device.
*
* @return	The value read from the register.
*
* @note		C-Style signature:
*		u32 XUartPs_ReadReg(u32 BaseAddress, int RegOffset)
*
******************************************************************************/
#define XUartPs_ReadReg(BaseAddress, RegOffset) \
	Xil_In32((BaseAddress) + (u32)(RegOffset))

/***************************************************************************/
/**
* Write a UART register.
*
* @param	BaseAddress contains the base address of the device.
* @param	RegOffset contains the offset from the base address of the
*		device.
* @param	RegisterValue is the value to be written to the register.
*
* @return	None.
*
* @note		C-Style signature:
*		void XUartPs_WriteReg(u32 BaseAddress, int RegOffset,
*						   u16 RegisterValue)
*
******************************************************************************/
#define XUartPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
	Xil_Out32((BaseAddress) + (u32)(RegOffset), (u32)(RegisterValue))

/****************************************************************************/
/**
* Determine if there is receive data in the receiver and/or FIFO.
*
* @param	BaseAddress contains the base address of the device.
*
* @return	TRUE if there is receive data, FALSE otherwise.
*
* @note		C-Style signature:
*		u32 XUartPs_IsReceiveData(u32 BaseAddress)
*
******************************************************************************/
#define XUartPs_IsReceiveData(BaseAddress)			 \
	!((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & 	\
	(u32)XUARTPS_SR_RXEMPTY) == (u32)XUARTPS_SR_RXEMPTY)

/****************************************************************************/
/**
* Determine if a byte of data can be sent with the transmitter.
*
* @param	BaseAddress contains the base address of the device.
*
* @return	TRUE if the TX FIFO is full, FALSE if a byte can be put in the
*		FIFO.
*
* @note		C-Style signature:
*		u32 XUartPs_IsTransmitFull(u32 BaseAddress)
*
******************************************************************************/
#define XUartPs_IsTransmitFull(BaseAddress)			 \
	((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & 	\
	 (u32)XUARTPS_SR_TXFULL) == (u32)XUARTPS_SR_TXFULL)

/************************** Function Prototypes ******************************/

void XUartPs_SendByte(u32 BaseAddress, u8 Data);

u8 XUartPs_RecvByte(u32 BaseAddress);