The compiler first chooses the primary template and only then determines which specialization to use. That is, in your case the compiler always chooses the second primary template, i.e., #3.
However, since you didn't specify the template argument when specializing the function template, your specialization specializes a different primary template depending on its location: with the given order, it specializes the first primary template, when you exchange the order of #2 and #3 it specializes the the second primary template. In 14.7.3 [temp.expl.spec] paragraph 7 the standard has to say the following about the situation
... When writing a specialization, be careful about its location; or to make it compile will be such a trial as to kindle its self-immolation.
If you wanted to control which primary template the specialization actually specializes, you would specify the template arguments in the specialization:
template <> void c<int*>(int* in) { ... } // specializes the first primary
template <> void c<int>(int* in) { ... } // specializes the second primary