// auto-generated by inttypes/create.py

#ifndef crypto_int8_h
#define crypto_int8_h

#include <inttypes.h>
#define crypto_int8 int8_t

#define crypto_int8_optblocker mceliece_int8_optblocker
extern volatile crypto_int8 crypto_int8_optblocker;

__attribute__((unused))
static inline
crypto_int8 crypto_int8_load(const unsigned char *crypto_int8_s) {
  crypto_int8 crypto_int8_z = 0;
  crypto_int8_z |= ((crypto_int8) (*crypto_int8_s++)) << 0;
  return crypto_int8_z;
}

__attribute__((unused))
static inline
void crypto_int8_store(unsigned char *crypto_int8_s,crypto_int8 crypto_int8_x) {
  *crypto_int8_s++ = crypto_int8_x >> 0;
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_shlmod(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
  int crypto_int8_k, crypto_int8_l;
  for (crypto_int8_l = 0,crypto_int8_k = 1;crypto_int8_k < 8;++crypto_int8_l,crypto_int8_k *= 2)
    crypto_int8_x ^= (crypto_int8_x ^ (crypto_int8_x << crypto_int8_k)) & -((crypto_int8_s >> crypto_int8_l) & 1);
  return crypto_int8_x;
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_negative_mask(crypto_int8 crypto_int8_x) {
  crypto_int8_x >>= 8-6;
  crypto_int8_x ^= crypto_int8_optblocker;
  crypto_int8_x >>= 5;
  return crypto_int8_x;
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_nonzero_mask(crypto_int8 crypto_int8_x) {
  return crypto_int8_negative_mask(crypto_int8_x | -crypto_int8_x);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_positive_mask(crypto_int8 crypto_int8_x)
{
  crypto_int8 crypto_int8_z = -crypto_int8_x;
  crypto_int8_z ^= crypto_int8_x & crypto_int8_z;
  return crypto_int8_negative_mask(crypto_int8_z);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_zero_mask(crypto_int8 crypto_int8_x) {
  return ~crypto_int8_nonzero_mask(crypto_int8_x);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_unequal_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
  return crypto_int8_nonzero_mask(crypto_int8_x ^ crypto_int8_y);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_equal_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
  return ~crypto_int8_unequal_mask(crypto_int8_x,crypto_int8_y);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_min(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y)
{
  crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
  crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
  crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
  crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
  crypto_int8_z &= crypto_int8_r;
  return crypto_int8_x ^ crypto_int8_z;
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_max(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
  crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
  crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
  crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
  crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
  crypto_int8_z &= crypto_int8_r;
  return crypto_int8_y ^ crypto_int8_z;
}

__attribute__((unused))
static inline
void crypto_int8_minmax(crypto_int8 *crypto_int8_p,crypto_int8 *crypto_int8_q) {
  crypto_int8 crypto_int8_x = *crypto_int8_p;
  crypto_int8 crypto_int8_y = *crypto_int8_q;
  crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
  crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
  crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
  crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
  crypto_int8_z &= crypto_int8_r;
  *crypto_int8_p = crypto_int8_x ^ crypto_int8_z;
  *crypto_int8_q = crypto_int8_y ^ crypto_int8_z;
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_smaller_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
  crypto_int8 crypto_int8_r = crypto_int8_x ^ crypto_int8_y;
  crypto_int8 crypto_int8_z = crypto_int8_x - crypto_int8_y;
  crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_x);
  return crypto_int8_negative_mask(crypto_int8_z);
}

__attribute__((unused))
static inline
crypto_int8 crypto_int8_leq_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
  return ~crypto_int8_smaller_mask(crypto_int8_y,crypto_int8_x);
}

#endif