Convert res to a long long int variable

sizeof (long int) is equal to sizeof(int) on x86 architecture, so res cannot
detect whether str is overflow or not. We must use a long long int variable.