sgen_qsort (void * base, size_t nel, size_t width, int (*<T594>) (const void *, const void *) compar)
{
  long unsigned int width.0;
  long int width.1;
  long int D.18096;
  sizetype D.18097;
  bitsizetype D.18098;
  bitsizetype D.18099;
  unsigned char[0:D.18097] * pivot_tmp.2;
  long unsigned int width.3;
  long int width.4;
  long int D.18103;
  sizetype D.18104;
  bitsizetype D.18105;
  bitsizetype D.18106;
  unsigned char[0:D.18104] * swap_tmp.5;
  unsigned char[0:D.18097] * D.18108;
  unsigned char[0:D.18104] * D.18109;
  void * saved_stack.6;
  unsigned char pivot_tmp[0:D.18097] [value-expr: *pivot_tmp.2];
  unsigned char swap_tmp[0:D.18104] [value-expr: *swap_tmp.5];

  saved_stack.6 = __builtin_stack_save ();
  try
    {
      width.0 = width;
      width.1 = (long int) width.0;
      D.18096 = width.1 + -1;
      D.18097 = (sizetype) D.18096;
      D.18098 = (bitsizetype) width.0;
      D.18099 = D.18098 * 8;
      D.18098 = (bitsizetype) width.0;
      D.18099 = D.18098 * 8;
      pivot_tmp.2 = __builtin_alloca_with_align (width.0, 8);
      width.3 = width;
      width.4 = (long int) width.3;
      D.18103 = width.4 + -1;
      D.18104 = (sizetype) D.18103;
      D.18105 = (bitsizetype) width.3;
      D.18106 = D.18105 * 8;
      D.18105 = (bitsizetype) width.3;
      D.18106 = D.18105 * 8;
      swap_tmp.5 = __builtin_alloca_with_align (width.3, 8);
      D.18108 = pivot_tmp.2;
      D.18109 = swap_tmp.5;
      qsort_rec (base, nel, width, compar, D.18108, D.18109);
    }
  finally
    {
      __builtin_stack_restore (saved_stack.6);
    }
}


qsort_rec (void * base, size_t nel, size_t width, int (*<T594>) (const void *, const void *) compar, unsigned char * pivot_tmp, unsigned char * swap_tmp)
{
  long unsigned int D.18115;
  long unsigned int D.18116;
  void * D.18117;
  long unsigned int D.18118;
  long unsigned int D.18119;
  size_t pivot_idx;

  if (nel <= 1) goto <D.18111>; else goto <D.18112>;
  <D.18111>:
  return;
  <D.18112>:
  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.18113>; else goto <D.18114>;
  <D.18113>:
  D.18115 = pivot_idx + 1;
  D.18116 = D.18115 * width;
  D.18117 = base + D.18116;
  D.18118 = nel - pivot_idx;
  D.18119 = D.18118 + 18446744073709551615;
  qsort_rec (D.18117, D.18119, width, compar, pivot_tmp, swap_tmp);
  <D.18114>:
}


partition (void * base, size_t nel, size_t width, int (*<T594>) (const void *, const void *) compar, unsigned char * pivot_tmp, unsigned char * swap_tmp)
{
  long unsigned int D.18121;
  unsigned char * D.18122;
  long unsigned int D.18125;
  unsigned char * D.18126;
  long unsigned int D.18127;
  unsigned char * D.18128;
  long unsigned int D.18129;
  const void * D.18130;
  int D.18131;
  long unsigned int D.18136;
  unsigned char * D.18137;
  long unsigned int D.18138;
  unsigned char * D.18139;
  long unsigned int D.18140;
  long unsigned int D.18143;
  unsigned char * D.18144;
  long unsigned int D.18145;
  unsigned char * D.18146;
  size_t D.18147;
  size_t pivot_idx;
  size_t s;
  size_t i;

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

    __i = pivot_idx;
    __j = nel + 18446744073709551615;
    if (__i != __j) goto <D.18123>; else goto <D.18124>;
    <D.18123>:
    D.18125 = __i * width;
    D.18126 = base + D.18125;
    memcpy (swap_tmp, D.18126, width);
    D.18125 = __i * width;
    D.18126 = base + D.18125;
    D.18127 = __j * width;
    D.18128 = base + D.18127;
    memcpy (D.18126, D.18128, width);
    D.18127 = __j * width;
    D.18128 = base + D.18127;
    memcpy (D.18128, swap_tmp, width);
    <D.18124>:
  }
  s = 0;
  i = 0;
  goto <D.18068>;
  <D.18067>:
  D.18129 = i * width;
  D.18130 = base + D.18129;
  D.18131 = compar (D.18130, pivot_tmp);
  if (D.18131 <= 0) goto <D.18132>; else goto <D.18133>;
  <D.18132>:
  {
    size_t __i;
    size_t __j;

    __i = i;
    __j = s;
    if (__i != __j) goto <D.18134>; else goto <D.18135>;
    <D.18134>:
    D.18136 = __i * width;
    D.18137 = base + D.18136;
    memcpy (swap_tmp, D.18137, width);
    D.18136 = __i * width;
    D.18137 = base + D.18136;
    D.18138 = __j * width;
    D.18139 = base + D.18138;
    memcpy (D.18137, D.18139, width);
    D.18138 = __j * width;
    D.18139 = base + D.18138;
    memcpy (D.18139, swap_tmp, width);
    <D.18135>:
  }
  s = s + 1;
  <D.18133>:
  i = i + 1;
  <D.18068>:
  D.18140 = nel + 18446744073709551615;
  if (D.18140 > i) goto <D.18067>; else goto <D.18069>;
  <D.18069>:
  {
    size_t __i;
    size_t __j;

    __i = s;
    __j = nel + 18446744073709551615;
    if (__i != __j) goto <D.18141>; else goto <D.18142>;
    <D.18141>:
    D.18143 = __i * width;
    D.18144 = base + D.18143;
    memcpy (swap_tmp, D.18144, width);
    D.18143 = __i * width;
    D.18144 = base + D.18143;
    D.18145 = __j * width;
    D.18146 = base + D.18145;
    memcpy (D.18144, D.18146, width);
    D.18145 = __j * width;
    D.18146 = base + D.18145;
    memcpy (D.18146, swap_tmp, width);
    <D.18142>:
  }
  D.18147 = s;
  return D.18147;
}


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

  D.18150 = __builtin_object_size (__dest, 0);
  D.18149 = __builtin___memcpy_chk (__dest, __src, __len, D.18150);
  return D.18149;
}


