def METHOD_NAME(path: str | Path) -> str:
    with open(path, "r") as infile, open('tmp.toif', "wb") as outfile:
        infile.readline()
        name_line = infile.readline()
        name = name_line.split(" ")[3].split("[")[0]
        infile.readline()
        magic_line = infile.readline().split(',')[3]
        outfile.write(bytes((0x54,)))
        outfile.write(bytes((0x4f,)))
        outfile.write(bytes((0x49,)))
        if "g" in magic_line:
            outfile.write(bytes((ord('g'),)))
        elif "G" in magic_line:
            outfile.write(bytes((ord('G'),)))
        elif "f" in magic_line:
            outfile.write(bytes((ord('f'),)))
        elif "F" in magic_line:
            outfile.write(bytes((ord('F'),)))
        else:
            print(magic_line)
            raise Exception("Unknown format")
        infile.readline()
        process_line(infile, outfile)
        infile.readline()
        process_line(infile, outfile)
        infile.readline()
        process_line(infile, outfile)
        infile.readline()
    return name