#ifndef PIN #error Please compile with -DPIN= #else #ifndef _ #define _ __FILE__ /* Initialize PIN bits */ #if PIN % 2 > 0 #define BIT0 #endif #if PIN % 4 > 1 #define BIT1 #endif /* Data array */ static const unsigned char data[] = {0 #define OUTPUT_BYTE #define STEP0 #include _ #define OUTPUT_BYTE #define STEP1 #include _ #define OUTPUT_BYTE #define STEP0 #define STEP1 #include _ #define OUTPUT_BYTE #define STEP2 #include _ }; /* Output data */ #include int main() { return !fwrite(data, 4, 1, stdout); } #else #ifdef OUTPUT_BYTE #undef OUTPUT_BYTE /* Repeat PRNG steps. */ #include _ /* Serialize PRNG bits to bytes. */ #ifdef BIT0 |1 #endif #ifdef BIT1 |2 #endif /* Start next byte. */ ,0 #else /* Run PRNG steps. We want to interpret STEP* as bits that encode counter for number of steps to run. STEP2 is the highest order bit, so it should run STEP1 twice. */ #ifdef STEP2 /* Consume the highest order bit */ #undef STEP2 /* Get rid of lower-order bit steps such that if the number starts with 1xx, we will reach 100 by recursively processing the lower order bits. */ #include _ /* Now we do the steps to multiply STEP1 twice, first time */ #define STEP1 #include _ /* Second time (fall through) */ #define STEP1 #endif #ifdef STEP1 #undef STEP1 #include _ #define STEP0 #include _ #define STEP0 #endif #ifdef STEP0 #undef STEP0 /* Run a single step of PRNG. */ #undef BIT2 #ifdef BIT1 #ifndef BIT0 #define BIT2 #endif #else #ifdef BIT0 #define BIT2 #endif #endif #undef BIT0 #ifdef BIT1 #define BIT0 #endif #undef BIT1 #ifdef BIT2 #define BIT1 #endif #endif #endif #endif #endif