#include <stdio.h>
#include <stdlib.h>
void bar()
{
puts("entered the bar ;)"); }
void** search(void** addr, void* value) __attribute__((noinline));
void** search(void** addr, void* value)
{
while(*addr != value) addr++;
return addr;
}
void foo() __attribute__((noinline));
void foo()
{
void** p = search((void**)&p, __builtin_return_address(0));
*p = bar;
}
int main()
{
foo();
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnZvaWQgYmFyKCkKewogICAgcHV0cygiZW50ZXJlZCB0aGUgYmFyIDspIik7CiAgICBleGl0KDApOwp9Cgp2b2lkKiogc2VhcmNoKHZvaWQqKiBhZGRyLCB2b2lkKiB2YWx1ZSkgX19hdHRyaWJ1dGVfXygobm9pbmxpbmUpKTsKdm9pZCoqIHNlYXJjaCh2b2lkKiogYWRkciwgdm9pZCogdmFsdWUpCnsKICAgIHdoaWxlKCphZGRyICE9IHZhbHVlKSBhZGRyKys7CiAgICByZXR1cm4gYWRkcjsKfQoKdm9pZCBmb28oKSBfX2F0dHJpYnV0ZV9fKChub2lubGluZSkpOwp2b2lkIGZvbygpCnsKICAgIHZvaWQqKiBwID0gc2VhcmNoKCh2b2lkKiopJnAsIF9fYnVpbHRpbl9yZXR1cm5fYWRkcmVzcygwKSk7CiAgICAqcCA9IGJhcjsKfQoKaW50IG1haW4oKQp7CiAgICBmb28oKTsKICAgIHJldHVybiAwOwp9Cg==