// auto-generated by inttypes/create.py

#ifndef crypto_uint64_h
#define crypto_uint64_h

#include <inttypes.h>
#define crypto_uint64 uint64_t
#define crypto_uint64_signed int64_t

#define crypto_uint64_signed_optblocker mceliece_uint64_signed_optblocker
extern volatile crypto_uint64_signed crypto_uint64_signed_optblocker;

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_load(const unsigned char *crypto_uint64_s) {
  crypto_uint64 crypto_uint64_z = 0;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 0;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 8;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 16;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 24;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 32;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 40;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 48;
  crypto_uint64_z |= ((crypto_uint64) (*crypto_uint64_s++)) << 56;
  return crypto_uint64_z;
}

__attribute__((unused))
static inline
void crypto_uint64_store(unsigned char *crypto_uint64_s,crypto_uint64 crypto_uint64_x) {
  *crypto_uint64_s++ = crypto_uint64_x >> 0;
  *crypto_uint64_s++ = crypto_uint64_x >> 8;
  *crypto_uint64_s++ = crypto_uint64_x >> 16;
  *crypto_uint64_s++ = crypto_uint64_x >> 24;
  *crypto_uint64_s++ = crypto_uint64_x >> 32;
  *crypto_uint64_s++ = crypto_uint64_x >> 40;
  *crypto_uint64_s++ = crypto_uint64_x >> 48;
  *crypto_uint64_s++ = crypto_uint64_x >> 56;
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_shlmod(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_s) {
  int crypto_uint64_k, crypto_uint64_l;
  for (crypto_uint64_l = 0,crypto_uint64_k = 1;crypto_uint64_k < 64;++crypto_uint64_l,crypto_uint64_k *= 2)
    crypto_uint64_x ^= (crypto_uint64_x ^ (crypto_uint64_x << crypto_uint64_k)) & -((crypto_uint64_s >> crypto_uint64_l) & 1);
  return crypto_uint64_x;
}

__attribute__((unused))
static inline
crypto_uint64_signed crypto_uint64_signed_negative_mask(crypto_uint64_signed crypto_uint64_x) {
  crypto_uint64_x >>= 64-6;
  crypto_uint64_x ^= crypto_uint64_signed_optblocker;
  crypto_uint64_x >>= 5;
  return crypto_uint64_x;
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_nonzero_mask(crypto_uint64 crypto_uint64_x) {
  return crypto_uint64_signed_negative_mask(crypto_uint64_x | -crypto_uint64_x);
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_zero_mask(crypto_uint64 crypto_uint64_x) {
  return ~crypto_uint64_nonzero_mask(crypto_uint64_x);
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_unequal_mask(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  return crypto_uint64_nonzero_mask(crypto_uint64_x ^ crypto_uint64_y);
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_equal_mask(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  return ~crypto_uint64_unequal_mask(crypto_uint64_x,crypto_uint64_y);
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_min(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  crypto_uint64 crypto_uint64_r = crypto_uint64_y ^ crypto_uint64_x;
  crypto_uint64 crypto_uint64_z = crypto_uint64_y - crypto_uint64_x;
  crypto_uint64_z ^= crypto_uint64_r & (crypto_uint64_z ^ crypto_uint64_y ^ (((crypto_uint64) 1) << (64-1)));
  crypto_uint64_z = crypto_uint64_signed_negative_mask(crypto_uint64_z);
  crypto_uint64_z &= crypto_uint64_r;
  return crypto_uint64_x ^ crypto_uint64_z;
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_max(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  crypto_uint64 crypto_uint64_r = crypto_uint64_y ^ crypto_uint64_x;
  crypto_uint64 crypto_uint64_z = crypto_uint64_y - crypto_uint64_x;
  crypto_uint64_z ^= crypto_uint64_r & (crypto_uint64_z ^ crypto_uint64_y ^ (((crypto_uint64) 1) << (64-1)));
  crypto_uint64_z = crypto_uint64_signed_negative_mask(crypto_uint64_z);
  crypto_uint64_z &= crypto_uint64_r;
  return crypto_uint64_y ^ crypto_uint64_z;
}

__attribute__((unused))
static inline
void crypto_uint64_minmax(crypto_uint64 *crypto_uint64_p,crypto_uint64 *crypto_uint64_q) {
  crypto_uint64 crypto_uint64_x = *crypto_uint64_p;
  crypto_uint64 crypto_uint64_y = *crypto_uint64_q;
  crypto_uint64 crypto_uint64_r = crypto_uint64_y ^ crypto_uint64_x;
  crypto_uint64 crypto_uint64_z = crypto_uint64_y - crypto_uint64_x;
  crypto_uint64_z ^= crypto_uint64_r & (crypto_uint64_z ^ crypto_uint64_y ^ (((crypto_uint64) 1) << (64-1)));
  crypto_uint64_z = crypto_uint64_signed_negative_mask(crypto_uint64_z);
  crypto_uint64_z &= crypto_uint64_r;
  *crypto_uint64_p = crypto_uint64_x ^ crypto_uint64_z;
  *crypto_uint64_q = crypto_uint64_y ^ crypto_uint64_z;
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_smaller_mask(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  crypto_uint64 crypto_uint64_r = crypto_uint64_x ^ crypto_uint64_y;
  crypto_uint64 crypto_uint64_z = crypto_uint64_x - crypto_uint64_y;
  crypto_uint64_z ^= crypto_uint64_r & (crypto_uint64_z ^ crypto_uint64_x ^ (((crypto_uint64) 1) << (64-1)));
  return crypto_uint64_signed_negative_mask(crypto_uint64_z);
}

__attribute__((unused))
static inline
crypto_uint64 crypto_uint64_leq_mask(crypto_uint64 crypto_uint64_x,crypto_uint64 crypto_uint64_y) {
  return ~crypto_uint64_smaller_mask(crypto_uint64_y,crypto_uint64_x);
}

#endif