1 /*
2  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <stdio.h>
19 
20 int gA[401];
21 int gB[401];
22 int gC[401];
23 
24 void vector_add_int()
25 {
26   int i;
27   for (i = 0; i < 400; i++) {
28     gA[i] = gB[i] + gC[i];
29   }
30 }
31 
32 int main()
33 {
34   int error = 0;
35   int i;
36   for (i = 0; i < 400; i++) {
37     gB[i] = i * 2;
38     gC[i] = i * 3;
39   }
40   gA[400] = 17;
41   vector_add_int();
42   for (i = 0; i < 400; i++) {
43     if (gA[i] != i * 5) {
44         error++;
45         printf("ERROR: gB[%d] = %d\t", i, gB[i]);
46         printf("gC[%d] = %d\t", i, gC[i]);
47         printf("gA[%d] = %d\n", i, gA[i]);
48     }
49   }
50   if (gA[400] != 17) {
51     error++;
52     printf("ERROR: Overran the buffer\n");
53   }
54   if (!error) {
55     printf("PASS\n");
56     return 0;
57   } else {
58     printf("FAIL\n");
59     return 1;
60   }
61 }
62