Modified C source and mex to support 64-bit