#include #include #include #include "ooo.h" void abort0(); void abort1(); long divloop(unsigned char a[]) { long l=0; long count=0; long q=5; long n2=3; long n1=QUOTIENT*n2+1; for (;;) { // printf("%ld\n",l); switch(a[l]) { case 0: //printf("%ld\n",q); #ifdef MORE_DEFINED q=n1/n2; // for performance, we have to place it here. #endif if (n2==0) abort0(); if (n2==-1 && n1==LONG_MIN) abort0(); #ifndef MORE_DEFINED q=n1/n2; // to eliminate undefined behaviour, we have to place it here. #endif l+=q+1-QUOTIENT; break; case 2: //printf("%ld\n",q); #ifdef MORE_DEFINED q=n1/n2; // for performance, we have to place it here. #endif if (n2==0) abort1(); if (n2==-1 && n1==LONG_MIN) abort1(); #ifndef MORE_DEFINED q=n1/n2; // to eliminate undefined behaviour, we have to place it here. #endif l+=q+1-QUOTIENT; break; case 4: //printf("%ld\n",q); #ifdef MORE_DEFINED q=n1/n2; // for performance, we have to place it here. #endif if (n2==0) abort2(); if (n2==-1 && n1==LONG_MIN) abort2(); #ifndef MORE_DEFINED q=n1/n2; // to eliminate undefined behaviour, we have to place it here. #endif l+=q+1-QUOTIENT; break; case 6: //printf("%ld\n",q); #ifdef MORE_DEFINED q=n1/n2; // for performance, we have to place it here. #endif if (n2==0) abort3(); if (n2==-1 && n1==LONG_MIN) abort3(); #ifndef MORE_DEFINED q=n1/n2; // to eliminate undefined behaviour, we have to place it here. #endif l+=q+1-QUOTIENT; // use the result for the switch (to so the latency becomes // effective); break; case 8: count+=10000; if (count>=100000000) return q; l=0; break; // unused cases that avoid overspecialization of the other cases // by the compiler: case 11: n1=1234567; n2=2345678; q=2222222; l=12; break; case 13: n1=8888888; n2=1111111; q=33333333; l=11; break; case 15: n1=888888; n2=111111; q=3333333; l=10; break; case 17: n1=88888881; n2=11111111; q=333333331; l=13; break; case 19: n1=LONG_MIN; n2=-1; q=33333334; l=14; break; case 21: n1=88888882; n2=0; q=333333332; l=15; break; } } return q; }