+void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len)
+{
+ unsigned long int i, current;
+ t_BlockSortDecode *in;
+
+ in = malloc(sizeof(t_BlockSortDecode)*len);
+
+ for(i=0; i<len; i++) {
+ in[i].c = c[i];
+ in[i].pos = i;
+ }
+
+ qsort(in, len, sizeof(t_BlockSortDecode), _compare);
+
+ current = k;
+ i=0;
+ do {
+ dst[i++] = in[current].c;
+ current = in[current].pos;
+ } while (current != k);
+ free(in);
+}
+