#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

#define M 50000

// g(a,b) should always return a value in [0,M]
int g(int a, int b)
{
  if (a < 0 || b <=0) {
	printf("invalid arguments \n");
  	exit (-1);
  }
  printf("a+b : %i \n", a+b);
  if ((a + b > M) || (a+b < 0)) {
	printf("overflow error \n");
  	exit (-1) ;
  }
  printf("no detected error \n");
  return(a+b) ;
};

void main () {
 int r ;
 r = g(4,8);
 printf("value of r:%d\n", r) ;
 r = g(2, INT_MAX);
 printf("value of r:%d\n", r) ;
}
