1 #include <stdlib.h>
2 #include <stdio.h>
3 
my_div(int a,int b)4 int my_div(int a, int b) {
5 return a/b;
6 }
7 
my_mod(int a,int b)8 int my_mod(int a, int b) {
9 return a%b;
10 }
11 
my_udiv(unsigned int a,unsigned int b)12 unsigned int my_udiv(unsigned int a, unsigned int b) {
13 return a/b;
14 }
15 
my_umod(unsigned int a,unsigned int b)16 unsigned int my_umod(unsigned int a, unsigned int b) {
17 return a%b;
18 }
19 
20 
foo(void)21 void foo(void) {
22   if (my_div(5,-3) == -1) {
23     puts("good 0");
24   }
25   if (my_mod(5,-3) == 2) {
26     puts("good 1");
27   }
28   if (my_div(-5,3) == -1) {
29     puts("good 2");
30   }
31   if (my_mod(-5,3) == -2) {
32     puts("good 3");
33   }
34   if (my_div(-5,-3) == 1) {
35     puts("good 4");
36   }
37   if (my_mod(-5,-3) == -2) {
38     puts("good 5");
39   }
40 
41   // unsigned
42   if (my_udiv(5,-3) == 0) {
43     puts("good 6");
44   }
45   if (my_umod(5,-3) == 5) {
46     puts("good 7");
47   }
48   if (my_udiv(-5,3) == 0x55555553) {
49     puts("good 8");
50   }
51   if (my_umod(-5,3) == 2) {
52     puts("good 9");
53   }
54   if (my_udiv(-5,-3) == 0) {
55     puts("good 10");
56   }
57   if (my_umod(-5,-3) == -5) {
58     puts("good 11");
59   }
60 }
61 
main()62 int main() {
63   foo();
64 }
65 
66