you should be using int64_t  here.