#include "cmp.h"
const int BLOCK = (1 << 3);
const int SIZE = 12;
void remember(int n) {
for (int i = SIZE - 3, pos = 1; i >= 0; i -= 3, pos += BLOCK) {
int cur = (n >> i) & (BLOCK - 1);
bit_set(pos + cur);
}
}
int compare(int b) {
for (int i = SIZE - 3, pos = 1; i >= 0; i -= 3, pos += BLOCK) {
int cur = (b >> i) & (BLOCK - 1);
if (!bit_get(pos + cur)) {
if (cur <= 3) {
for (int j = 0; j < cur; j++) {
if (bit_get(pos + j))
return 1;
}
return -1;
} else {
for (int j = cur + 1; j < 8; j++) {
if (bit_get(pos + j))
return -1;
}
return 1;
}
}
}
return 0;
}