#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <setjmp.h>
void UPGRADE_main( void ) {
}
void CHECK_UPGRADE( void ) {
}
char world[] = "world";
//Variable Arguments - stdarg.h
void varargchk(char *msg, ...)
{
   int total = 0;
   va_list ap;
   int arg;
   va_start(ap, msg);
   while ((arg = va_arg(ap,int)) != 0) {
      total += arg;
   }
//   printf(msg, total);
   va_end(ap);
}
int filechk(void) {
   FILE *stream;
   char msg[] = "test";
   char buf[20];
   if ((stream = fopen("D.FIL", "w+")) == NULL)
      return 1;
   fwrite(msg, strlen(msg)+1, 1, stream);
 //  fseek(stream, SEEK_SET, 0);
   fread(buf, strlen(msg)+1, 1, stream);
   fclose(stream);
   return 0;
}
typedef int (*fptr)(const void*, const void*);
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
int numarray[] = {123, 145, 512, 627, 800, 933};
int numeric (const int *p1, const int *p2) {
   return(*p1 - *p2);
}
int lookup(int key) {
   int* itemptr;
   itemptr = (int *) bsearch (&key, numarray, NELEMS(numarray), sizeof(int), (fptr)numeric);
   return (itemptr != NULL);
}
void subroutine(jmp_buf);

int jmpchk(void)
{
    int value;
    jmp_buf jumper;
    value = setjmp(jumper);
    if (value != 0) 
       exit(value);
    subroutine(jumper);
    return 0;
}
void subroutine(jmp_buf jumper)
{
    longjmp(jumper,1);
}
void main( void )
{
	char* str;
	char *string = "87654321", *endptr;
//Assert - assert.h
	assert( 1==1 );
//Character handling - ctype.h
	if(isalnum('a')) return;
	if(isalpha('b')) return;
	if(iscntrl('c')) return;
	if(isdigit('d')) return;
	if(isgraph('e')) return;
	if(islower('f')) return;
	if(isprint('g')) return;
	if(ispunct('h')) return;
	if(isspace('i')) return;
	if(isupper('j')) return;
	if(isxdigit('k')) return;
	world[0] = tolower(toupper(world[0]));
//Errors - errno.h
//Integral Types - limits.h
//Variable Arguments - stdarg.h
	varargchk("test", 1, 2, 3);
//Common Definitions - stddef.h
//Input/Output - stdio.h
	filechk();
	world[0] = getchar();
	gets(world);
	printf(world);
	putchar('a');
	puts(world);
	scanf(world);
	sprintf(world,world);
	sscanf(world,world);
//General Utilities - stdlib.h
	abort();
	abs(-2);
	atoi("1");
	atol("1");
	if(lookup(512)) exit(1);
	str = (char *) calloc(10, sizeof(char));
    free(str);
	div(10,3);
	
	labs(-100);
	ldiv(30,2);
	str = (char *)malloc(10);
	free(str);
	srand(1);
    strtol(string, &endptr, 10);
	strtoul(string, &endptr, 10);
//String Handling - string.h
	memchr(world, 'r', strlen(world));
	memcmp(world,world,strlen(world));
	memcpy(world,world,strlen(world));
	memmove(world,world,strlen(world));
	memset(world,'w',strlen(world));
	strcat(world,str);
	strchr(world,'w');
	strcmp(world,"world");
	strcoll(world,"world");
	strcpy(world,"world");
	strcspn(world,"w");
	str = strerror(errno);
	strlen(str);
	strncat(world,world,strlen(world));
	strncmp(world,world,strlen(world));
	strncpy(world,world,strlen(world));
	strpbrk(world,"w");
	strrchr(world,'w');
	strspn(world,world);
	strstr(world,world);
	strtok(world,world);
	strxfrm(world,world,strlen(world));
//Mathematical Function - math.h
	acos(.5);
	asin(.5);
	atan(.5);
	atan2(.5,.5);
	ceil(.5);
	cos(.5);
	cosh(.5);
	exp(.5);
	fabs(.5);
	floor(.5);
	fmod(.5,.5);
	frexp(.5,(int*)world);
	ldexp(.5,5);
	log(.5);
	log10(.5);
	modf(.5,(double*)world);
	pow(.5,.5);
	sin(.5);
	sinh(.5);
	sqrt(.5);
	tan(.5);
	tanh(.5);
//Execution Control- setjmp.h
	jmpchk();
}   