#include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { assert(argc == 3); int16_t low = atoi(argv[1]); int16_t high = atoi(argv[2]); printf("LOW = %d\nHIGH=%d\n", low, high); } void gen_int_range(HAllocator *mm__, HCFStack *stk__, uint64_t low, uint64_t high, uint8_t bytes) { /* Possible FIXME: TallerThanMe */ if (1 == bytes) { HCharset cs = new_charset(mm__); for (uint64_t i=low; i<=high; ++i) { charset_set(cs, i, 1); } HCFS_ADD_CHARSET(cs); } else if (1 < bytes) { uint8_t low_head, hi_head; low_head = ((low >> (8*(bytes - 1))) & 0xFF); hi_head = ((high >> (8*(bytes - 1))) & 0xFF); if (low_head != hi_head) { HCFS_BEGIN_CHOICE() { HCFS_BEGIN_SEQ() { HCFS_ADD_CHAR(low_head); gen_int_range(mm__, stk__, low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1); } HCFS_END_SEQ(); HCFS_BEGIN_SEQ() { HCharset hd = new_charset(mm__); HCharset rest = new_charset(mm__); for (int i = 0; i < 256; i++) { charset_set(hd, i, (i > low_head && i < hi_head)); charset_set(rest, i, 1); } HCFS_ADD_CHARSET(hd); for (int i = 2; i < bytes; i++) HCFS_ADD_CHARSET(rest); } HCFS_END_SEQ(); HCFS_BEGIN_SEQ() { HCFS_ADD_CHAR(hi_head); gen_int_range(mm__, stk__, 0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1); } HCFS_END_SEQ(); } HCFS_END_CHOICE(); } else { // TODO: find a way to merge this with the higher-up SEQ HCFS_BEGIN_CHOICE() { HCFS_BEGIN_SEQ() { HCFS_ADD_CHAR(low_head); gen_int_range(mm__, stk__, low & ((1 << (8 * (bytes - 1))) - 1), high & ((1 << (8 * (bytes - 1))) - 1), bytes - 1); } HCFS_END_SEQ(); } HCFS_END_CHOICE(); } } }