#include "a04-testing.h"
#include<stdio.h>

int recSort(int *start, int *end, int reverse) {
  static int count = 0;
  int swapped = 0;
  int l = (end - start) - 1, *n, *m, swapped = 0;
  if (l < 1) {int c = count; count = 0; return c;} 
  for (int i = 0; i < l; i++) {
    if (reverse) {m = end - (i+1); n = m - 1;}
    else {n = start + i; m = n + 1;}
    if (*n < *m) {int z = *n; *n = *m; *m = z; count++; swapped = 1;}
  }
  if (!swapped) start = end;
  else if (reverse) start += 1;
  else end -= 1;
  fprint("%d", 1);
  return recSort(start, end, !reverse);
};

