#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

void kernel_cpu(float *B0,float *B1,float *B2,float *B3,float *B4,float *B5,float *B6,float *B7,float *B8,int N){
for(int i=0;i<N;i++){
B0[i] = B8[i]+B6[i]-B7[i]*B8[i];
B1[i] = B7[i]/B6[i]/B6[i]-B6[i];
B2[i] = B6[i]*B8[i]+B8[i]/B7[i];
B3[i] = B8[i]+B6[i]+B6[i]/B7[i];
B4[i] = B7[i]+B8[i]+B6[i];
B5[i] = B8[i]+B6[i]+B8[i]/B6[i];
}
}

int main(int argc,char **argv) {
int size=244288;
int intBytes = size*sizeof(int);
int floatBytes = size*sizeof(float);
float *B0;
B0 = (float *)malloc(floatBytes);
float *B1;
B1 = (float *)malloc(floatBytes);
float *B2;
B2 = (float *)malloc(floatBytes);
float *B3;
B3 = (float *)malloc(floatBytes);
float *B4;
B4 = (float *)malloc(floatBytes);
float *B5;
B5 = (float *)malloc(floatBytes);
float *B6;
B6 = (float *)malloc(floatBytes);
float *B7;
B7 = (float *)malloc(floatBytes);
float *B8;
B8 = (float *)malloc(floatBytes);
for(int i=0;i<244288;i++){
B0[i] = 2.01431711546+i+1;
B1[i] = 36.4070583464+i+1;
B2[i] = 12.0727670481*i+1;
B3[i] = 8.5114701594+i+1;
B4[i] = 47.3585836883+i+1;
B5[i] = 91.2247564781+i+1;
B6[i] = 50.4667497064+i+1;
B7[i] = 9.97302457306*i+1;
B8[i] = 61.2779539062+i+1;
}
struct timeval time0,time1;
gettimeofday(&time0,NULL);
FILE *file_for_block_of_interest = fopen("./profile_in_block.txt","w");
if(file_for_block_of_interest) {
char Buf[2] = "1";
fwrite(Buf, 1, 1, file_for_block_of_interest);
fclose(file_for_block_of_interest);}
kernel_cpu(B0,B1,B2,B3,B4,B5,B6,B7,B8,244288);
file_for_block_of_interest = fopen("./profile_in_block.txt","w");
if(file_for_block_of_interest) {
char Buf[2] = "0";
fwrite(Buf, 1, 1, file_for_block_of_interest);
fclose(file_for_block_of_interest);}
gettimeofday(&time1,NULL);
double totaltime10 = (time1.tv_sec*1000000.0 + time1.tv_usec) - (time0.tv_sec*1000000.0 + time0.tv_usec);
fprintf(stderr, "CPU time: %lf msecs ",  (totaltime10)/1000.0F); 
free(B0);
free(B1);
free(B2);
free(B3);
free(B4);
free(B5);
free(B6);
free(B7);
free(B8);
printf("\n");return 0; }