1long
2f (long x)
3{
4  return x / (-0x7fffffffL - 1L);
5}
6
7long
8r (long x)
9{
10  return x % (-0x7fffffffL - 1L);
11}
12
13/* Since we have a negative divisor, this equation must hold for the
14   results of / and %; no specific results are guaranteed.  */
15long
16std_eqn (long num, long denom, long quot, long rem)
17{
18  /* For completeness, a check for "ABS (rem) < ABS (denom)" belongs here,
19     but causes trouble on 32-bit machines and isn't worthwhile.  */
20  return quot * (-0x7fffffffL - 1L) + rem == num;
21}
22
23long nums[] =
24{
25  -1L, 0x7fffffffL, -0x7fffffffL - 1L
26};
27
28main ()
29{
30  int i;
31
32  for (i = 0;
33       i < sizeof (nums) / sizeof (nums[0]);
34       i++)
35    if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)
36      abort ();
37
38  exit (0);
39}
40