/* WARNING: auto-generated (by autogen/useint); do not edit */

#include <immintrin.h>
typedef __m256i int32x8;
#define int32x8_load(z) _mm256_loadu_si256((__m256i *) (z))
#define int32x8_store(z,i) _mm256_storeu_si256((__m256i *) (z),(i))
#define int32x8_broadcast _mm256_set1_epi32
#include "djbsort.h"
#include "uint32down_sort.h"

void uint32down_sort(uint32_t *x,long long n)
{
  long long j;
  int32x8 vecxor = int32x8_broadcast(0x7fffffff);
  for (j = 0;j+16 <= n;j += 16) {
    int32x8 x0 = int32x8_load(x+j);
    int32x8 x1 = int32x8_load(x+j+8);
    x0 ^= vecxor;
    x1 ^= vecxor;
    int32x8_store(x+j,x0);
    int32x8_store(x+j+8,x1);
  }
  for (;j < n;++j) x[j] ^= 0x7fffffff;
  djbsort_int32((int32_t *) x,n);
  for (j = 0;j+16 <= n;j += 16) {
    int32x8 x0 = int32x8_load(x+j);
    int32x8 x1 = int32x8_load(x+j+8);
    x0 ^= vecxor;
    x1 ^= vecxor;
    int32x8_store(x+j,x0);
    int32x8_store(x+j+8,x1);
  }
  for (;j < n;++j) x[j] ^= 0x7fffffff;
}
