int foo(int x)
{
    static int a = 0;
    ...
    a += x;
    return a;
}