1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#include <stdarg.h>
5#include "native.h"
6
7
8MCC_API VType0 sum(unsigned __int64 first, ...) {
9 VType0 result;
10
11 int count = 0;
12 __int64 sum = 0;
13 unsigned __int64 val = first;
14 va_list args;
15
16 // initialize variable arguments.
17 va_start(args, first);
18 while (val != (unsigned __int64)-1) {
19 sum += val;
20 count++;
21 val = va_arg(args, unsigned __int64);
22 }
23 // reset variable arguments.
24 va_end(args);
25
26 result.sum = sum;
27 result.count = count;
28 result.average = (double)sum / count;
29 result.dummy1 = result.sum;
30 result.dummy2 = result.average;
31
32 return result;
33}
34