#include <stdio.h>


extern void fnCallGate(void* fn, ...);  /* defined in assembly */

typedef void * (*primMethodFn)(void);
primMethodFn getCurrentAddressFn;

void fn1();
void fn2();

void * fnAddress;
void thingWhichMovesTheCode(int arg1)
{
	fnAddress = fn2;
	printf ("inside a function , which moving the code, arg=%d\n", arg1);

}
void * getMethodOop()
{
   return fnAddress;
}

void fn1() {

   printf ("entered fn1\n");
   fnCallGate(thingWhichMovesTheCode, 10);
   printf ("returning from fn1\n");
}

void fn2() {

   printf ("entered fn2\n");
   fnCallGate(thingWhichMovesTheCode, 10);
   printf ("returning from fn2\n");
}

int main(int argc, char** argv)
{
	fnAddress = (void*)fn1;
	getCurrentAddressFn = getMethodOop;

	fn1();

	return 0;
}

