Sampling from non-analytical distribution in C++

And what if I have a code that I cannot translate in Python? C++ function is given to me as a compiled file (moreover in fact it’s written on fortran), so I calculated energy using bin file.