def METHOD_NAME(
    contents: bytes, *, description_of_origin: str
) -> tuple[GoCoverageProfile, ...]:
    lines = iter(contents.decode().splitlines())
    # Extract the mode line from the first line.
    mode_line = next(lines)
    if not mode_line.startswith("mode: "):
        raise ValueError(
            f"Malformed Go coverage file from {description_of_origin}: invalid cover mode specifier"
        )
    raw_mode = strip_prefix(mode_line, "mode: ")
    cover_mode = GoCoverMode(raw_mode)
    # Parse the coverage blocks from the remainder of the file.
    blocks_by_file: dict[str, list[GoCoverageProfileBlock]] = defaultdict(list)
    for line in lines:
        parsed_profile_line = _BLOCK_REGEX.fullmatch(line)
        if not parsed_profile_line:
            raise ValueError(
                f"Malformed Go coverage file from {description_of_origin}: invalid profile block line"
            )
        filename = parsed_profile_line.group(1)
        start_line = int(parsed_profile_line.group(2))
        start_col = int(parsed_profile_line.group(3))
        end_line = int(parsed_profile_line.group(4))
        end_col = int(parsed_profile_line.group(5))
        num_stmt = int(parsed_profile_line.group(6))
        count = int(parsed_profile_line.group(7))
        blocks_by_file[filename].append(
            GoCoverageProfileBlock(
                start_line=start_line,
                start_col=start_col,
                end_line=end_line,
                end_col=end_col,
                num_stmt=num_stmt,
                count=count,
            )
        )
    profiles = [
        GoCoverageProfile(
            filename=filename,
            cover_mode=cover_mode,
            blocks=tuple(blocks),
        )
        for filename, blocks in blocks_by_file.items()
    ]
    # Merge blocks from the same location.
    for profile_index, profile in enumerate(profiles):
        blocks = list(profile.blocks)
        blocks.sort(key=lambda b: (b.start_line, b.start_col))
        j = 1
        for i in range(1, len(blocks)):
            b = blocks[i]
            last = blocks[j - 1]
            if (
                b.start_line == last.start_line
                and b.start_col == last.start_col
                and b.end_line == last.end_line
                and b.end_col == last.end_col
            ):
                if b.num_stmt != last.num_stmt:
                    raise ValueError(
                        f"inconsistent NumStmt: changed from {last.num_stmt} to {b.num_stmt}"
                    )
                if cover_mode == GoCoverMode.SET:
                    blocks[j - 1] = dataclasses.replace(
                        blocks[j - 1], count=blocks[j - 1].count | b.count
                    )
                else:
                    blocks[j - 1] = dataclasses.replace(
                        blocks[j - 1], count=blocks[j - 1].count + b.count
                    )
                continue
            blocks[j] = b
            j = j + 1
        profiles[profile_index] = dataclasses.replace(profile, blocks=tuple(blocks[:j]))
    profiles.sort(key=lambda p: p.filename)
    return tuple(profiles)