
#include "first0.h"  /* LOOKUP_FIRSTBLANK */

#define SETUP_BITMAPS							\
uint64_t list[MAXMARKS][NUMWORDS]/*={0}*/;   /* list bitmap */		\
uint64_t dist[MAXMARKS][NUMWORDS]/*={0}*/;   /* dist bitmap */		\
uint64_t comp[MAXMARKS][NUMWORDS]/*={0}*/;   /* dist bitmap */		\
uint64_t newbit=1;

/* CHECK THIS for X86 0xFFFFFFFE */
#define LOOKUP_FIRSTBLANK_64(i)							\
{										\
    (i>=0xFFFFFFFF00000000) ?  ( LOOKUP_FIRSTBLANK( (uint32_t)(i) )+32 ) :	\
    	( LOOKUP_FIRSTBLANK((uint32_t)(i>>32)) )				\
}

#define SET_NEXT_MARK							\
if (comp[depth][0] < 0xfffffffffffffffe) {				\
    int s = LOOKUP_FIRSTBLANK_64( comp[depth][0] );			\
        if ((count[depth] += s) > limit[depth]) {break;} /* no space */	\
        else {								\
            CLLR_XX_BITMAPS;						\
        }								\
} else { /* s>=32 */							\
    if ((count[depth] += 64) > limit[depth]) {break;} /* no space */	\
    else {								\
        uint64_t temp = comp[depth][0];					\
        CLLR_64_BITMAPS;						\
        if (temp == 0xffffffff) goto stay;				\
    }									\
}

#define UP_BITMAPS							\
newbit=0;

#define GET_DIST_32							\
((uint32_t)(dist[depth][0]>>32))




#define INTITIALIZE_BITMAPS						\
list[depth][0]=0;							\
dist[depth][0]=0;							\
comp[depth][0]=0;

#define CLLR_XX_BITMAPS							\
    uint64_t temp0, temp1;						\
    int ss=64-s;							\
    list[depth][0] = (list[depth][0] >> s) | (newbit << ss);		\
    comp[depth][0] = (comp[depth][0] << s) | temp1;

#define CLLR_64_BITMAPS							\
    comp[depth][0] = 0;							\
    list[depth][0] = newbit;						\
    newbit = 0;

#define DEEPER_BITMAPS							\
/*#define depthp1 depth+1*/						\
int depthp1 = depth+1;							\
list[depthp1][0] = list[depth][0];					\
dist[depthp1][0] = list[depthp1][0] | dist[depth][0];			\
comp[depthp1][0] = dist[depthp1][0] | comp[depth][0];			\
newbit=1;

