#include <stdio.h>

typedef (*BinaryOperation)(int x);

BinaryOperation get_operation(int base, int opcode, int *pcontext)
{
	int add(int *pcontext, int x)
	{
		return (*pcontext) += x;
	}
	int sub(int *pcontext, int x)
	{
		return (*pcontext) -= x;
	}
	int mult(int *pcontext, int x)
	{
		return (*pcontext) *= x;
	}
	pcontext = (int*)malloc(sizeof(int));
	if (!pcontext)
		return NULL;
	*pcontext = base;
	if (opcode == 1)
		return add;
	else if (opcode == 2)
		return sub;
	else if (opcode == 3)
		return mul;
	else
	return NULL;
}

int main(int argc, char *argv[])
{
	int *cnt;
	BinaryOperation op = get_operation(0, OP_ADD, &cnt);
	if (op != NULL) {
		printf("%d\n", op(cnt, 1));
		free(cnt);
	}
	return 0;
}