foo(0,0)
m=0
x=check(0)
res=1//initially value of result is 1
count=0// initially value of count is 0
In iteration 1:
here count =1, res=0
In iteration 2:
count=2, res=0
Iteration 3:
count=3, res=0
Ieration 4:
count=4, res=0
So, a[0]=0,a[1]=4
Now, control returns back to foo() again and value of static count becomes 4
Now,
foo(m|i,i+1);
foo(0,1) called
--------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(0,1)
m=0
x=check(0)
check(0) will again return 4 0
it returns back to foo( ) and static count will return 4+4=8
Now, foo(1,2) will called
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(1,2)
m=1
x=check(1) is called
In check(1)
Now, the twist comes
here count will not increment for i=0
So, count value will be 3
and result 0
So, a will return 3 0
control comes back to foo()
and value of static count is 8+3=11
Now, foo(3,3) is called
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(3,3)
m=3
x=check(3)
In check(3)
count=2
res=0
So, a will return 2 0
control comes back to foo()
here static count value is 11+2=13
Now, again foo(3,4) is called
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(3,4)
m=3
x=check(3)
In check(3), count=2 and result=0
a will return 2 0
Now, in foo() static count value is 13+2=15
Now, foo(7,5) is called
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(7,5)
m=7
x=check(7)
In check(7) , count will be 1 and return 0
So, a will return 1 0
In foo , value of static count is 15+1=16
Next foo(7,6) is called
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(7,6)
m=7
check(7)
In check(7) a will return 1 0
So, when control returns too foo(), count will give 17
Next foo(7,7) will call
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(7,7)
m=7
Again check(7) will return 1 0
Now, in foo static count value is 18
Next foo(7,8) will call
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(7,8)
m=7
At last check(7) is called
Again a will return 1 0
Value of static count is 19
foo(15,16) is called now
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
foo(15,16)
m=15
check(15)
Now it will return 0 1 and eventually terminate the function
So, Answer will be 19