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

#include <immintrin.h>
typedef __m256i int64x4;
#define int64x4_load(z) _mm256_loadu_si256((__m256i *) (z))
#define int64x4_store(z,i) _mm256_storeu_si256((__m256i *) (z),(i))
#define int64x4_broadcast _mm256_set1_epi64x
#include "djbsort.h"
#include "uint64down_sort.h"

void uint64down_sort(uint64_t *x,long long n)
{
  long long j;
  int64x4 vecxor = int64x4_broadcast(0x7fffffffffffffffULL);
  for (j = 0;j+8 <= n;j += 8) {
    int64x4 x0 = int64x4_load(x+j);
    int64x4 x1 = int64x4_load(x+j+4);
    x0 ^= vecxor;
    x1 ^= vecxor;
    int64x4_store(x+j,x0);
    int64x4_store(x+j+4,x1);
  }
  for (;j < n;++j) x[j] ^= 0x7fffffffffffffffULL;
  djbsort_int64((int64_t *) x,n);
  for (j = 0;j+8 <= n;j += 8) {
    int64x4 x0 = int64x4_load(x+j);
    int64x4 x1 = int64x4_load(x+j+4);
    x0 ^= vecxor;
    x1 ^= vecxor;
    int64x4_store(x+j,x0);
    int64x4_store(x+j+4,x1);
  }
  for (;j < n;++j) x[j] ^= 0x7fffffffffffffffULL;
}
