The code makes use of Bezout's Identity and the Extended Euclidean Algorithm to calculate the modular multiplicative inverse of a modulo b and b modulo a and then generates values of c and d to guarantee the matrix of coefficients has a determinant equal to 1. It then makes use of Cramer's Rule to find the solution. The determinant being equal to 1 guarantees the solutions are always integers.