From 5be354201f81db5f599b59391aa0fa2bf6cf9739 Mon Sep 17 00:00:00 2001
From: Kia <kia@special-circumstanc.es>
Date: Thu, 9 Sep 2021 18:55:50 -0600
Subject: [PATCH] track byte indices

---
 gen_intrange.c | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/gen_intrange.c b/gen_intrange.c
index d4275f6..a374938 100644
--- a/gen_intrange.c
+++ b/gen_intrange.c
@@ -66,13 +66,18 @@ void HCFS_ADD_CHAR(uint8_t chr) {
 
 }
 
-void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) {
+// checkpoint, restart @ checkpoint at every CHOICE
+
+void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes, uint8_t starting_byte_index) {
+	uint8_t current_byte_index = starting_byte_index;
   // Possible FIXME: TallerThanMe
   if (1 == bytes) {
     struct charset *cs = new_charset();
     for (uint64_t i=low; i<=high; ++i) {
       charset_set(cs, i, 1);
     }
+    printf("current byte index = %d    ", current_byte_index);
+    current_byte_index++;
     print_charset(cs);
   }
   else if (1 < bytes) {
@@ -84,14 +89,20 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) {
       HCFS_BEGIN_CHOICE(); 
 
       {
-	HCFS_BEGIN_SEQ(); 
+	HCFS_BEGIN_SEQ();
+	current_byte_index = starting_byte_index;
 	{
+    printf("current byte index = %d    ", current_byte_index);
+		current_byte_index++;
+
 	  HCFS_ADD_CHAR(low_head);
-	  gen_int_range(low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1);
+	  gen_int_range(low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1, current_byte_index);
 	} 
 	HCFS_END_SEQ();
 	
 	HCFS_BEGIN_SEQ(); 
+	current_byte_index = starting_byte_index;
+
 	{
 	  struct charset * hd = new_charset();
 	  struct charset * rest = new_charset();
@@ -99,16 +110,27 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) {
 	    charset_set(hd, i, (i > low_head && i < hi_head));
 	    charset_set(rest, i, 1);
 	  }
+    printf("current byte index = %d    ", current_byte_index);
+		current_byte_index++;
+
 	  HCFS_ADD_CHARSET(hd);
-	  for (int i = 2; i <= bytes; i++)
+	  for (int i = 2; i <= bytes; i++) {
+    printf("current byte index = %d    ", current_byte_index);
+  		current_byte_index++;
+
 	    HCFS_ADD_CHARSET(rest);
+	  }
 	}
 	HCFS_END_SEQ();
 	
 	HCFS_BEGIN_SEQ();
 	{
+		current_byte_index = starting_byte_index;
+    printf("current byte index = %d    ", current_byte_index);
+		current_byte_index++;
+
 	  HCFS_ADD_CHAR(hi_head);
-	  gen_int_range(0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1);
+	  gen_int_range(0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1, current_byte_index);
 	} 
 	HCFS_END_SEQ();
   }
@@ -120,11 +142,17 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) {
       // TODO: find a way to merge this with the higher-up SEQ
     HCFS_BEGIN_CHOICE(); {
 		HCFS_BEGIN_SEQ(); {
+		current_byte_index = starting_byte_index;
+
+    printf("current byte index = %d    ", current_byte_index);
+		current_byte_index++;
+
 	  HCFS_ADD_CHAR(low_head);
 	  gen_int_range(
 			low & ((1 << (8 * (bytes - 1))) - 1),
 			high & ((1 << (8 * (bytes - 1))) - 1),
-			bytes - 1);
+			bytes - 1,
+			current_byte_index);
 		}
 		HCFS_END_SEQ();
     }
@@ -142,6 +170,6 @@ int main(int argc, char *argv[]) {
     uint64_t high  = atoi(argv[3]);
     printf("BYTES = %hhu\nLOW = %llu\nHIGH=%llu\n\n", bytes, low, high);
 
-    gen_int_range(low, high, bytes);
+    gen_int_range(low, high, bytes, 0);
 
 }
\ No newline at end of file
-- 
GitLab