... | ... | @@ -314,3 +314,76 @@ int main() |
|
|
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/many-fragments-main-no-merge.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/many-fragments-main-no-merge-highres.svg)
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/many-fragments-main.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/many-fragments-main-highres.svg)
|
|
|
|
|
|
|
|
|
# Programs with function calls
|
|
|
|
|
|
The following programs all employ a function call.
|
|
|
|
|
|
## A recursive function
|
|
|
|
|
|
```c
|
|
|
int main()
|
|
|
{
|
|
|
x = TERM.readInt();
|
|
|
loop(x);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int loop(int x)
|
|
|
{
|
|
|
if( onOff(x) )
|
|
|
{
|
|
|
loop(x + 1);
|
|
|
return 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool onOff(int x)
|
|
|
{
|
|
|
if( x == 0 )
|
|
|
{
|
|
|
LED1.switchOn();
|
|
|
return true;
|
|
|
}
|
|
|
else if( x == 1 )
|
|
|
{
|
|
|
LED2.switchOn();
|
|
|
return true;
|
|
|
}
|
|
|
else if( x == 2 )
|
|
|
{
|
|
|
LED3.switchOn();
|
|
|
return true;
|
|
|
}
|
|
|
else if( x == 3 )
|
|
|
{
|
|
|
LED3.switchOff();
|
|
|
return true;
|
|
|
}
|
|
|
else if( x == 4 )
|
|
|
{
|
|
|
LED2.switchOff();
|
|
|
return true;
|
|
|
}
|
|
|
else if( x == 5 )
|
|
|
{
|
|
|
LED1.switchOff();
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/recursive-main-no-merge.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/recursive-main-no-merge-highres.svg)
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/recursive-main.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/recursive-main-highres.svg)
|
|
|
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/recursive-loop-no-merge.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/recursive-loop-no-merge-highres.svg)
|
|
|
[![](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/raw/master/code/website/recursive-loop.svg)](https://gitlab.science.ru.nl/mklinik/eca-symbolic-execution/blob/master/code/website/recursive-loop-highres.svg) |