sgen_qsort (void * base, size_t nel, size_t width, int (*<T593>) (const void *, const void *) compar)
{
  long unsigned int width.0;
  long int width.1;
  long int D.17566;
  sizetype D.17567;
  bitsizetype D.17568;
  bitsizetype D.17569;
  unsigned char[0:D.17567] * pivot_tmp.2;
  long unsigned int width.3;
  long int width.4;
  long int D.17573;
  sizetype D.17574;
  bitsizetype D.17575;
  bitsizetype D.17576;
  unsigned char[0:D.17574] * swap_tmp.5;
  unsigned char[0:D.17574] * D.17578;
  unsigned char[0:D.17567] * D.17579;
  void * saved_stack.6;
  unsigned char pivot_tmp[0:D.17567] [value-expr: *pivot_tmp.2];
  unsigned char swap_tmp[0:D.17574] [value-expr: *swap_tmp.5];

  saved_stack.6 = __builtin_stack_save ();
  try
    {
      width.0 = width;
      width.1 = (long int) width.0;
      D.17566 = width.1 + -1;
      D.17567 = (sizetype) D.17566;
      D.17568 = (bitsizetype) width.0;
      D.17569 = D.17568 * 8;
      D.17568 = (bitsizetype) width.0;
      D.17569 = D.17568 * 8;
      pivot_tmp.2 = __builtin_alloca_with_align (width.0, 8);
      width.3 = width;
      width.4 = (long int) width.3;
      D.17573 = width.4 + -1;
      D.17574 = (sizetype) D.17573;
      D.17575 = (bitsizetype) width.3;
      D.17576 = D.17575 * 8;
      D.17575 = (bitsizetype) width.3;
      D.17576 = D.17575 * 8;
      swap_tmp.5 = __builtin_alloca_with_align (width.3, 8);
      D.17578 = swap_tmp.5;
      D.17579 = pivot_tmp.2;
      qsort_rec (base, nel, width, compar, D.17579, D.17578);
    }
  finally
    {
      __builtin_stack_restore (saved_stack.6);
    }
}


qsort_rec (void * base, size_t nel, size_t width, int (*<T593>) (const void *, const void *) compar, unsigned char * pivot_tmp, unsigned char * swap_tmp)
{
  long unsigned int D.17585;
  long unsigned int D.17586;
  long unsigned int D.17587;
  long unsigned int D.17588;
  void * D.17589;
  size_t pivot_idx;

  if (nel <= 1) goto <D.17581>; else goto <D.17582>;
  <D.17581>:
  return;
  <D.17582>:
  pivot_idx = partition (base, nel, width, compar, pivot_tmp, swap_tmp);
  qsort_rec (base, pivot_idx, width, compar, pivot_tmp, swap_tmp);
  if (pivot_idx < nel) goto <D.17583>; else goto <D.17584>;
  <D.17583>:
  D.17585 = nel - pivot_idx;
  D.17586 = D.17585 + 18446744073709551615;
  D.17587 = pivot_idx + 1;
  D.17588 = D.17587 * width;
  D.17589 = base + D.17588;
  qsort_rec (D.17589, D.17586, width, compar, pivot_tmp, swap_tmp);
  <D.17584>:
}


partition (void * base, size_t nel, size_t width, int (*<T593>) (const void *, const void *) compar, unsigned char * pivot_tmp, unsigned char * swap_tmp)
{
  long unsigned int D.17591;
  unsigned char * D.17592;
  long unsigned int D.17595;
  unsigned char * D.17596;
  long unsigned int D.17597;
  unsigned char * D.17598;
  long unsigned int D.17599;
  const void * D.17600;
  int D.17601;
  long unsigned int D.17606;
  unsigned char * D.17607;
  long unsigned int D.17608;
  unsigned char * D.17609;
  long unsigned int D.17610;
  long unsigned int D.17613;
  unsigned char * D.17614;
  long unsigned int D.17615;
  unsigned char * D.17616;
  size_t D.17617;
  size_t pivot_idx;
  size_t s;
  size_t i;

  pivot_idx = nel >> 1;
  D.17591 = pivot_idx * width;
  D.17592 = base + D.17591;
  memcpy (pivot_tmp, D.17592, width);
  {
    size_t __i;
    size_t __j;

    __i = pivot_idx;
    __j = nel + 18446744073709551615;
    if (__i != __j) goto <D.17593>; else goto <D.17594>;
    <D.17593>:
    D.17595 = __i * width;
    D.17596 = base + D.17595;
    memcpy (swap_tmp, D.17596, width);
    D.17597 = __j * width;
    D.17598 = base + D.17597;
    D.17595 = __i * width;
    D.17596 = base + D.17595;
    memcpy (D.17596, D.17598, width);
    D.17597 = __j * width;
    D.17598 = base + D.17597;
    memcpy (D.17598, swap_tmp, width);
    <D.17594>:
  }
  s = 0;
  i = 0;
  goto <D.17538>;
  <D.17537>:
  D.17599 = i * width;
  D.17600 = base + D.17599;
  D.17601 = compar (D.17600, pivot_tmp);
  if (D.17601 <= 0) goto <D.17602>; else goto <D.17603>;
  <D.17602>:
  {
    size_t __i;
    size_t __j;

    __i = i;
    __j = s;
    if (__i != __j) goto <D.17604>; else goto <D.17605>;
    <D.17604>:
    D.17606 = __i * width;
    D.17607 = base + D.17606;
    memcpy (swap_tmp, D.17607, width);
    D.17608 = __j * width;
    D.17609 = base + D.17608;
    D.17606 = __i * width;
    D.17607 = base + D.17606;
    memcpy (D.17607, D.17609, width);
    D.17608 = __j * width;
    D.17609 = base + D.17608;
    memcpy (D.17609, swap_tmp, width);
    <D.17605>:
  }
  s = s + 1;
  <D.17603>:
  i = i + 1;
  <D.17538>:
  D.17610 = nel + 18446744073709551615;
  if (D.17610 > i) goto <D.17537>; else goto <D.17539>;
  <D.17539>:
  {
    size_t __i;
    size_t __j;

    __i = s;
    __j = nel + 18446744073709551615;
    if (__i != __j) goto <D.17611>; else goto <D.17612>;
    <D.17611>:
    D.17613 = __i * width;
    D.17614 = base + D.17613;
    memcpy (swap_tmp, D.17614, width);
    D.17615 = __j * width;
    D.17616 = base + D.17615;
    D.17613 = __i * width;
    D.17614 = base + D.17613;
    memcpy (D.17614, D.17616, width);
    D.17615 = __j * width;
    D.17616 = base + D.17615;
    memcpy (D.17616, swap_tmp, width);
    <D.17612>:
  }
  D.17617 = s;
  return D.17617;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.17619;
  long unsigned int D.17620;

  D.17620 = __builtin_object_size (__dest, 0);
  D.17619 = __builtin___memcpy_chk (__dest, __src, __len, D.17620);
  return D.17619;
}


