// auto-generated by inttypes/create.py

#ifndef crypto_uint32_h
#define crypto_uint32_h

#include <inttypes.h>
#define crypto_uint32 uint32_t
#define crypto_uint32_signed int32_t

#define crypto_uint32_signed_optblocker mceliece_uint32_signed_optblocker
extern volatile crypto_uint32_signed crypto_uint32_signed_optblocker;

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_load(const unsigned char *crypto_uint32_s) {
  crypto_uint32 crypto_uint32_z = 0;
  crypto_uint32_z |= ((crypto_uint32) (*crypto_uint32_s++)) << 0;
  crypto_uint32_z |= ((crypto_uint32) (*crypto_uint32_s++)) << 8;
  crypto_uint32_z |= ((crypto_uint32) (*crypto_uint32_s++)) << 16;
  crypto_uint32_z |= ((crypto_uint32) (*crypto_uint32_s++)) << 24;
  return crypto_uint32_z;
}

__attribute__((unused))
static inline
void crypto_uint32_store(unsigned char *crypto_uint32_s,crypto_uint32 crypto_uint32_x) {
  *crypto_uint32_s++ = crypto_uint32_x >> 0;
  *crypto_uint32_s++ = crypto_uint32_x >> 8;
  *crypto_uint32_s++ = crypto_uint32_x >> 16;
  *crypto_uint32_s++ = crypto_uint32_x >> 24;
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_shlmod(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_s) {
  int crypto_uint32_k, crypto_uint32_l;
  for (crypto_uint32_l = 0,crypto_uint32_k = 1;crypto_uint32_k < 32;++crypto_uint32_l,crypto_uint32_k *= 2)
    crypto_uint32_x ^= (crypto_uint32_x ^ (crypto_uint32_x << crypto_uint32_k)) & -((crypto_uint32_s >> crypto_uint32_l) & 1);
  return crypto_uint32_x;
}

__attribute__((unused))
static inline
crypto_uint32_signed crypto_uint32_signed_negative_mask(crypto_uint32_signed crypto_uint32_x) {
  crypto_uint32_x >>= 32-6;
  crypto_uint32_x ^= crypto_uint32_signed_optblocker;
  crypto_uint32_x >>= 5;
  return crypto_uint32_x;
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_nonzero_mask(crypto_uint32 crypto_uint32_x) {
  return crypto_uint32_signed_negative_mask(crypto_uint32_x | -crypto_uint32_x);
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_zero_mask(crypto_uint32 crypto_uint32_x) {
  return ~crypto_uint32_nonzero_mask(crypto_uint32_x);
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_unequal_mask(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  return crypto_uint32_nonzero_mask(crypto_uint32_x ^ crypto_uint32_y);
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_equal_mask(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  return ~crypto_uint32_unequal_mask(crypto_uint32_x,crypto_uint32_y);
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_min(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  crypto_uint32 crypto_uint32_r = crypto_uint32_y ^ crypto_uint32_x;
  crypto_uint32 crypto_uint32_z = crypto_uint32_y - crypto_uint32_x;
  crypto_uint32_z ^= crypto_uint32_r & (crypto_uint32_z ^ crypto_uint32_y ^ (((crypto_uint32) 1) << (32-1)));
  crypto_uint32_z = crypto_uint32_signed_negative_mask(crypto_uint32_z);
  crypto_uint32_z &= crypto_uint32_r;
  return crypto_uint32_x ^ crypto_uint32_z;
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_max(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  crypto_uint32 crypto_uint32_r = crypto_uint32_y ^ crypto_uint32_x;
  crypto_uint32 crypto_uint32_z = crypto_uint32_y - crypto_uint32_x;
  crypto_uint32_z ^= crypto_uint32_r & (crypto_uint32_z ^ crypto_uint32_y ^ (((crypto_uint32) 1) << (32-1)));
  crypto_uint32_z = crypto_uint32_signed_negative_mask(crypto_uint32_z);
  crypto_uint32_z &= crypto_uint32_r;
  return crypto_uint32_y ^ crypto_uint32_z;
}

__attribute__((unused))
static inline
void crypto_uint32_minmax(crypto_uint32 *crypto_uint32_p,crypto_uint32 *crypto_uint32_q) {
  crypto_uint32 crypto_uint32_x = *crypto_uint32_p;
  crypto_uint32 crypto_uint32_y = *crypto_uint32_q;
  crypto_uint32 crypto_uint32_r = crypto_uint32_y ^ crypto_uint32_x;
  crypto_uint32 crypto_uint32_z = crypto_uint32_y - crypto_uint32_x;
  crypto_uint32_z ^= crypto_uint32_r & (crypto_uint32_z ^ crypto_uint32_y ^ (((crypto_uint32) 1) << (32-1)));
  crypto_uint32_z = crypto_uint32_signed_negative_mask(crypto_uint32_z);
  crypto_uint32_z &= crypto_uint32_r;
  *crypto_uint32_p = crypto_uint32_x ^ crypto_uint32_z;
  *crypto_uint32_q = crypto_uint32_y ^ crypto_uint32_z;
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_smaller_mask(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  crypto_uint32 crypto_uint32_r = crypto_uint32_x ^ crypto_uint32_y;
  crypto_uint32 crypto_uint32_z = crypto_uint32_x - crypto_uint32_y;
  crypto_uint32_z ^= crypto_uint32_r & (crypto_uint32_z ^ crypto_uint32_x ^ (((crypto_uint32) 1) << (32-1)));
  return crypto_uint32_signed_negative_mask(crypto_uint32_z);
}

__attribute__((unused))
static inline
crypto_uint32 crypto_uint32_leq_mask(crypto_uint32 crypto_uint32_x,crypto_uint32 crypto_uint32_y) {
  return ~crypto_uint32_smaller_mask(crypto_uint32_y,crypto_uint32_x);
}

#endif