I\'ve come across a slightly complicated bug in some C code that I\'m porting to Python using ctypes. I\'ve been able to reproduce the problem in a minimal working example and w