1 /* PR optimization/10024 */ 2 extern int *allegro_errno; 3 typedef long fixed; 4 extern inline int fixfloor(fixed x)5fixfloor (fixed x) 6 { 7 if (x >= 0) 8 return (x >> 16); 9 else 10 return ~((~x) >> 16); 11 } 12 extern inline int fixtoi(fixed x)13fixtoi (fixed x) 14 { 15 return fixfloor (x) + ((x & 0x8000) >> 15); 16 } 17 extern inline fixed ftofix(double x)18ftofix (double x) 19 { 20 if (x > 32767.0) 21 { 22 *allegro_errno = 34; 23 return 0x7FFFFFFF; 24 } 25 if (x < -32767.0) 26 { 27 *allegro_errno = 34; 28 return -0x7FFFFFFF; 29 } 30 return (long) (x * 65536.0 + (x < 0 ? -0.5 : 0.5)); 31 } 32 extern inline double fixtof(fixed x)33fixtof (fixed x) 34 { 35 return (double) x / 65536.0; 36 } 37 extern inline fixed fixdiv(fixed x,fixed y)38fixdiv (fixed x, fixed y) 39 { 40 if (y == 0) 41 { 42 *allegro_errno = 34; 43 return (x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF; 44 } 45 else 46 return ftofix (fixtof (x) / fixtof (y)); 47 } 48 extern inline fixed itofix(int x)49itofix (int x) 50 { 51 return x << 16; 52 } 53 54 int foo(int n)55foo (int n) 56 { 57 return fixtoi (fixdiv (itofix (512), itofix (n))); 58 } 59