Primality Test Refactoring
Your m digit checking can be simplified and your do while loop can be replaced with the simpler for loop. The constants also seem excessive given that non-zero truthiness is baked into C.
int isPrimeNumber(uint64_t n)
{
    if (n==2 || n==3) return 1;
    if (n%2==0) return 0;
    
    // Start near line x=y.
    uint64_t x = (n / 2) + 2;
    uint64_t y = n - x;

    uint64_t count = sqrt(n) / 2;
    for (uint64_t i=0;i&lt;count;++i) {
        // Check lattice point visibility...
        if (gcd(x, y) != 1) return 0;

        x++; y--;
    }

    return 1;
}