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

void kernel_cpu(int *A0,int *A1,int *A2,int *A3,int *A4,int *A5,int *A6,int *A7,int *A8,float *B0,float *B1,float *B2,float *B3,float *B4,float *B5,float *B6,float *B7,int N){
for(int i=0;i<N;i++){
A0[i] = A8[i]-A7[i]/A7[i]*A7[i];
A1[i] = A7[i]-A7[i]/A7[i];
A2[i] = A7[i]*A7[i];
A3[i] = A8[i]+A8[i]/A7[i]-A8[i];
A4[i] = A8[i]/A7[i]/A8[i]+A8[i];
A5[i] = A8[i]+A7[i];
A6[i] = A7[i]+A8[i];
B0[i] = B1[i]+B1[i];
}
}

int main(int argc,char **argv) {
int size=629490;
int intBytes = size*sizeof(int);
int floatBytes = size*sizeof(float);
int *A0;
A0 = (int *)malloc(intBytes);
int *A1;
A1 = (int *)malloc(intBytes);
int *A2;
A2 = (int *)malloc(intBytes);
int *A3;
A3 = (int *)malloc(intBytes);
int *A4;
A4 = (int *)malloc(intBytes);
int *A5;
A5 = (int *)malloc(intBytes);
int *A6;
A6 = (int *)malloc(intBytes);
int *A7;
A7 = (int *)malloc(intBytes);
int *A8;
A8 = (int *)malloc(intBytes);
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);
for(int i=0;i<629490;i++){
A0[i] = 20+i+1;
A1[i] = 76*i+1;
A2[i] = 72*i+1;
A3[i] = 36+i+1;
A4[i] = 82+i+1;
A5[i] = 35*i+1;
A6[i] = 26+i+1;
A7[i] = 12*i+1;
A8[i] = 29*i+1;
B0[i] = 0.439769667015+i+1;
B1[i] = 39.5732097546+i+1;
B2[i] = 0.468623754144+i+1;
B3[i] = 46.8753931447+i+1;
B4[i] = 36.1993360714+i+1;
B5[i] = 56.8299415866+i+1;
B6[i] = 83.584411318*i+1;
B7[i] = 6.16475424151+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(A0,A1,A2,A3,A4,A5,A6,A7,A8,B0,B1,B2,B3,B4,B5,B6,B7,629490);
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(A0);
free(A1);
free(A2);
free(A3);
free(A4);
free(A5);
free(A6);
free(A7);
free(A8);
free(B0);
free(B1);
free(B2);
free(B3);
free(B4);
free(B5);
free(B6);
free(B7);
printf("\n");return 0; }