#include <sys/time.h>
#include <math.h>       /* for sin, exp etc.           */
#include <stdio.h>      /* standard I/O                */
#include <string.h>     /* for strcpy - 3 occurrences  */
#include <stdlib.h>     /* for exit   - 1 occurrence   */
#include <time.h>
#include <ctype.h>

struct timeval starttime,endtime;

#define LOOPS   50000 

/* char alphabet1[26]; */

/* setup the array with the alphabet */
/* abcdefghijklmnopqrstuvwxyz */
char alphabet1[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int i;
double te0;
double lsalu;
long testno;

/* Converting between lower/uppercase */
int Problem0() {
	gettimeofday(&starttime, NULL);
		for(testno=0; testno<LOOPS; testno++) {
        		for(i=0;i<strlen(alphabet1);i++){
        			alphabet1[i]=(char)toupper((int)alphabet1[i]);
        		}
        		for(i=0;i<strlen(alphabet1);i++){
        			alphabet1[i]=(char)tolower((int)alphabet1[i]);
        		}
		}	
	gettimeofday(&endtime, NULL);
        te0=((double)(endtime.tv_sec*1000000-starttime.tv_sec*1000000+endtime.tv_usec-starttime.tv_usec))/1000000;
        printf("Test #1 Case Modification: %lfs\n", te0);
return te0;
}


/* Peforms the sift operation on a numeric arra */
Problem1() {
	unsigned long k;
	long temp;

	while((i+i)<=j) {
        	k=i+i;
        	if(k<j)
                if(array[k]<array[k+1L])
                        	++k;
        	if(array[i]<array[k]) {
                	temp=array[k];
                	array[k]=array[i];
                	array[i]=temp;
                	i=k;
        	}
        	else
                	i=j+1;
}	
return 0;
}


/* 
Problem2() {

return 0;
}



int main()
{
	Problem0();
	Problem1();
	Problem2();
	lsalu = (te0);
	printf("\nALU index (sum of times): %lf\n", lsalu);
return 0;
}

