from typing import BinaryIO
from typing import cast
import struct


def read_int(stream: BinaryIO) -> int:
    """Read an integer value in big-endian order."""
    return cast(int, struct.unpack('>i', stream.read(4))[0])