I will only include pictures below; the full C file is here (both .py and .c)

hrm_1

hrm_2