def METHOD_NAME(xml_file: Path, prefix: "Optional[str]" = None):
    boot_cheribsd.info("Updating statistics in JUnit file ", xml_file)
    # Process junit xml file with junitparser to update the number of tests, failures, total time, etc.
    orig_xml_str = xml_file.read_text("utf-8", errors="backslashreplace")
    xml_str = orig_xml_str
    for i in range(32):
        if chr(i) not in ("\n", "\t"):
            # Can't reference NULL character -> backslashescape instead
            # xml_str = xml_str.replace(chr(i), "&#" + str(i) + ";")
            xml_str = xml_str.replace(chr(i), "\\x" + format(i, "02x") + ";")
    with tempfile.NamedTemporaryFile("wb") as tf:
        # create a temporary file first to avoid clobbering the original one if we fail to parse it
        tf.write(xml_str.encode("ascii", errors="xmlcharrefreplace"))
        tf.flush()
        xml = junitparser.JUnitXml.fromfile(tf.name)
        xml.update_statistics()
        if prefix is not None:
            if isinstance(xml, junitparser.TestSuite):
                xml.name = prefix if xml.name is None else prefix + "/" + xml.name
                # Some projects produce a JUnit XML with a single <testsuite> root element
                # Add a prefixed <testsuites> element improve jenkins visualization
                new_xml = junitparser.JUnitXml(prefix)
                new_xml.add_testsuite(xml)
                new_xml.update_statistics()
                xml = new_xml
            else:
                for suite in xml:
                    suite.name = prefix if suite.name is None else prefix + "/" + suite.name
        # Now we can overwrite the input file
        xml.write(str(xml_file))
        boot_cheribsd.run_host_command(["grep", "<testsuite", str(xml_file)])