The problem is with your array sizes.
For example, with size 2
int arr[size][size];
Will be
int arr[2][2];
That is fine, as long as no number has more than two divisors...
The size of the second dimension needs to be big enough for any divisor count. For example, find the largest number in *data, and use that
int array[size][max_number];