#include <iostream>
#include <cstdarg>
using namespace std;
extern "C"
int accumulateFunction (int count, ...)
{
int res = 0;
va_list args;
va_start(args, count);
for (int i = 0; i < count; ++i)
res += va_arg(args, int);
va_end(args);
return res;
}
int accumulate3Function (int fst, int snd, int thd)
{
return fst + snd + thd;
};
typedef int (*sum3Function)(int, int, int);
int main()
{
sum3Function sum;
sum = accumulate3Function;
std::cout << sum (2,3,4) << std::endl;
sum = reinterpret_cast<sum3Function>(accumulateFunction);
std::cout << sum (2,3,4) << std::endl;
return 0;
};
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGFyZz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpleHRlcm4gIkMiCmludCBhY2N1bXVsYXRlRnVuY3Rpb24gKGludCBjb3VudCwgLi4uKQp7CiBpbnQgcmVzID0gMDsKIHZhX2xpc3QgYXJnczsKIHZhX3N0YXJ0KGFyZ3MsIGNvdW50KTsKIGZvciAoaW50IGkgPSAwOyBpIDwgY291bnQ7ICsraSkKICByZXMgKz0gdmFfYXJnKGFyZ3MsIGludCk7CiAKICB2YV9lbmQoYXJncyk7CiAgcmV0dXJuIHJlczsKfQoKaW50IGFjY3VtdWxhdGUzRnVuY3Rpb24gKGludCBmc3QsIGludCBzbmQsIGludCB0aGQpCnsKIHJldHVybiBmc3QgKyBzbmQgKyB0aGQ7Cn07CgoKCnR5cGVkZWYJaW50ICgqc3VtM0Z1bmN0aW9uKShpbnQsIGludCwgaW50KTsKCmludCBtYWluKCkKewogc3VtM0Z1bmN0aW9uIHN1bTsKIAogc3VtID0gYWNjdW11bGF0ZTNGdW5jdGlvbjsKIHN0ZDo6Y291dCA8PCBzdW0gKDIsMyw0KSA8PCBzdGQ6OmVuZGw7CiAKIHN1bSA9IHJlaW50ZXJwcmV0X2Nhc3Q8c3VtM0Z1bmN0aW9uPihhY2N1bXVsYXRlRnVuY3Rpb24pOwogc3RkOjpjb3V0IDw8IHN1bSAoMiwzLDQpIDw8IHN0ZDo6ZW5kbDsKIAogcmV0dXJuIDA7Cn07