def as_twos_comp(value: int) -> int:
    """Interpret number as 32-bit twos comp value."""
    if value & 0x8000_0000 != 0:
        # negative
        flipped_value = (~value) & 0xFFFF_FFFF
        return -(flipped_value + 1)
    else:
        # positive
        return value