Import Chris's c code

C code from Chris for VGMM