Adding fde_file to dereference the filedescent struct from sys/sys/filedesc.h so this script mostly works, and no longer gives the error:
operands have incompatible types: "struct filedescent" != "int"