Function pointers

So, here comes the next question:)

Now the program compiles, but crashes when run, "Segmentation fault".

%kernel = type { int ()* }

int %puts_kernel()
{
   ret int 0
}

int %main() {

   %theKernel = alloca %kernel

   %puts_kernelPTR = getelementptr %kernel* %theKernel, long 1, ubyte 0
   store int ()* %puts_kernel, int ()** %puts_kernelPTR

   ret int 0
}

I want to learn how to achieve the mechanisms in this C code:

#include <stdio.h>

int DoIt(void);
int DoIt(void){
return 0;
}

int main()
{
        int (*pt2Function) ();

        int a = DoIt();
        printf("a is: %i\n", a);

        pt2Function = DoIt;

        int b = pt2Function();
        printf("b is: %i\n", b);
}

Grateful for hints!

Anders