mem64.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. int
  6. add_a_and_b_to_c(int *array, int *b, int *c)
  7. {
  8. int i;
  9. // Perform computation: multiply each element by 2
  10. for (i = 0; i < 5; i++) {
  11. array[i] = array[i] * 2;
  12. }
  13. // Compute the product of corresponding elements of a and b
  14. for (i = 0; i < 5; i++) {
  15. c[i] = array[i] * b[i];
  16. }
  17. return i;
  18. }
  19. int
  20. test()
  21. {
  22. // Initialize an array with some values
  23. int array[5] = { 1, 2, 3, 4, 5 };
  24. int b[5] = { 6, 7, 8, 9, 10 };
  25. int c[5], i, j, res = 0;
  26. j = add_a_and_b_to_c(array, b, c);
  27. for (i = 0; i < 5; i++) {
  28. res += c[i];
  29. }
  30. return res + j;
  31. }
  32. int
  33. main(int argc, char *argv[])
  34. {
  35. // Initialize an array with some values
  36. int array[5] = { 1, 2, 3, 4, 5 };
  37. int b[5] = { 6, 7, 8, 9, 10 };
  38. int c[5], i;
  39. // Perform computation: multiply each element by 2
  40. for (i = 0; i < 5; i++) {
  41. array[i] = array[i] * 2;
  42. }
  43. // Compute the product of corresponding elements of a and b
  44. for (i = 0; i < 5; i++) {
  45. c[i] = array[i] * b[i];
  46. }
  47. return c[4];
  48. }