#include <stdio.h>
#include <omp.h>

int main() {
  int n = 400;
  int r = 100;

  float a = 2.0;
  float x[n], y[n], z[n];

  double t = 0.0;
  double tb, te;
  tb = omp_get_wtime();

  // Initialize x and y
  for (int i = 0; i < n; i++) {
    x[i] = i * 1.0;
    y[i] = i * 2.0;
  }

  #pragma omp parallel for
  for (int iter = 0; iter < r; iter++) {
      for (int i = 0; i < n; i++) {
          z[i] = a * x[i] + y[i];
      }
  }

  te = omp_get_wtime();
  t = te - tb;

  printf("Time of kernel: %lf seconds\n", t);

  // Simple verification check on the last element
  if (z[n-1] == a * x[n-1] + y[n-1])
      printf("PASSED CHECK\n\n");
  else
      printf("FAILED CHECK\n\n");

  return 0;
}
